Add-Type @' using System; using System.Runtime.InteropServices; public class HKTest { [DllImport("user32.dll", SetLastError=true)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint mods, uint vk); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("kernel32.dll")] public static extern IntPtr GetConsoleWindow(); } '@ $h = [HKTest]::GetConsoleWindow() Write-Host "hwnd=$h" foreach ($spec in @(@('Ctrl+Alt+Q', 3, 0x51), @('Ctrl+Alt+K', 3, 0x4B), @('Ctrl+Alt+W', 3, 0x57), @('Ctrl+Shift+Space', 6, 0x20))) { $ok = [HKTest]::RegisterHotKey($h, 1, [uint32]$spec[1], [uint32]$spec[2]) $err = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error() Write-Host ($spec[0] + ' => ' + $ok + ' err=' + $err) if ($ok) { [void][HKTest]::UnregisterHotKey($h, 1) } }