怎样编程让鼠标移动 (5分)

  • 主题发起人 supershan
  • 开始时间
S

supershan

Unregistered / Unconfirmed
GUEST, unregistred user!
通过编程让鼠标在WIN98的桌面上移动,并在指定的地方CLICK一次
(例如:在‘我的电脑’图标上CLICK一次),该怎样做呢?
 
sendmessage again:(
find a component called simulator it should work
 
可不可以这样:
先SetCursorPos到你要指向的位置,然后发送WM_LBBUTTONDOWN消息
(可能还要再发一个WM_LBBUTTONUP消息)
 
我记得前几天刚有一个人问过类似问题,后来好像eyes做了解答.
 
用mouse_event可以产生mouse的所有事件;NT4 SP3或Win98 下用SendInput
 
SendInput??
怎样用牙?
 
SendInput
The SendInput function synthesizes keystrokes, mouse motions, and
button clicks.

UINT SendInput(
UINT nInputs, // count of input events
LPINPUT pInputs, // array of input events to insert
int cbSize // size of an INPUT structure
);

INPUT
The INPUT structure is used by SendInput to synthesize keystrokes,
mouse motions, and button clicks.

typedef struct tagINPUT {
DWORD type;
union
{
MOUSEINPUT mi;
KEYBDINPUT ki;
HARDWAREINPUT hi;
};
} INPUT, *PINPUT, FAR* LPINPUT;

QuickInfo
Windows NT: Requires version 4.0 SP3 or later.
Windows: Requires Windows 98 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.


 
这个函数不错,不过有点危险. 谁也不能保证别人的机器是win98+
 
呵呵,所以我只用mouse_event
 
你说的mouse_event也是一个现成的函数吗?
 
GetCursorPos , SetCursorPos WindowsAPI的函数

SendMessage(0,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(x,y));
SendMessage(0,WM_LBUTTONUP,MK_LBUTTON,MAKELONG(x,y));
 
mouse_event是一个专门用于模拟鼠标动作的Api函数,用它肯定可以达到你的要求
的。与此相应还有个Keybd_event用于模拟键盘动作.
 
移动得方法可以实现,但是如何知道'我的电脑’图标得位置呢?!!!!
 
不错,Mouse_Event可以Fake鼠标的移动、单击,可是要得到桌面上的图标的位
置恐怕不现实,应该换一种思路。
 
mouseevent怎么个用法啊?
举个例子???tqz?
 
比如说移到屏幕(50,50)的地方按一下?
 
SetCursorPos(50,50);
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
如果要在某个特定的窗口的某处模拟,首先要SetForegroundWindow
 

Similar threads

回复
0
查看
511
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
741
SUNSTONE的Delphi笔记
S
顶部