Bamse Posted January 13, 2018 Share Posted January 13, 2018 (edited) I am trying to create a script that will wait until a pixel is found. After the pixel is found then it will start moving the mouse. And also why is my script exiting when i use #RequireAdmin? My code #RequireAdmin AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("PixelCoordMode", 0) HotKeySet("t" ,"set") Global $pix = PixelSearch(235,209,287,260,0xA53A3A,10) Func set() Do $pix = PixelSearch(235,209,287,260,0xA53A3A,10) Until @error MouseClick('primary', $pix[0], $pix[1] EndFunc While 1 Sleep(300) WEnd Edited January 13, 2018 by Bamse Missing code Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 46 minutes ago, Bamse said: I am trying to create a script that will wait until a pixel is found. After the pixel is found then it will start moving the mouse. ... but you are doing the PixelSearch() only one time at the start of the script so there seems to be a logic issue. 47 minutes ago, Bamse said: And also why is my script exiting when i use #RequireAdmin? How did you determine this? or are you talking about that SciTE tells you it ended but it is still running? 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...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 (edited) 19 minutes ago, Jos said: How did you determine this? or are you talking about that SciTE tells you it ended but it is still running? Jos The program keeps running but i can’t get any outputs from ConsoleWrite etc... 19 minutes ago, Jos said: ... but you are doing the PixelSearch() only one time at the start of the script so there seems to be a logic issue. But shouldn't it do the MouseClick when thel Do loop have found the pixel? Pix is a global Variable. Edited January 13, 2018 by Bamse Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 Just now, Bamse said: he program keeps running but i can’t get any outputs from ConsoleWrite etc... That will only work when you run SciTE as Administrator since an lower level process can't read the STDOUT of an elevated level process. 1 minute ago, Bamse said: But shouldn't it do the MouseClick when thel Do loop have found the pixel? Why? Are you starting func Set() somewhere in your script? 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...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 3 minutes ago, Jos said: Why? Are you starting func Set() somewhere in your script? I am using HotKeySet("t" ,"set") for starting the function. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 Ok. So lets look at your loop checking for the pixel. You are looping until @error right? When will PixelSearch() return an @error of 1 and exit this loop? 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...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 1 minute ago, Jos said: You are looping until @error right? When will PixelSearch() return an @error of 1 and exit this loop? I have been reading the help file that Autoit comes with and the failure will return one when the color is not found. Is the loop exiting when it returning one? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 2 minutes ago, Bamse said: Is the loop exiting when it returning one? Yes, the loop is ending when @error is not equal to 0. Bamse 1 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...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 (edited) 18 minutes ago, Jos said: Yes, the loop is ending when @error is not equal to 0. Then the loop is ending when it has found the pixel, right? Func set() Run("D:\Program Files\SWT\server.exe") WinWait("server1") WinActivate("server1") WinMove("server1", "", 0, 0, 848, 704) Global $pix = PixelSearch(235,209,287,260,0xA53A3A,10) Do $pix = PixelSearch(235,209,287,260,0xA53A3A,10) Until @error MouseClick('primary', $pix[0], $pix[1] EndFunc It looks like the program is exiting when it has found the color. Edited January 13, 2018 by Bamse Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 (edited) 5 hours ago, Bamse said: Then the loop is ending when it has found the pixel, right? Come on ... think, it isn't that hard!! Of course the reverse of what you want is happening. PixelSearch() sets @error to 1 when it is unsuccessful and your loop ends. Jos Edited January 13, 2018 by Jos Bamse 1 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...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 (edited) 4 hours ago, Jos said: Come on ... think, it isn't that hard!! Of course the reverse of what you want is happening. PixelSearch() sets @error to 1 when it is unsuccessful and your loop ends. Jos That hit me when i was working out, but i need to figure out some code that will work! Will be back with my code if i can’t solve it! Thanks again @JosThis is really hard(Banging my head against the keyboard) but fun at the same time. Edited January 13, 2018 by Jos Link to comment Share on other sites More sharing options...
Bamse Posted January 13, 2018 Author Share Posted January 13, 2018 @Jos Could you give me a hint what i need todo to getting it working? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2018 Developers Share Posted January 13, 2018 Hints has been given, actually the answer was given, and you really need to be able to figure that one out by yourself. 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...
Bert Posted January 14, 2018 Share Posted January 14, 2018 may I ask what you are trying to automate? Most likely hooking directly into controls and looking for changes would be much more stable. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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