Open henryliangt opened 1 year ago
SendComboKey.bat
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%cd%\SendComboKey.ps1'"
pause
exit
SendComboKey.ps1
Write-Host ""
Write-Host "Combo hot keys Listening Started..." -ForegroundColor Red
Write-Host ""
$key = [Byte][Char]' ' ## Letter
$key2 = '0x11' ## Ctrl
$key3 = '0x12' ## Alt
$Signature = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
'@
Add-Type -MemberDefinition $Signature -Name Keyboard -Namespace PsOneApi
do
{ If( [bool]([PsOneApi.Keyboard]::GetAsyncKeyState($key) -eq -32767 -and
[PsOneApi.Keyboard]::GetAsyncKeyState($key2) -eq -32767 -and
[PsOneApi.Keyboard]::GetAsyncKeyState($key3) -eq -32767))
{
Write-Host "The hotkeys Ctrl + Alt + Space has been pressed." -ForegroundColor Green
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("{F1}")
Write-Host "F1 key pushed to current active window." -ForegroundColor Green
Start-Sleep -Milliseconds 100
Write-Host "Start Sleep 0.1 s" -ForegroundColor Green
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Write-Host "Enter key pushed to current active window." -ForegroundColor Green
$ClipBoard = Get-Clipboard
$ClipArray= $ClipBoard.Split(" ")
Set-Clipboard -Value $ClipArray[0]
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("^{v}")
Write-Host "Get Clipboard to array and first word pushed to current active window." -ForegroundColor Green
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Write-Host "Enter key pushed to current active window." -ForegroundColor Green
Write-Host ""
}
Start-Sleep -Milliseconds 1
} while($true)
RunCopynPaste.bat
CopynPaste.ps1