Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Poltras

Programming a fake mouse mover/clicker...

This topic is 6625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I want to make a "Fake Surfer" like program. That is, the application move the mouse, click the mouse and do a ton of other things with the mouse. I want it to work with my own application, but also with other applications. All I want to know is how to work with mouse/keyboard queue so I can make a mouse move the way I want and click on everything possible in the screen, plus make Windows think that some keys are really pressed on the keyboard and mouse is really moving/clicking. Thanks.
Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Poltras

Ok I want to make a "Fake Surfer" like program. That is, the application move the mouse, click the mouse and do a ton of other things with the mouse.
I want it to work with my own application, but also with other applications.

All I want to know is how to work with mouse/keyboard queue so I can make a mouse move the way I want and click on everything possible in the screen, plus make Windows think that some keys are really pressed on the keyboard and mouse is really moving/clicking.

Thanks.




I know there are API calls to fake it. I know primarily VB, but the API stuff I believe is WM_MouseMove, WM_KeyPress.... things like that. Check those out in your API documentation.



B e S
It's Da BOMB Baby!!!

Edited by - wrenhal on August 30, 2000 2:10:16 PM

Share this post


Link to post
Share on other sites
You can post your own WM_MOUSE..., WM_Key..., WM_SYSKEY... type messages to your window or another window. I''m not sure whether you can actually move the mouse around, but you can hide the mouse and create your own mouse icon and move that around. I do not recall it being too difficult to find the handles of all the open windows on the desktop, but I don''t remember the details of doing that. You should be able to find it easily enough.

Keep in mind that this is the type of program that can really generate a bunch of different problems in a hurry if you''re not very careful.

information is the illusion of knowledge

Share this post


Link to post
Share on other sites
I don''t know how to do it, but I know that it is possible. Check out WinRunner from Mercury Interactive. It is a program that you can use to automate testing, among other things. You can pretty much completely simulate a user with it, so if a real person can do it, WinRunner can do it, plus a bit more.

Unfortunately, it isn''t free. But, at least it is some proof that it can be done!

Share this post


Link to post
Share on other sites
There is a SetCursorPos API function that sets the position of the cursor, I''v used it and it works really good. You just set the coordinates where you want the cursor and it moves there.

Share this post


Link to post
Share on other sites
A little more info (I got curious and looked some stuff up). Use the windows PostMessage function to post the messages I listed above. There is a GetDesktopWindow function that will give you the handle of the desktop window. From there you can enumerate all the child windows.

I am pretty sure that the original Windows Programming book by Petzold had an example of doing stuff with all the windows on the desktop.

information is the illusion of knowledge

Share this post


Link to post
Share on other sites
You need keybd_event() and mouse_event() to simulate keyboard presses and mouse clicks respectively. Then you can use SetCursorPos() to move the cursor around the screen.

Hope this helps!

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
First off don''t use SetCursorPos that will change your cursor position (You may want that so your screen saver doesn''t go on) However just moving the cursor often doesn''t count to keep you connected on those surfer programs...

I''m assuming you want a browser running in the back ground just clicking on stuff right? Well I''d make a program which you would first allow it to get the Window handle of your browser, then use "SendMessage" to send windows messages to it. Now because it''s very hard fopr a program to pick something and click it with the mouse I''d probably use keyboard commands, it makes no difference to what the i-net servers recieve in terms of requests and activity.

So send it a tab or two, then and enter, wait for it to load, then do it again! On most pages if your targeting adds the adds are near the top of the page, so 1 to maybe 4 tabs will very often hit a banner add.

Then you could of course use the API call "SetCursrPos" to avoid screen saver popping up or you could disable the screensaver all together, the reason you don''t want the screen saver is that on many newer computer, your motherboard will have MANY power modes, not just on and off. Some will reduce the CPU speed by 1/32 while sleeping and 1/16 while idling... this means everything slows down, but your CPU doesn''t heat up at all. Actually you probably could run at 1/16, but I don''t know how that''d impact the browser....

Any have fun!
Basic re-cap, look up "SendMessage", "SetCursorPos", "GetCursorPos", "FindWindow" and there might be a few more suggestions... there is a way of finding the handle of the window the mouse is over too... but I don''t remember right now...

See ya,
Ben

Share this post


Link to post
Share on other sites
quote:

there is a way of finding the handle of the window the mouse is over too... but I don''t remember right now...



WindowFromPoint() is what you''re looking for here.

You basically use GetCursorPos() and then do a WindowFromPoint() and you got the handle of the window(control) under your mouse cursor.

Hope this helps!

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
Thanks for all the replies guys... I''m going to make a little prog, not related to games, but that will be very useful. For now I''m using VB (Ôôô pain of the API calls... It''s hell when you have to pass pointers...)
As soon as finished, I''ll put it here.

BTW, what''s the ChildWindowFromPoint? It seems to work weirdo, and I''m using it WITH WindowFromPoint.

Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!