远程控制篇:模拟按键

类别:Delphi 点击:0 评论:0 推荐:

远程控制篇:模拟按键

模拟鼠标

鼠标移动(移动量dx,dy)
mouse_event(MOUSEEVENTF_MOVE,dx,dy,0, 0 );
鼠标在(x,y)处按下或释放
setcursorpos(x,y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 );
鼠标双击由两次按下与释放来模拟

键盘模拟

一般虚拟键值(VK_)由KeyDown或keyup事件得到
特殊键值
Tab--9
Shift--16
Ctrl--17
Alt--18
CapsLock--20
Esc--27
Win--91,92
NumLock--144
ScrollLock--145

按下键
keybd_event(key, MapVirtualKey(key, 0 ), KEYEVENTF_KEYUP , 0 );
释放键
keybd_event(key, MapVirtualKey(key, 0 ), 0 , 0 );
以上做法对大多数键有效,少数键要用到不同的值

--------------------------------------------
湖北襄樊  官本和([email protected])  2001.4
详见主页源程序:
http://delphi21cn.yeah.net
http://personal.hb.cninfo.net/~gbh

本文地址:http://com.8s8s.com/it/it6240.htm