问题
I tried the below code by referred the link but not able to press those keys at a time.
Do I need any change?
$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")
回答1:
have a look at this code: https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1
I assume you should be able to use the function "Win" like Win "%{PRTSC}"
to get what you want
来源:https://stackoverflow.com/questions/60946380/multiple-key-press-simultaneously-for-windows-logo-key-alt-prtscn-in-powersh