c# - Powershell中的Windows徽标键+ Alt + PrtScn同时按下多个键?
问题描述
我通过引用链接尝试了以下代码,但无法一次按下这些键。
我需要任何改变吗?
$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”功能Win "%{PRTSC}"
来获得您想要的东西
推荐阅读
- node.js - Balance Transfer 示例的 invoke-transaction.js 中的 Transaction ID 响应有什么用?
- jquery - 如何禁用 DataTable 中的垂直滚动条?
- c# - 单元测试:使用 MSTest 将复杂对象作为输入参数发送到我的测试方法
- javascript - 你如何在Javascript中反转字符串插值
- mapbox - 用 turf.js 和 mapbox 测量画线长度
- c# - 如何将 JSON 数据格式化为动态生成对象属性的 C# 对象
- python - 通过 Django Rest Framework 中的查找表进行迭代
- python - 如何在字典中添加用户?
- hadoop - Apache pig 错误 org.apache.pig.backend.hadoop.executionengine.Launcher - 错误:org.apache.avro.file.DataFileWriter$AppendWriteException:
- c++ - 引用特定函数参数