Jump to content

Recommended Posts

Posted (edited)

It is supposed to run through the loop every .8 seconds and check to ensure it can find a pixel at that location. If it can, it changes the box to green, if it can't it changes to red.

However, currently, it seems to run the check once and it sets the color. It's definitly looping that command, so I don't really get what the problem could be..

#include <GUIConstants.au3>

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

Dim $i = PixelSearch(700, 700, 700, 700, 0x000080, 10) ;checks that pixel to make sure it is within 10 shades of a dark blue

$GUI = GUICreate("", 5,5,0,0,$WS_POPUP,$WS_EX_TOOLWINDOW)
GUISetBkColor(0x00FF00)

GUISetState()
WinSetOnTop($GUI,"",1)

AdlibEnable("SwitchColor",800)

While 1
    If GUIGetMsg() = -3 Then
        ExitLoop
    EndIf
WEnd

Func SwitchColor()
    If IsArray($i) Then  ;if the pixel is found within 10 shades of blue, change the gui to green, else change to red
        GUISetBkColor(0x00FF00)
    Else
        GUISetBkColor(0xFF0000)
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by shea851
Posted

maybe...

#include <GUIConstants.au3>

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

Dim $i = PixelSearch(700, 700, 700, 700, 0x000080, 10);checks that pixel to make sure it is within 10 shades of a dark blue

$GUI = GUICreate("", 5,5,0,0,$WS_POPUP,$WS_EX_TOOLWINDOW)
GUISetBkColor(0x00FF00)

GUISetState()
WinSetOnTop($GUI,"",1)

AdlibEnable("SwitchColor",800)

While 1
    If GUIGetMsg() = -3 Then
        ExitLoop
    EndIf
    Sleep(10)
WEnd

Func SwitchColor()
    $i = PixelSearch(700, 700, 700, 700, 0x000080, 10);checks that pixel to make sure it is within 10 shades of a dark blue
    If IsArray($i) Then;if the pixel is found within 10 shades of blue, change the gui to green, else change to red
        GUISetBkColor(0x00FF00, $GUI)
    Else
        GUISetBkColor(0xFF0000, $GUI)
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

8)

NEWHeader1.png

Posted

Ah ha! Of course... it was set to only check the color once at the beginning, rather than everytime it was looping. Thanks so much!!

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
×
×
  • Create New...