Sign in to follow this  
Followers 0
BluhBlah

While TimerDiff($iBegin) < $delay - Dont work

4 posts in this topic

This part of my code seems like it wont trigger or something, I tested and the pixelsearch works but hmm it wont send !Q ( im 100% it havent found the extloop part

If PixelGetColor(217, 591) = 0xCCB211 Then
            $iBegin = TimerInit()
            While TimerDiff($iBegin) < $delay
                If PixelGetColor(35, 149) = 0x737777 Then ExitLoop
            WEnd
            If PixelGetColor(217, 591) = 0xCCB211 Then Send ("!Q")
        EndIf
    Else
        Sleep(10)
    EndIf[/codebox]

Here's whole code

Dim $stop = 0

HotKeySet("{F4}", "toggle")
HotKeySet("{F5}", "off")

$password = IniRead(@ScriptDir & "\settings.ini", "Settings", "Password", "Notfound")
$delay = IniRead(@ScriptDir & "\settings.ini", "Settings", "Delay", 5000)

While 1
    If $stop = 1 Then
    ;********************************************************************************
    If PixelGetColor(217, 591) = 0xCCB211 Then
            $iBegin = TimerInit()
            While TimerDiff($iBegin) < $delay
                If PixelGetColor(35, 149) = 0x737777 Then ExitLoop
            WEnd
            If PixelGetColor(217, 591) = 0xCCB211 Then Send ("!Q")
        EndIf
    Else
        Sleep(10)
    EndIf
    ;********************************************************************************
    If PixelGetColor(167, 86) = 0xFFF052 Then ; Press B to enter bnet
        Send("B")
        Sleep(5000)
    EndIf
    ;********************************************************************************
    If PixelGetColor(359, 414) = 0x291C11 Then ; Type password to enter game
        Send($password)
        Send("{ENTER}")
        Sleep(10000)
    EndIf
    ;********************************************************************************
    If PixelGetColor(504, 375) = 0x000000 Then Send("{ENTER}") ; If wrong password screen come up it press enter
    If PixelGetColor(28, 157) = 0x5C594D Then Send("!Q") ; Sends search game if it is in ..channel
    If PixelGetColor(479, 114) = 0xFFFFFF Then Send("!Q") ;Leave if quitscreen come
    If PixelGetColor(109, 2) = 0x444244 Then Send("{ENTER}") ; If scorescreen comes
    ;********************************************************************************
    ;Undead
    If PixelGetColor(673, 243) = 0x929270 Then Send("!Q") ;Leave if defeatscreen come
    If PixelGetColor(677, 215) = 0x49412D Then Send("!Q") ;Leave if victoryscreen come
    ;Human
    If PixelGetColor(680, 232) = 0x485055 Then Send("!Q") ;Leave if defeatscreen come
    If PixelGetColor(684, 224) = 0x3D3E3D Then Send("!Q") ;Leave if victoryscreen come
    ;Nightelf
    If PixelGetColor(657, 235) = 0x3D6129 Then Send("!Q") ;Leave if defeatscreen come
    If PixelGetColor(670, 209) = 0x354019 Then Send("!Q") ;Leave if victoryscreen come
    ;Orc
    If PixelGetColor(645, 245) = 0x454531 Then Send("!Q") ;Leave if defeatscreen come
    If PixelGetColor(680, 237) = 0x434130 Then Send("!Q") ;Leave if victoryscreen come
    ;********************************************************************************
WEnd

Func toggle()
    If $stop = 0 Then
        $stop = 1
    Else
        $stop = 0
    EndIf
EndFunc

Func off()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Xoriaz,

It worked when I wrote it for you. :) You could try removing the unneeded EndIf (the one before the Else) that you seem to have added.

M23

P.S. If you use the full SciTE4AutoIt3 package, you can run Tidy on your code (by pressing Ctrl-T or selecting it from the Tools menu) and it will find these sort of errors for you automatically. :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Dim $stop = 0

HotKeySet("{F4}", "toggle")
HotKeySet("{F5}", "off")

$password = IniRead(@ScriptDir & "\settings.ini", "Settings", "Password", "Notfound")
$delay = IniRead(@ScriptDir & "\settings.ini", "Settings", "Delay", 5000)

