UnknowName Posted December 17, 2011 Share Posted December 17, 2011 (edited) Hi, I need some help for my script. I'm a newbe and I don't know all of features AutoIt has. Here, I just want to send keystroke, when x pixel get x color code. I want the script checks, as fast as it can, the color of 6 pixel I have wrote, and react in function of these colors. It's very simple. But when I strat the script, OK the msgbox, and activating the window, nothing happen No error, the script is still running. If someone can help me, it would be appreciated. expandcollapse popupHotKeySet("{ESC}", "close") ; => Press ESC to stop the macro Func close() Exit EndFunc $count = 0 $max = 100001 ; => This is how many times the macro will loop $tempo1 = 500 $tempo2 = 1000 $tempo3 = 2500 MsgBox(0, "", "") Winwait("") While $count < $max ;Schedule If PixelGetColor(1179,555) = 858585 Then Send("{ENTER}") sleep($tempo1) EndIf ;Starting If PixelGetColor(297,768) = 050505 Then Send("{ENTER}") sleep($tempo3) EndIf ;Strating with space If PixelGetColor(297,768) <> 050505 Then Send("{SPACE}") sleep($tempo3) EndIf ;Ready1 If PixelGetColor(1040,830) = 181918 Then Send("{ENTER}") sleep($tempo1) EndIf ;Ready2 If PixelGetColor(1630,842) = 000000 Then Send("{ENTER}") sleep($tempo1) EndIf ;Ready3 If PixelGetColor(325,465) = 000000 Then Send("{ENTER}") sleep($tempo1) EndIf ;End If PixelGetColor(1080,50) = 000000 Then Send("!{TAB}") ; ALT+TAB sleep($tempo2) WinActivate("") Winwait("") Sleep($tempo1) Send("{ENTER}") EndIf WEnd Edited December 17, 2011 by UnknowName Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Share Posted December 17, 2011 Making numbers such as this 050505 to 0x050505 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UnknowName Posted December 17, 2011 Author Share Posted December 17, 2011 I tested, and it changes nothing. Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Share Posted December 17, 2011 Then my next guess would be that those colours are not at those x y. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Zedna Posted December 17, 2011 Share Posted December 17, 2011 (edited) Colors should be defined in 0xRRGGBB format Check desired color values by Au3Info. Edited December 17, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UnknowName Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) They are. If there are not any error in my script, whether it's the script don't check pixels at all, whether the scrpit can't check pixels on fullscreen application, in both cases, I doubt... I try Zedna, thanks. Edited December 17, 2011 by UnknowName Link to comment Share on other sites More sharing options...
Zedna Posted December 17, 2011 Share Posted December 17, 2011 In your script try this (for all pixels accordingly) ;~ If PixelGetColor(1179,555) = 858585 Then ConsoleWrite('1179,555 0x' & Hex(PixelGetColor(1179,555),6) & @CRLF) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UnknowName Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) It don't work properly, at all... But for the Ready3, it works good. It's the only one. Alt+tab are too previous (I mean, it alt+tab when the pixel isn't black O_O), and other check don't works at all... Myabe my coordiantes are not good, I used GIMP, for coordinates+colors. I have some troubles, does the script check ervytime, as fast as it can, the pixels I have wrote, and when he found one, does it do the function I have indicated ? I don't understand how it works with my script, line by line, or permanent refresh, searching pixels color ? There is my script, edited : expandcollapse popupHotKeySet("{ESC}", "close") ; => Press ESC to stop the macro Func close() Exit EndFunc $count = 0 $max = 100001 ; => This is how many times the macro will loop $tempo1 = 500 $tempo2 = 1000 $tempo3 = 2500 MsgBox(0, "", "") Winwait("") While $count < $max ;Schedule If PixelGetColor(1179,555) = 0x848484 Then ConsoleWrite('1179,555 0x' & Hex(PixelGetColor(1179,555),6) & @CRLF) Send("{ENTER}") sleep($tempo1) EndIf ;Starting If PixelGetColor(297,768) = 0x050505 Then ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF) Send("{ENTER}") sleep($tempo3) EndIf ;Strating with space If PixelGetColor(297,768) <> 0x050505 Then ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF) Send("{SPACE}") sleep($tempo3) EndIf ;Ready1 If PixelGetColor(1040,830) = 0x2A292A Then ConsoleWrite('1040,830 0x' & Hex(PixelGetColor(1040,830),6) & @CRLF) Send("{ENTER}") sleep($tempo1) EndIf ;Ready2 If PixelGetColor(1630,842) = 0x030403 Then ConsoleWrite('1630,842 0x' & Hex(PixelGetColor(1630,842),6) & @CRLF) Send("{ENTER}") sleep($tempo1) EndIf ;Ready3 If PixelGetColor(325,465) = 0x000000 Then ConsoleWrite('325,465 0x' & Hex(PixelGetColor(325,465),6) & @CRLF) Send("{ENTER}") sleep($tempo1) EndIf ;End If PixelGetColor(1080,50) = 0x000000 Then ConsoleWrite('1080,50 0x' & Hex(PixelGetColor(1080,50),6) & @CRLF) Send("!{TAB}") ; ALT+TAB sleep($tempo2) WinActivate("") Winwait("") Sleep($tempo1) Send("{ENTER}") EndIf WEnd Edited December 17, 2011 by UnknowName Link to comment Share on other sites More sharing options...
Zedna Posted December 17, 2011 Share Posted December 17, 2011 (edited) ConsoleWrite BEFORE PixelGetColor expandcollapse popupHotKeySet("{ESC}", "close") ; => Press ESC to stop the macro Func close() Exit EndFunc $count = 0 $max = 100001 ; => This is how many times the macro will loop $tempo1 = 500 $tempo2 = 1000 $tempo3 = 2500 MsgBox(0, "", "") Winwait("") While $count < $max ;Schedule ConsoleWrite('1179,555 0x' & Hex(PixelGetColor(1179,555),6) & @CRLF) If PixelGetColor(1179,555) = 0x848484 Then Send("{ENTER}") sleep($tempo1) EndIf ;Starting ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF) If PixelGetColor(297,768) = 0x050505 Then Send("{ENTER}") sleep($tempo3) EndIf ;Strating with space ConsoleWrite('297,768 0x' & Hex(PixelGetColor(297,768),6) & @CRLF) If PixelGetColor(297,768) <> 0x050505 Then Send("{SPACE}") sleep($tempo3) EndIf ;Ready1 ConsoleWrite('1040,830 0x' & Hex(PixelGetColor(1040,830),6) & @CRLF) If PixelGetColor(1040,830) = 0x2A292A Then Send("{ENTER}") sleep($tempo1) EndIf ;Ready2 ConsoleWrite('1630,842 0x' & Hex(PixelGetColor(1630,842),6) & @CRLF) If PixelGetColor(1630,842) = 0x030403 Then Send("{ENTER}") sleep($tempo1) EndIf ;Ready3 ConsoleWrite('325,465 0x' & Hex(PixelGetColor(325,465),6) & @CRLF) If PixelGetColor(325,465) = 0x000000 Then Send("{ENTER}") sleep($tempo1) EndIf ;End ConsoleWrite('1080,50 0x' & Hex(PixelGetColor(1080,50),6) & @CRLF) If PixelGetColor(1080,50) = 0x000000 Then Send("!{TAB}") ; ALT+TAB sleep($tempo2) WinActivate("") Winwait("") Sleep($tempo1) Send("{ENTER}") EndIf WEnd Edited December 17, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UnknowName Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) Works better...much better <3 Edit : At End, the script keep alttabbing, and don't process line by line, how can I fix it ? Can't I tell the script to send ALTTAB just one time ? Another question : How can I tell to the script to check the color of a rectangle, and if the rectangle is full of this color, => Then ..... Edited December 18, 2011 by UnknowName Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2011 Share Posted December 18, 2011 Somewhere inside your loop put $count += 1 This will increment and then exit when it reaches $max AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UnknowName Posted December 18, 2011 Author Share Posted December 18, 2011 (edited) Alttabbing still don't work properly. The script spam alttab I want : When 1800,145 is black, press alt tab, activate the window, and press enter. ;End ConsoleWrite('1800,145 0x' & Hex(PixelGetColor(1800,145),6) & @CRLF) If PixelGetColor(1800,145) = 0x000000 Then sleep($tempo3) Send("!{TAB}") WinActivate("") Winwait("") sleep($tempo2) Send("{ENTER}") EndIf It spams alttab and don't press enter at all, like that Edited December 18, 2011 by UnknowName Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2011 Share Posted December 18, 2011 Change WinWait() to WinWaitActive() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UnknowName Posted December 18, 2011 Author Share Posted December 18, 2011 (edited) Okay thanks. EDIT : How can I improve my script build ? It seems to be too slow, sometimes. I think it's slow because of this : ;End ConsoleWrite('1672,819 0x' & Hex(PixelGetColor(1672,819),6) & @CRLF) If PixelGetColor(1672,819) = 0x6b6d5a Then sleep($tempo3) Send("!{TAB}") WinActivate("") sleep($tempo1) EndIf tempo3 = 10 000 millisec :/ And it seems even if PixelGetColor(1672,819) <> 0x6b6d5a, tempo3 is activated... Edited December 18, 2011 by UnknowName 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