Last active
December 28, 2016 11:14
-
-
Save saggie/355e3883809c28904cdbf5aa67fba782 to your computer and use it in GitHub Desktop.
Observing the clipboard and logging its history by PowerShell. ref: http://qiita.com/saggie/items/481461a436a1d6801bbd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set window title | |
(Get-Host).UI.RawUI.WindowTitle = $MyInvocation.MyCommand | |
# get text from the clipboard | |
Add-Type -AssemblyName System.Windows.Forms | |
$clipText = [Windows.Forms.Clipboard]::GetText() | |
Write-Host $clipText | |
while ($true) | |
{ | |
# check if there is any updates in the clipboard | |
$latestClipText = [Windows.Forms.Clipboard]::GetText() | |
if ($latestClipText -ne $clipText) | |
{ | |
# update the cache | |
$clipText = $latestClipText | |
Write-Host "- - -" | |
Write-Host $clipText | |
} | |
Start-Sleep -Seconds 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set THIS_FILE_PATH=%~dp0 | |
powershell.exe -STA -File "%THIS_FILE_PATH%ClipboardObserver.ps1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment