Casper2400 Posted August 6, 2009 Posted August 6, 2009 Hello all, it has been a long time since I have visited these forums. I need some advice on how to solve this problem: I have a button that when pushed the pixel is either white or black IF the pixel in THAT location is White then click on that pixel If the pixel is black then check next pixel location If you clicked on first pixel location (meaning it was white) then pixel location 2 will either turn white or remain black confusing I know... What I want it to do is: click a start button, check the first pixel location if it is white, click it then check pixel location 2 if it is white click it and check pixel location 2 again (until location 2 is black) when location 2 is black click start button every 5 seconds until location 1 OR 2 turns white again... I have done up some code but it is not checking the pixel location until after the sleep time (code is set to 5 sec. for testing) expandcollapse popup; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;begin MouseClick("left", 600, 255, 1) While 1 $var1 = PixelGetColor( 515 , 390 ) $var2 = PixelGetColor( 515 , 480 ) If $var1 = 0xFFFFFF Then MouseClick("left", 515, 390, 1) ElseIf $var2 = 0xFFFFFF Then MouseClick("left", 515, 480, 1) Else MouseClick("left", 850, 225, 1) EndIf If $var2 = 0xFFFFFF Then MouseClick("left", 515, 480, 1) Else Sleep (60000) MouseClick("left", 850, 225, 1) EndIf WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc the above is my code, it works BUT it only checks each one time in the cycle, I want it to check $var1 if true click and re-check $var1 before checking $var2... check $var2 if true click and re-check $var1 and $var2 again , continue the loop until both $var are false then click the start button after 60 seconds to go through the cycle again. Hope this all makes sense. Thank you I have never killed a man, but I have read many obituaries with a smile.Arguing on the enternet is like running in the special olympics. Even if you win your still retarded.If I like it I will use it, if I dont it keeps me warm when I burn it.
Scriptonize Posted August 6, 2009 Posted August 6, 2009 (edited) When I follow you correctly you need to use nested loops. Click@Pos0 While 1 Get X value Get Y value If X <> value1 Then While x <> value1 Click@Pos1 Get X value again Wend While y <> value2 Click@Pos2 Get Y value again Wend Else Click@Pos3 EndIF Wend Maybe this helps. Edited August 6, 2009 by Scriptonize If you learn from It, it's not a mistake
Casper2400 Posted August 6, 2009 Author Posted August 6, 2009 (edited) When I follow you correctly you need to use nested loops. Click@Pos0 While 1 Get X value Get Y value If X <> value1 Then While x <> value1 Click@Pos1 Get X value again Wend While y <> value2 Click@Pos2 Get Y value again Wend Else Click@Pos3 EndIF Wend Maybe this helps. From what you gave me got me on the right track MouseClick("left", 600, 255, 1) While 1 $var1 = PixelGetColor( 515 , 390 ) $var2 = PixelGetColor( 515 , 480 ) If $var1 = 0xffffff Then While $var1 = 0xffffff MouseClick("left", 515, 390, 1) Sleep (2000) $var1 = PixelGetColor( 515 , 390 ) Wend ElseIf $var2 = 0xffffff Then While $var2 = 0xffffff MouseClick("left", 515, 480, 1) Sleep (2000) $var2 = PixelGetColor( 515 , 480 ) Wend Else MouseClick("left", 850, 225, 1) EndIF MouseClick("left", 850, 225, 1) Sleep (5000) Wend This works as far as I can tell Edited August 6, 2009 by Casper2400 I have never killed a man, but I have read many obituaries with a smile.Arguing on the enternet is like running in the special olympics. Even if you win your still retarded.If I like it I will use it, if I dont it keeps me warm when I burn it.
Scriptonize Posted August 6, 2009 Posted August 6, 2009 Glad I could help. >_ If you learn from It, it's not a mistake
Casper2400 Posted August 7, 2009 Author Posted August 7, 2009 Ok back on this issue now. The code above works BUT only in my 1024 by 768 windows XP Firefox browser system. I am doing this for a friend and the pixel location is off a hair or 2, so I want to change the code to search an area of space for ANY color other than black... if it finds a color NOT black click on it and continue search.. is this possible? the thing is the page is black, when something happens a button appears when you click on that button IF more is needed the button appears again but this time in a lower location (a 3rd, 4th, or continuing will always be in the same location as the 2nd) and remain there until 1 it is no longer needed in which case go back to the beginning of code and continue the loop, or 2 click the button again. because of different screen resolutions and operating systems and god forbid everyone use the same web browser >_< I need a way to seek a square area that will be covered by all of these issues. thank you and I hope its not too confusing I have never killed a man, but I have read many obituaries with a smile.Arguing on the enternet is like running in the special olympics. Even if you win your still retarded.If I like it I will use it, if I dont it keeps me warm when I burn it.
WannaLearnPls Posted August 7, 2009 Posted August 7, 2009 well, there is a function to read pixels and to see what color are they, and to notice if they changed or not.. so yah, it should be doable >_< however i have yet to find out how do those functions work, as im new to AutoIt anyhow, here ya go Q19.How can I use Pixel functions ? A1.PixelCheckSum $PixelCheck=PixelChecksum(40,50,70,60) ;Check if a region of pixel has changed While 1 ;Always Check for Pixel If IsArray($PixelCheck)=1 Then ;If Pixel Region has changed (color) Then Msgbox(48,"PixelChecksum","Pixel region has changed !") EndIf WEnd taken from a great FAQ in here
Casper2400 Posted August 8, 2009 Author Posted August 8, 2009 well, there is a function to read pixels and to see what color are they, and to notice if they changed or not.. so yah, it should be doable >_< however i have yet to find out how do those functions work, as im new to AutoIt anyhow, here ya go Q19.How can I use Pixel functions ? A1.PixelCheckSum $PixelCheck=PixelChecksum(40,50,70,60) ;Check if a region of pixel has changed While 1 ;Always Check for Pixel If IsArray($PixelCheck)=1 Then ;If Pixel Region has changed (color) Then Msgbox(48,"PixelChecksum","Pixel region has changed !") EndIf WEnd taken from a great FAQ in here Yes that part I got and understand, however I want it to tell me WHICH pixel changed (it needs to click on that pixel) More importantly I need it to check for not only changed but is NO LONGER black. This part of the code must be very specific. the page will change 3 times in the course of this action and if it is black then page has returned to normal state, if any area of the checksum is NOT black then continue clicking button #2. I have never killed a man, but I have read many obituaries with a smile.Arguing on the enternet is like running in the special olympics. Even if you win your still retarded.If I like it I will use it, if I dont it keeps me warm when I burn it.
WannaLearnPls Posted August 8, 2009 Posted August 8, 2009 (edited) Well... You could use this function then $CurrentColor = PixelGetColor ( x , y ) You would need to compare $CurrentColor to the black colour you want to compare with (you need to know the exact "tone" of black. You can use the AutoIt Window Info for that). If they match, it means that pixel is now black, else, it is not.. For that you would need to know the pixel coords beforehand of course.. >_< In case you don't know the coords, you should make up a way to check specific places, unless there's already a function for that which I don't know of, which is possible considering I'm rather new to AutoIt I have not tried those pixel thingy stuff, but thats the way I'd do it if I were to Edited August 8, 2009 by WannaLearnPls
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