Jump to content

Loops 'n WEnds


Recommended Posts

Ok, the problem is in Line 46, because the error states the WEnd shouldn't be there somehow.

What I want is, to loop from the first While to the last, but IF PixelGetColor is any other then the displayed Hex, then ti needs to re-do that loop over and over untill it's back into the origoinal color.

Little help anyone?

Script:

WinWaitActive($Window)

    While WinExists($Window)
        
        While WinActive($Window)
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            Send("{SPACE}")
            Sleep(12000)
            Send("{SPACE}")
            Sleep(4000)
            Send("{SPACE}")
            Sleep(3000)
            Send("{SPACE}")
            Sleep(3000)
    
            While 1 
                If PixelGetColor(117,45) <> 0xE25A54 Then
                    Send("{2}")
                    Sleep(100)
                Else ExitLoop
            WEnd
   
            
        WEnd
        
        Sleep(200)
        
    WEnd
Link to comment
Share on other sites

WinWaitActive($Window)

    While WinExists($Window)
       
        While WinActive($Window)
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            Send("{SPACE}")
            Sleep(12000)
            Send("{SPACE}")
            Sleep(4000)
            Send("{SPACE}")
            Sleep(3000)
            Send("{SPACE}")
            Sleep(3000)
   
            While 1 
                If PixelGetColor(117,45) <> 0xE25A54 Then
                    Send("{2}")
                    Sleep(100)
                Else 
                    ExitLoop
                endif
            WEnd
   
           
        WEnd
       
        Sleep(200)
       
    WEnd

try

Link to comment
Share on other sites

Somehow it didn't work perfectly, so changed it to this:

while 1
        If PixelGetColor(117,45) <> 0xE25A54 Then
            Send("2")
            Sleep(2000)
        Else 
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            Send("{SPACE}")
            Sleep(10000)
            Send("{SPACE}")
            Sleep(3500)
            Send("{SPACE}")
            Sleep(2500)
            Send("{SPACE}")
            Sleep(2500)
        EndIf
    WEnd

Can't test it just yet, but this SHOULD work right? I mean press 2 when the color is different, and if not do the long loop...

Link to comment
Share on other sites

Yes if the color is not (the color you have choosen) then it sends 2 and wait 2 seconds.. and it will do that until the color is the one you specified... then it will take the long loop (and do that until it changes again) etc etc etc :shocked:

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

Somehow it didn't work perfectly, so changed it to this:

while 1
        If PixelGetColor(117,45) <> 0xE25A54 Then
            Send("2")
            Sleep(2000)
        Else 
            Sleep(100)
            Send("{TAB}")
            Sleep(100)
            Send("{SPACE}")
            Sleep(10000)
            Send("{SPACE}")
            Sleep(3500)
            Send("{SPACE}")
            Sleep(2500)
            Send("{SPACE}")
            Sleep(2500)
        EndIf
    WEndoÝ÷ Ø&§ßÛmzËb¶;¬·'­nëm+å
+¸ Ò&y©é­ë,Û^Ø^rh®+÷Þ­éíjwb~z-vazZ'Z(§ú®¢×rÛ§¢'hmmébz÷­«pYp¢¹jËmgrçO¥ëB¢Z+­ën­çmæÃ"¿Û½©nzíç(Úܨ¹ªÞr©j¸§+m w±¶¼­+ºÚ"µÍÚ[HBBRY^[Ù]ÛÛÜLMË

JH  ÉÝÈXÊLPMM
H[Õ]ÚÝ[ÛÜÂBBTÙ[
    ][ÝÌ][ÝÊBBBTÛY

BBQ[ÙHBBTÛY
L
BBBTÙ[
    ][ÝÞÕPI][ÝÊBBBTÛY
L
BBBTÙ[
    ][ÝÞÔÔPÑ_I][ÝÊBBBTÛY
L
BBBTÙ[
    ][ÝÞÔÔPÑ_I][ÝÊBBBTÛY
ÍL
BBBTÙ[
    ][ÝÞÔÔPÑ_I][ÝÊBBBTÛY
L
BBBTÙ[
    ][ÝÞÔÔPÑ_I][ÝÊBBBTÛY
L
BBQ[YUÑ[
Link to comment
Share on other sites

Actually, no i don't believe that will work.

Last time I checked, PixelGetColor retured the DECIMAL value of the color. and you are comparing it to Hex

You don't actually have to worry about that in this situation. Number formatting is significant when humans are typing, reading, or printing numbers, not in programs comparing them. Demo:

$Hex = 0x10
$Dec = 16

If $Dec = 0x10 And $Hex = 16 Then
    MsgBox(64, "Match", "Match")
Else
    MsgBox(16, "No Match", "No Match")
EndIf
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Just in case Psalty's post was a bit vague, I just wanted to specifically and conspicuously point out that when you prefix a number with 0x and it's not inside a string, it evaluates that number as a decimal number.

So in Psalty's example above, both $Hex and $Dec are equal to eachother. 0x10 = 16, just like 0xF = 15, 0xFF = 255, etc.

Just try: MsgBox(0, 'Hex', 0xBEEFED); And you should get 12513261.

Remember not to wrap in quotes though. Cus MsgBox(0, 'Hex', '0xBEEFED') will just print 0xBEEFED.

Dec(0xE25A54) is functionally equivalent to Dec(14834260) (Which is obviously redundant :shocked:)

Link to comment
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
 Share

  • Recently Browsing   0 members

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