Skip to content

Instantly share code, notes, and snippets.

@indy-singh
Last active December 28, 2024 20:04
Show Gist options
  • Select an option

  • Save indy-singh/7b357a954683bae63d38ecce2d331fee to your computer and use it in GitHub Desktop.

Select an option

Save indy-singh/7b357a954683bae63d38ecce2d331fee to your computer and use it in GitHub Desktop.
# required to load in the DLLs
[Windows.ApplicationModel.DataTransfer.Clipboard, Windows.ApplicationModel.DataTransfer, ContentType=WindowsRuntime];
# this one doens't seem to work but registers fine
[Windows.ApplicationModel.DataTransfer.Clipboard]::add_ContentChanged({[Console]::Beep()});
# this one does beep
[Windows.ApplicationModel.DataTransfer.Clipboard]::add_HistoryChanged({[Console]::Beep()});
# Used
# https://devblogs.microsoft.com/oldnewthing/20230303-00/?p=107894
# https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.datatransfer.clipboard.contentchanged?view=winrt-26100
# https://stackoverflow.com/a/74225141
# https://www.therealomar.com/articles/2022-07/TIL-powershell-event-handlers
# https://stackoverflow.com/a/64232782
@indy-singh

Copy link
Copy Markdown
Author

Note: This only works in old school Powershell, pwsh (the newer one) blows up which I haven't bothered to look into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment