Multiple key press simultaneously for Windows logo key + Alt + PrtScn in powershell?

五迷三道 提交于 2020-05-17 06:54:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!