用程序实现鼠标在桌面上的按键操作(100分)

  • 主题发起人 主题发起人 罗海鹰
  • 开始时间 开始时间

罗海鹰

Unregistered / Unconfirmed
GUEST, unregistred user!
; 请问怎样能够用程序来控制鼠标,让它在桌面上执行按键操作。
就如同用手来来操作鼠标,执行按左右键或移动鼠标一样?
请高手不吝赐教,感激不尽!!!
 
The mouse_event function synthesizes mouse motion and button clicks.

VOID mouse_event(

DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);
 
1.首先要确定鼠标的位置(即鼠标定位),
SetCursorPos(x,y);//鼠标定位到指定座标
2.产生鼠标按键事件
mouse_event(MOUSEEVENTF_LEFTDOWN+MOUSEEVENTF_LEFTUP,x,y,0,GetMessageExtraInfo());//左键
mouse_event(MOUSEEVENTF_RIGHTDOWN+MOUSEEVENTF_LEFTUP,x,y,0,GetMessageExtraInfo());//右键
 
这是贴以前的
来自:wjiachun
打开我的电脑:

procedure TForm1.Button1Click(Sender: TObject);
begin
SetCursorPos(25,25);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;
 
SetCursorPos、mouse_event
 
USE
MOUSE_EVENT & SETCURSORPOS FUNCTION TO DO IT
YOU CAN PRESS F1 FOR MORE HELP IN DELPHI
 
以前有很多类似的帖子。
 
多人接受答案了。
 
后退
顶部