我通过引用链接尝试了下面的代码,但无法一次按下这些键。
我需要改变吗?
$code = @'
namespace SendTheKeys {
class SendIt {
public static void Main(string[] args) {
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
private const int KEYEVENTF_EXTENDEDKEY = 1;
private const int KEYEVENTF_KEYUP = 2;
public static void KeyDown(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0);
}
public static void KeyUp(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}
}
}
'@
Add-Type -TypeDefinition $source -ReferencedAssemblies "System.Windows.Forms"
[KeyboardSend.KeyboardSend]::KeyDown("LWin")
[KeyboardSend.KeyboardSend]::KeyDown("Alt")
[KeyboardSend.KeyboardSend]::KeyDown("PrintScreen")
[KeyboardSend.KeyboardSend]::KeyUp("LWin")
[KeyboardSend.KeyboardSend]::KeyUp("Alt")
看看这段代码:https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1 https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1
我认为您应该能够使用“Win”功能,例如Win "%{PRTSC}"
得到你想要的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)