Chimerians Posted July 22, 2019 Posted July 22, 2019 Hi everyone, Hope this is the right sections. Im trying to write a code that does the following: Checks if a mark1 is on the screen then clicks on it, once mark1 is on the center of the screen, the script will click on mark2 and so on. I managed to make this work, althought I want to add a check: If after x seconds mark1 wasnt reached, then click again on mark1 until mark1 is on center of the screen. The Red Cross is always in the center of the screen. A mark is considered to be reached, when the redcross is not visible anymore. Can someone help me with this? Thanks alot! #include <ImageSearch2015.au3> $x1=0 $y1=0 $x2=0 $y2=0 $mark1 = "C:\Users\jm\OneDrive\Área de Trabalho\markers\ImageSearch2015\mark1.png" $mark2 = "C:\Users\jm\OneDrive\Área de Trabalho\markers\ImageSearch2015\mark2.png" $center = PixelGetColor (1805, 83) While 1 $resultmark1 = _ImageSearch($mark1,1,$x1,$y1,0,0) If $resultmark1=1 and ($center = "0xFFFFFF") Then MouseClick('left',$x1,$y1,50) Sleep(3000) $resultmark2 = _ImageSearch($mark2,1,$x2,$y2,0,0) If $resultmark2=1 and ($center = "0xFFFFFF") Then MouseClick('left',$x2,$y2,50) Sleep(3000) EndIf EndIf Wend
Nine Posted July 22, 2019 Posted July 22, 2019 (edited) Make a simple loop do...until. Use sleep () to wait for the x seconds. You should use imagesearch 2018... Edited July 22, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Moderators JLogan3o13 Posted July 22, 2019 Moderators Posted July 22, 2019 @Chimerians this looks an awful lot like a game automation script. I am locking until you convince me otherwise via PM. In the meantime, please review our Forum Rules: And realize, the "yes it's for a game, but I should be able to ask it because...." and "this is just an example for learning..." tired excuses won't get you very far "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts