Jump to content

Finding and make mouse follow moving pixels?


Recommended Posts

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?

Link to comment
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.
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

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
Link to comment
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.
Link to comment
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.

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...