Sign in to follow this  
Followers 0
Lahtin3n

Finding and make mouse follow moving pixels?

6 posts in this topic

Right, so I'm pretty new with AutoIt and I've been fooling around for a bit trying different things.

I am currently trying to make the mouse follow a specific object on the screen, a ball to be more precise. I figured that I could use PixelSearch to define the coords and MouseMove to get the pointer to go there.

The only problem is that the ball shifts in color, making it rather hard for me to figure out how to solve it.

This is the basic script I tried using at first, and it had a rather low successrate as it many of the times could not find the correct color in time.

While 1
$coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x14007F, 10)
If Not @error Then
MouseMove ($coord[0], $coord[1], 1)
EndIf
WEnd

The background is static, and the only thing moving is the ball. Would it be possible to define a section on the screen, and use some sort of function to check for changes of pixels in that section?

What function(s) should I be looking into?

Share this post


Link to post
Share on other sites



If you know the pixel color, and the window area, it's very easy to do a PixelSearch to find the first instance of that color, and returned is the x/y to use in the mousemove.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

As you are just fooling/playing around with AutoIt I would suggest to look for a real life problem and try to solve it.

Threads where Pixelsearch is discussed/needed to solved a problem get locked very often.

I assume you have read the forum rules and know that game automation isn't supported here?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you know the pixel color, and the window area, it's very easy to do a PixelSearch to find the first instance of that color, and returned is the x/y to use in the mousemove.

Well, I know. But as I said - the balls color is not constant ;)

As you are just fooling/playing around with AutoIt I would suggest to look for a real life problem and try to solve it.

Threads where Pixelsearch is discussed/needed to solved a problem get locked very often.

I assume you have read the forum rules and know that game automation isn't supported here?

This is not for a game, this is for following an object in my browser with the mouse.

It looks quite a bit like this, http://www.ericj.se/ (but instead of dragging the site with ur mouse, you move it with the arrows) and I wan't the mouse to follow an object like the lens flare in this example, except the color is not constant.

Why do I want to do this? Well - because I want to learn how to do it, if it's even possible.

I am not discussing PixelSearch, as I already stated that I won't be using that. I am merely asking for advice of what functions to read more about, as there are plenty of them in the documentation.

Also, what's wrong with fooling around with AutoIt? I tend to do that when I am about to learn things, learning by doing you know.

Don't be so quick at juding others please, as everything is not everytime what it might look like.

Edited by Lahtin3n

Share this post


Link to post
Share on other sites

same difference, as long as the color is consistantly changing between known value(s), and those values are not found on the rest of the area, you can find it consistantly.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

same difference, as long as the color is consistantly changing between known value(s), and those values are not found on the rest of the area, you can find it consistantly.

Oh thanks, I got all stuck in my thinking. After reading this I figure I could be using an 'if-else' statement! Cheers. Edited by Lahtin3n

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0