While 1
    If $stop = 1 Then
        ;********************************************************************************
        If PixelGetColor(217, 591) = 0xCCB211 Then
            $iBegin = TimerInit()
            While TimerDiff($iBegin) < $delay
                If PixelGetColor(35, 149) = 0x737777 Then ExitLoop
            WEnd
            If PixelGetColor(217, 591) = 0xCCB211 Then Send("!Q")
        Else
            Sleep(10)
        EndIf
        ;********************************************************************************
        If PixelGetColor(167, 86) = 0xFFF052 Then ; Press B to enter bnet
            Send("B")
            Sleep(5000)
        EndIf
        ;********************************************************************************
        If PixelGetColor(359, 414) = 0x291C11 Then ; Type password to enter game
            Send($password)
            Send("{ENTER}")
            Sleep(10000)
        EndIf
        ;********************************************************************************
        If PixelGetColor(504, 375) = 0x000000 Then Send("{ENTER}") ; If wrong password screen come up it press enter
        If PixelGetColor(28, 157) = 0x5C594D Then Send("!Q") ; Sends search game if it is in ..channel
        If PixelGetColor(479, 114) = 0xFFFFFF Then Send("!Q") ;Leave if quitscreen come
        If PixelGetColor(109, 2) = 0x444244 Then Send("{ENTER}") ; If scorescreen comes
        ;********************************************************************************
        ;Undead
        If PixelGetColor(673, 243) = 0x929270 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(677, 215) = 0x49412D Then Send("!Q") ;Leave if victoryscreen come
        ;Human
        If PixelGetColor(680, 232) = 0x485055 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(684, 224) = 0x3D3E3D Then Send("!Q") ;Leave if victoryscreen come
        ;Nightelf
        If PixelGetColor(657, 235) = 0x3D6129 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(670, 209) = 0x354019 Then Send("!Q") ;Leave if victoryscreen come
        ;Orc
        If PixelGetColor(645, 245) = 0x454531 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(680, 237) = 0x434130 Then Send("!Q") ;Leave if victoryscreen come
        ;********************************************************************************
;### Tidy Error -> "wend" is closing previous "if" on line 14
    WEnd

;### Tidy Error -> while Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
    Func toggle()
        If $stop = 0 Then
            $stop = 1
        Else
            $stop = 0
        EndIf
    EndFunc   ;==>toggle
;### Tidy Error -> while Not closed before "Func" statement.
;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement.
    Func off()
        Exit
    EndFunc   ;==>off;### Tidy Error -> while is never closed in your script.

I dont know how to fix :7 lol

Edited by Xoriaz

Share this post


Link to post
Share on other sites

Xoriaz,

Yes, Tidy can be a bit confusing - the problem is that 1 error can cascade throughout the script and make it look as if you have multiple errors! :) In this case there is only one - trust me!

The trick is to always start with the first error:

;### Tidy Error -> "wend" is closing previous "if" on line 14
    WEnd

This is telling you that you are missing an EndIf here to close the If statement on line 14. So add an EndIf like this:

Dim $stop = 0

HotKeySet("{F4}", "toggle")
HotKeySet("{F5}", "off")

$password = IniRead(@ScriptDir & "\settings.ini", "Settings", "Password", "Notfound")
$delay = IniRead(@ScriptDir & "\settings.ini", "Settings", "Delay", 5000)

While 1
    If $stop = 1 Then
        ;********************************************************************************
        If PixelGetColor(217, 591) = 0xCCB211 Then
            $iBegin = TimerInit()
            While TimerDiff($iBegin) < $delay
                If PixelGetColor(35, 149) = 0x737777 Then ExitLoop
            WEnd
            If PixelGetColor(217, 591) = 0xCCB211 Then Send("!Q")
        Else
            Sleep(10)
        EndIf
        ;********************************************************************************
        If PixelGetColor(167, 86) = 0xFFF052 Then ; Press B to enter bnet
            Send("B")
            Sleep(5000)
        EndIf
        ;********************************************************************************
        If PixelGetColor(359, 414) = 0x291C11 Then ; Type password to enter game
            Send($password)
            Send("{ENTER}")
            Sleep(10000)
        EndIf
        ;********************************************************************************
        If PixelGetColor(504, 375) = 0x000000 Then Send("{ENTER}") ; If wrong password screen come up it press enter
        If PixelGetColor(28, 157) = 0x5C594D Then Send("!Q") ; Sends search game if it is in ..channel
        If PixelGetColor(479, 114) = 0xFFFFFF Then Send("!Q") ;Leave if quitscreen come
        If PixelGetColor(109, 2) = 0x444244 Then Send("{ENTER}") ; If scorescreen comes
        ;********************************************************************************
        ;Undead
        If PixelGetColor(673, 243) = 0x929270 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(677, 215) = 0x49412D Then Send("!Q") ;Leave if victoryscreen come
        ;Human
        If PixelGetColor(680, 232) = 0x485055 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(684, 224) = 0x3D3E3D Then Send("!Q") ;Leave if victoryscreen come
        ;Nightelf
        If PixelGetColor(657, 235) = 0x3D6129 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(670, 209) = 0x354019 Then Send("!Q") ;Leave if victoryscreen come
        ;Orc
        If PixelGetColor(645, 245) = 0x454531 Then Send("!Q") ;Leave if defeatscreen come
        If PixelGetColor(680, 237) = 0x434130 Then Send("!Q") ;Leave if victoryscreen come
        ;********************************************************************************
    EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Added
WEnd

Func toggle()
    If $stop = 0 Then
        $stop = 1
    Else
        $stop = 0
    EndIf
EndFunc   ;==>toggle
Func off()
    Exit
EndFunc   ;==>off

Run Tidy again and it removes all the other errors which were just cascading from the first and tells you everything is now fine.

So remember that you need to fix the FIRST error and then rerun Tidy to see if there are any further problems. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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