Jump to content

Recommended Posts

Posted

I am near to brain collaps....

Ok, here is what i try :

I have a Pixelsearch on a little part of the screen. This Pixels can be red or green.
As long as i detect red or green pixels in this area everything is OK.

But when nither red or green is found i want to execute a function.

This is what i tryed :
 

Global $iTellme = 1

While 1
    reader()
    Alert()
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd




Func reader()
    $ColVarread = GUICtrlRead($ColVar)
    $iSearchpoint = GUICtrlRead($Eper)
    $aEcoord = PixelSearch(465, $iSearchpoint, 468, $iSearchpoint + 1, 0xFF2020, 200)
        If IsArray($aEcoord) = True Then
        GUICtrlSetBkColor($List1, 0xFF2020)
        GUICtrlSetData($List1, "")
        GUICtrlSetData($List1, "Red")
        ConsoleWrite("Red found" & @CRLF)
        $iTellme = 0

        Else
    $aEcoord = PixelSearch(465, $iSearchpoint, 468, $iSearchpoint + 1, 0x20FF20, 200)
        If IsArray($aEcoord) = True Then
        GUICtrlSetBkColor($List1, 0x20FF20)
        GUICtrlSetData($List1, "")
        GUICtrlSetData($List1, "Green")
        ConsoleWrite("Green found" & @CRLF)
        $iTellme = 0

    EndIf

 EndIf
EndFunc


Func Alert()
    If $iTellme = 1 Then
    GUICtrlSetData($List1, "")
    GUICtrlSetData($List1, "ALARM")
    Send ("A")
    Sleep(1500)
    EndIf
    

EndFunc

So far my thoughts....
The $iTellme is set global to 1.
As long as i find red or green pixels in the area everything is fine and $iTellme will be set to 0 and the function Alert will do nothing.
But if no red or green pixels are found, $iTellme will stay 1 and  the Function Alert will do its job...

But o have no idea why all this is not working at all. Sometimes Alert is executed no matter what or, when i try something else, it is not executed at all....
Where is my error ?

Posted

Hi Jos, that was my attemp #102.....
I set the Var to 1 again right at the end of the Alarm-Func .... and then i had the weired problem that the routine got stuck at the reader function and the prog stopped working...

believe me... i tryed so many variants like Chase, Select etc....
Maybe my next try will be to do a function for every single Pixelsearch, set Vars and at the end look up the Vars and execute functions according.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...