回复 5# wyhs4000
SendKeys.ps1- 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=Num1
复制代码 Run.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 101,0
复制代码
|