【问题标题】:Multiple key press simultaneously for Windows logo key + Alt + PrtScn in powershell?Powershell中的Windows徽标键+ Alt + PrtScn同时按下多个键?
【发布时间】:2020-03-31 08:33:24
【问题描述】:

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

我需要任何改变吗?

$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")

【问题讨论】:

  • 这很难。建议使用 InputSimulator

标签: c# powershell powershell-ise pester


【解决方案1】:

看看这段代码:https://github.com/stefanstranger/PowerShell/blob/master/WinKeys.ps1

我假设你应该能够使用“Win”这样的函数 Win "%{PRTSC}" 来获得你想要的东西

【讨论】:

    猜你喜欢
    • 2020-07-08
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 2017-02-16
    相关资源
    最近更新 更多