在Powershell中同时按下Windows徽标键+ Alt + PrtScn的多个键? [英] Multiple key press simultaneously for Windows logo key + Alt + PrtScn in powershell?

查看:205
本文介绍了在Powershell中同时按下Windows徽标键+ Alt + PrtScn的多个键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过引用该链接尝试了以下代码,但一次无法按下这些键.

I tried the below code by referred the link but not able to press those keys at a time.

我需要任何更改吗?

$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

我认为您应该能够使用Win "%{PRTSC}"之类的"Win"功能来获取所需的内容

I assume you should be able to use the function "Win" like Win "%{PRTSC}" to get what you want

这篇关于在Powershell中同时按下Windows徽标键+ Alt + PrtScn的多个键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