954,135 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to simulate mouse movement and click

:( Hi,
I am creating a program that analyses a GUI within Windows XP environment.I am using Java to do all the Guis and other bits. Also, I use Java Native Interface to talk to Windows API. I am having a few problems. I need to make a mouse pointer move across on top of a program such as word, IE,etc in the windows XP environment and click a specified button.
How do I make a mouse move to a specified point and click?
eg, moveMouse(int x, int y);
IF you could give me tips, sample codes or working codes, that would be great.

oujmjyu
Newbie Poster
2 posts since Jun 2004
Reputation Points: 11
Solved Threads: 0
 

If you know the window to send them to, you can use WM_MOUSEMOVE and WM_MOUSEACTIVATE. But you have to know the HWND. One way to do that is to use EnumWindows and EnumChildWindows to find the button in the app you are looking for.

Another approach is to pick an x,y and call WindowFromPoint() or ChildWindowFromPoint, and then with the HWND that returns, send IT the WM_MOUSEMOVE or WM_MOUSEACTIVATE.

Hope that gives you a starting point.

Chainsaw
Posting Pro in Training
436 posts since Jun 2004
Reputation Points: 36
Solved Threads: 11
 
foolpanda
Newbie Poster
2 posts since Jun 2004
Reputation Points: 11
Solved Threads: 0
 

Thanks.. Let me try this and get back to you..

Man... There are so many good people other...

oujmjyu
Newbie Poster
2 posts since Jun 2004
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You