Jump to content
Sign in to follow this  
ForsakenGod

Is there some way to stop loop ?

Recommended Posts

ForsakenGod

Well i am working in autoit second day so far and i ve tried everythink i know searched Google and didnt found anythink about this .I want to make the code to sleep after it has been done 2 times and untill the other color apears but when i do sleep() than the whole script does not look for color what i dont want i ve ;;showed the place where it should sleep with pixelsearch still active

#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.0.0
    Author:      Unreal
#ce ----------------------------------------------------------------------------

HotKeySet("{F3}", "StartProg") 
HotKeySet("{F4}", "ExitProg") 


While 1
Sleep(100) 
Wend

Func StartProg()
WinActivate("GBP/USD, 5-Minute, Bid")
FirstCheck()
    
EndFunc

Func FirstCheck()
    PixelSearch(1471 ,22 ,1479 ,514 ,0xFFFF00)
    If @error = 0 Then
        WinActivate("Bez názvu – Poznámkový blok")
        Send(" Najdena Zlta ")
        WinActivate("GBP/USD, 5-Minute, Bid")
        Sleep(6000)
        $myColor = PixelSearch(1471 ,22 ,1479 ,514 ,0xFFFF00)
        If @error = 0 Then
            MouseClick("left",102,55,1,0) ;; After this has been 2 times it shouldnt execute anymore till the second color appears
            WinActivate("Bez názvu – Poznámkový blok") ;; After this has been 2 times it shouldnt execute anymore till the second color appears
            Send(" Potvrdene ");; After this has been 2 times it shouldnt execute anymore till the second color appears
        EndIf
        
        while($myColor = 0xFFFF00)
            $myColor = PixelSearch(1471 ,22 ,1479 ,514 ,0xFFFF00)    
        WEnd
    Else
        SecondCheck()
EndFunc

Func SecondCheck()
    PixelSearch(1471 ,22 ,1479 ,514 ,0x8000FF)
    If @error = 0 Then
        WinActivate("Bez názvu – Poznámkový blok")
        Send(" Najdena Fialova ")
        WinActivate("GBP/USD, 5-Minute, Bid")
        Sleep(6000)
        $myColor2 = PixelSearch(1471 ,22 ,1479 ,514 ,0x8000FF)
        If @error = 0 Then
            MouseClick("left",23,59,1,0)
            WinActivate("Bez názvu – Poznámkový blok")
            Send(" Potvrdene ")
        EndIf
EndIf           
EndFunc


Func ExitProg()
Exit 0 
EndFunc

Is there some way to do "balance" ? so when i reach some time of count some part of function disables untill i dont want it to stop being disabled ? :)

Thank you

Edited by ForsakenGod

Share this post


Link to post
Share on other sites
ForsakenGod

While PixelSearch(parameters) = @error
    Sleep(1000) ;will look for your pixel every one second
WEnd

Thanks but actually as i sayd i need it to just do 1 operation 2 times after finding a color and till the color presists dont do anythink but really anythink just look for second color :)

Any ideas? ;)

Share this post


Link to post
Share on other sites
mikjay

If you just want the loop to end and do the second check after a period of time you could use Adlibenable(<time>) before the loop.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.