Sign in to follow this  
Followers 0
Nethel

Check A Pixel's Color

9 posts in this topic

Looked through the help file, it just says that the color commands return the RGB value, I'm sure I'm just missing something as to how to implement this to check the pixel color. If the color is right, I would like the script to proceed, but if its wrong I need to have a 1 second delay to allow it to load. Any suggestions?

Share this post


Link to post
Share on other sites



I would also like to know if I can run a loop for a set amount of seconds, and then switch to another infinate loop.

PS, here is the code I am using, feel free to do anything with it, its just my newbie attempt at a macro.

sleep (1500)

HotKeySet("{ESC}", "Terminate")

While 1

send ("{F2}")
sleep (1200)
send ("{F5}")
sleep (1700)


mouseClick ("left", 635, 345, 1)
mouseClick ("left", 635, 345, 1)

mouseClick ("left", 665, 345, 1)
mouseClick ("left", 665, 345, 1)

send ("{F1}")

sleep (5000)

send ("{F3}")
sleep (1200)
send ("{F5}")
sleep (1700)

mouseClick ("left", 635, 345, 1)
mouseClick ("left", 635, 345, 1)

mouseClick ("left", 665, 345, 1)
mouseClick ("left", 665, 345, 1)

send ("{F1}")

sleep (5000)

send ("{F4}")
sleep (1200)
send ("{F5}")
sleep (1700)

mouseClick ("left", 635, 345, 1)
mouseClick ("left", 635, 345, 1)

mouseClick ("left", 665, 345, 1)
mouseClick ("left", 665, 345, 1)

send ("{F1}")

sleep (5000)
WEnd

Func Terminate()
   Exit
EndFunc

The two coordinates in there are the ones I would like to check, the color for the first is 495D4B and the second is 000000.

Thanks again

Share this post


Link to post
Share on other sites

I would also like to know if I can run a loop for a set amount of seconds, and then switch to another infinate loop.

$begin = TimerStart()
; first loop will loop for 5 seconds
Do
  ; First loop code 
    ...
Until TimerStop($begin) > 5000
;
While 1
  ;  Endless loop code
   ........
Wend

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks much, JdeB it worked perfectly.

Share this post


Link to post
Share on other sites

Try

If "495D4B" = Hex(PixelGetColor(635, 345),6) Then
 ; do stuff
EndIf

GrahamS

Share this post


Link to post
Share on other sites

Ok, if it doesnt find the pixel, I want it to pause for a second, where should I put that?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok, if it doesnt find the pixel, I want it to pause for a second, where should I put that?

If "495D4B" = Hex(PixelGetColor(635, 345),6) Then
; do stuff
Else
   sleep(1000)
EndIf
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

THe following code sleeps for a second at a time until the pixel contains the desired colour.

While "495D4B" <> Hex(PixelGetColor(635, 345),6)
  Sleep(1000)
EndIf

GrahamS

Share this post


Link to post
Share on other sites

Awesome, I'm off to go try it now :whistle:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0