Borges Posted June 26, 2019 Share Posted June 26, 2019 (edited) Hello guys, can someone help-me with a simple code? I want to check a pixel with color green and then click 1x After I click, will apper a red pixel, then I want to check the green pixel again just when the red pixel disappear... all this in loop how can I do that? HotKeySet("{PAUSE}", "Terminate") Func checkForPixel() Local $test = 0 PixelSearch(1018, 441, 1018, 441, 0x7A9D76) ; green pixel If Not @error And $test = 0 Then MouseClick("left", 1031, 444) Sleep(500) PixelSearch(1076, 439, 1076, 439, 0xFF0000) ; red pixel appear If Not @error Then Local $test = 1 EndIf PixelSearch(1076, 439, 1076, 439, 0xAE764B) ; red pixel disappear If Not @error Then $test = 0 EndIf EndIf EndFunc ;==>checkForPixel While 1 checkForPixel() WEnd Func Terminate() Exit EndFunc ;==>Terminate Edited June 26, 2019 by Jos Tidied the code of readability Link to comment Share on other sites More sharing options...
Sidley Posted June 26, 2019 Share Posted June 26, 2019 Looks like you can remove the last PixelSearch altogether, the function will end, be called again, reset the $test variable and search again for the green pixel. Link to comment Share on other sites More sharing options...
Bert Posted June 26, 2019 Share Posted June 26, 2019 What are you trying to automate? Pixel searching is the worst way to automate. Hooking into the control is much better. We may have what you need ready to go. No point re-inventing the wheel. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Borges Posted June 27, 2019 Author Share Posted June 27, 2019 (edited) 15 hours ago, Sidley said: Looks like you can remove the last PixelSearch altogether, the function will end, be called again, reset the $test variable and search again for the green pixel. After some tests, my script it's working the way I wanted it. HotKeySet("{PAUSE}", "Terminate") local $test = 0 Func checkForPixel() WinWaitActive("NoxPlayer") PixelSearch ( 1018, 441, 1018, 441, 0x7A9D76) ; green pixel If Not @error and $test = 0 Then MouseClick("left",1031,444) $test = 1 Sleep(50) EndIf PixelSearch ( 1076, 439, 1076, 439, 0xFF0000) ; red pixel appear if Not @error Then Sleep(50) Else $test = 0 EndIf EndFunc while 1 checkForPixel() WEnd Func Terminate() Exit EndFunc 13 hours ago, Bert said: What are you trying to automate? Pixel searching is the worst way to automate. Hooking into the control is much better. We may have what you need ready to go. No point re-inventing the wheel. how can I do that, with this "control"? how it works? Thanks for feedback Edited June 27, 2019 by Borges 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