
- 帖子
- 11
- 积分
- 23
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2023-10-7
|
你看看同样的问题
Nsqs 发表于 2023-10-7 21:12 
非常感谢 你的热心回复
我不会修改参数 有哪位好心人帮我修改一下 vbs按下小键盘5
param([byte]$Key,[byte]$Shift)
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Keyboard {
[DllImport("user32.dll")]
private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
Keyboard(){}
public static void Sendkeys(byte key, byte shift = 0){
if(shift == 0){
keybd_event(key, 0, 0, 0);
keybd_event(key, 0, 2, 0);
}else{
keybd_event(shift, 0, 0, 0);
keybd_event(key, 0, 0, 0);
keybd_event(key, 0, 2, 0);
keybd_event(shift, 0, 2, 0);
}
}
}
"@;
[Keyboard]::Sendkeys($Key,$Shift) # Ctrl=17;97=Num1COPY
保存为PowerShell代码
然后vbs代码
function KeyBoard(byval vkey,byval shift)
set ws=createobject("Wscript.Shell")
ws.run "powershell -noprofile -executionpolicy bypass -file "&chr(34)& "SendKeys.ps1"&chr(34)&chr(32)&vKey&chr(32)&Shift,0
end function
'使用方法<键值,组合键值>
KeyBoard 97,17 'Ctrl=17COPY
与PowerShell脚本保存在同一文件夹内进行测试 |
|