vierwald Posted May 13, 2017 Posted May 13, 2017 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?
Developers Jos Posted May 13, 2017 Developers Posted May 13, 2017 Something like a loop like While..Wend? What are you trying to automate? 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.
vierwald Posted May 13, 2017 Author Posted May 13, 2017 I am a complete beginner so I have no clue how to implement a loop... I am not trying automate anything. I am just trying to learn how to do this in case I need to use it in the future. Right now I'm just using this game as an example: https://www.mathsisfun.com/games/reaction-time.html
Developers Jos Posted May 13, 2017 Developers Posted May 13, 2017 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.
vierwald Posted May 13, 2017 Author Posted May 13, 2017 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?
Developers Jos Posted May 13, 2017 Developers Posted May 13, 2017 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.
genord92 Posted June 6, 2017 Posted June 6, 2017 How about this one? Its in pdf, so u will be able to read it without any problems.
Moderators Melba23 Posted June 6, 2017 Moderators Posted June 6, 2017 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
huweto Posted June 13, 2017 Posted June 13, 2017 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now