模拟按键不稳定时好时坏,该怎么处理
模拟按键不稳定时好时坏C# codeIntPtr a FindWindow(VoiceRoomForm, null)//查找窗口IntPtr b Find
模拟按键不稳定时好时坏
C# code IntPtr a = FindWindow("VoiceRoomForm", null);//查找窗口 IntPtr b = FindWindowEx(a, IntPtr.Zero, "ExtraEd", null);//查找子控件 if (b != IntPtr.Zero) { ShowWindow(a, 3); SetForegroundWindow(b); keybd_event(0x11, 0, 0, 0); keybd_event(86,0,0,0); keybd_event(86,0,0x2,0); keybd_event(0x11, 0, 0x2, 0); }
用这个去向一个对话框内去粘贴 有时候能粘贴上有的时候粘贴不上 在记事本里一直都好使
[解决办法]每个操作之前加Sleep,来点延时,不然操作系统觉得你操作太快了。
[解决办法]SetForegroundWindow(b);
Sleep(100);
keybd_event(0x11, 0, 0, 0);
Sleep(100);
keybd_event(86,0,0,0);
Sleep(100);
keybd_event(86,0,0x2,0);
Sleep(100);
keybd_event(0x11, 0, 0x2, 0);
Sleep(100);