Jump to content

Pixel search autoclick


Recommended Posts

I am writing a script to click a button when it changes to a specific color.

$pixel = PixelSearch(0,0,714,432,0xFFFF00)
If IsArray($pixel) = True Then
    MouseClick ("primary", 714, 432, 1, 0)
EndIf

It works with this: https://www.mathsisfun.com/games/reaction-time.html

The problem is I need it to continuously scan the screen and click everytime the color changes i.e. to run forever.

What do I need to add to the script?

 

Link to comment
Share on other sites

  • Developers

Well, it is pretty common that new members asking questions about PixelSearch in general have no real purpose for their question but in general are looking to automate a game. So please ensure you familiarize yourself with our forum rules before continuing asking questions.  

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you for your input.

Did you look at the link? I said game for lack of a better word. If you actually open the webpage you can see it's actually a reaction time test thing... 

I fail to see why anyone would ever want to automate that...

Anyway, could anyone tell me if how to loop my script?

Link to comment
Share on other sites

  • Developers
Just now, vierwald said:

Did you look at the link? I said game for lack of a better word. If you actually open the webpage you can see it's actually a reaction time test thing... 

Yes ... and as you noticed: The thread is still open which is an indication. ;)

1 minute ago, vierwald said:

I fail to see why anyone would ever want to automate that...

Well... I can assure you many do not agree with you!

2 minutes ago, vierwald said:

Anyway, could anyone tell me if how to loop my script?

Thought I did give you a hint earlier, so did you open the helpfile and looked for it?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 4 weeks later...
  • Moderators

genord92,

Welcome to the AutoIt forums.

But what makes you think that posting a link to a Visual Basic tutorial will be helpful to someone who is programming in AutoIt?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you really interested in code, you must learn to research and try&error codes.

If you want to scan the screen all the time, you must use a loop. If you do not know how, just google "while loop autoit" --> https://www.autoitscript.com/autoit3/docs/keywords/While.htm

so...

$color = ;put your color here
while (true)
sleep(10)
    $colorPos = PixelSearch(0, 0, 714, 432, $color)
    If Not @error Then
        MouseClick("left",$colorPos[0],$colorPos[1])
    EndIf
WEnd

i did not tested the code, but it should be correct, however, if its not you can fix it.

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...