exoticsquids Posted December 7, 2017 Share Posted December 7, 2017 Hello AutoIt Community! This is my very first post!! I have been using Auto if for small things like moving mouse and clicking things. I am not a compete newbie with programming but I am getting into a little more advance stuff now and was wondering if/what is the best solution. I am wanting to make a small bot that basically Clicks on image1.png to start the program. Almost all the time there is a advertisement so I am going to snip every x button (image2 through however many there are) and want the bot to search for which x comes up first then once clicked it goes back to the app/image1 to where it repeats itself. So I am looking for a loop inside of a loop! Can you do things like that? or would it be best to maybe do if statement then else and if its not there just move to the next if till one fits the box? p.s. I am about to head to work so might be a few hours before I respond back to the post. Thanks for the help in advance! ExoticSquids What I have: #include <ImageSearch2015.au3> HotKeySet("1", ForceExit) $x1=0 $y1=0 Func Loop() While 1 WinActivate("MyprogramHere") $image1 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image1.png" $result = _ImageSearch($image1, 1, $x1, $y1, 0, 0) If $result=1 Then Mouseclick("left",$x1,$y1,1,10) EndIf WEnd EndFunc What I was thinking: #include <ImageSearch2015.au3> HotKeySet("1", ForceExit) $x1=0 $y1=0 $x2=0 $y2=0 Func Loop() While 1 ;---Image1 is the app--- $image1 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image1.png" $result = _ImageSearch($image1, 1, $x1, $y1, 0, 0) If $result=1 Then Mouseclick("left",$x1,$y1,1,10) Else ;---Image2 is the x button (Close button on advertisement)----- $image2 = "C:\Users\gunth_000\Desktop\Scripts\pictures\image2.png" $result2 = _ImageSearch($image2, 1, $x2, $y2, 0, 0) $result2=1 Then MouseClick("left",$x1,$y1,1,10) Else..... ;-----so on from here------ EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
exoticsquids Posted December 7, 2017 Author Share Posted December 7, 2017 I don't know if there is a edit button but the mouseclick in the idea porgramming the last one those $x1, $y1 is meant to be 2 not 1. Link to comment Share on other sites More sharing options...
water Posted December 8, 2017 Share Posted December 8, 2017 Welcome to AutoIt and the forum! Which program do you try to automate? Most of the time there are more reliable ways to do what you want to do without using picturesearch. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
exoticsquids Posted December 8, 2017 Author Share Posted December 8, 2017 Well I am using NoxPlayer. I am going to be clicking basically the play button (image1) the video/ad will pop up and I need to turn the ad off so that is why I am just snipping all the x buttons (image2-whatever). I have ran it with send("{ESC}") it works on almost all of them I run into some that I can't just click esc to get out. The other thing I am running into that way is timing, because of loading time its very small but builds up over time. The Esc would work with a little extra work for tweaking but I think I would still need a if statements for the ones that don't work with esc being pressed. Link to comment Share on other sites More sharing options...
exoticsquids Posted December 8, 2017 Author Share Posted December 8, 2017 The app just lets you watch ad's the whole time. I am setting it up to run automatically basically. if that makes more sense xD I re-read the top. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2017 Developers Share Posted December 8, 2017 3 hours ago, exoticsquids said: The app just lets you watch ad's the whole time Sounds like fun... (not really) Just wondering why one would want this? 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 More sharing options...
RTFC Posted December 8, 2017 Share Posted December 8, 2017 2 minutes ago, Jos said: Just wondering why one would want this? Because people get paid for it. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2017 Developers Share Posted December 8, 2017 14 minutes ago, RTFC said: Because people get paid for it. I know but guess I wanted the OP to state that. 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 More sharing options...
RTFC Posted December 8, 2017 Share Posted December 8, 2017 Apologies. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2017 Developers Share Posted December 8, 2017 No worries ... just wanted to let you know I might be old but still have the brains going at a proper speed. (I am sure some particular individual will chime in now soon) 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 More sharing options...
exoticsquids Posted December 9, 2017 Author Share Posted December 9, 2017 Never mind I figured it Thanks overall though. I am just doing Switch case statements. Thanks anyways. I learn very quick when it comes to programming. CLOSED Figured it out Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2017 Developers Share Posted December 9, 2017 1 hour ago, exoticsquids said: Never mind I figured it Thanks overall though. @exoticsquids, Actually I do mind and would like to hear what you are doing with this script... guess the post kinda explained why. 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 More sharing options...
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