Jump to content

ExitLoop Help


Recommended Posts

hotkeyset ("{F9}", "hide") 
hotkeyset ("{F10}", "show") 
AutoItSetOption("WinTitleMatchMode", 4)

while 1 
sleep(1000) 
WEnd

func hide() 
$Show = 0
$handle = WinGetHandle("classname=GxWindowClassD3d")
WinSetState ($handle, "", @SW_MINIMIZE ) 
WinSetState ($handle, "", @SW_HIDE ) 
    If @error Then
        MsgBox(0, "error", "couldnt find WoW")
    Else
        While 1
            ControlSend($handle, "", "", "{RIGHT DOWN}")
            Sleep(700)
            ControlSend($handle, "", "", "{RIGHT UP}")
            Send("{ENTER}")
            ClipPut("/afk")
            Send("^v")
            Send("{ENTER}")
            Sleep(2000)
            If $Show > 0 Then ExitLoop
        Wend
    EndIf
endfunc 
 
func show() 
$Show = 1
Winsetstate ("World of Warcraft", "", @SW_SHOW ) 
WinSetState ("Worlf of Warcraft", "", @SW_MAXIMIZE )
endfunc

this is what happens, I push F9 everything goes fine then when i push F10 to stop it... It keeps on doing the loop in F9

Link to comment
Share on other sites

Variables defined inside functions only exist within that function, and nowhere else. The "$Show" you're defining in show() is a totally different variable than the one you're checking in hide(). To fix this, put the line:

Global $Show = 0

...just after the AutoItSetOption (or anywhere before the first While loop, really).

Edited by Sokko
Link to comment
Share on other sites

Variables defined inside functions only exist within that function, and nowhere else. The "$Show" you're defining in show() is a totally different variable than the one you're checking in hide(). To fix this, put the line:

Global $Show = 0

...just after the AutoItSetOption (or anywhere before the first While loop, really).

:o works prefectly now, thank you

Link to comment
Share on other sites

or you could change it a little

HotKeySet("{F9}", "hide")
HotKeySet("{F10}", "show")
HotKeySet("{ESC}", "Terminate")
AutoItSetOption("WinTitleMatchMode", 4)
$hiding = False
While 1
 Sleep(1000)
 If $hiding = True Then
  ControlSend($handle, "", "", "{RIGHT DOWN}")
  Sleep(700)
  ControlSend($handle, "", "", "{RIGHT UP}")
  Send("{ENTER}")
  ClipPut("/afk")
  Send("^v")
  Send("{ENTER}")
  Sleep(2000)
 EndIf
WEnd

Func hide()
 $handle = WinGetHandle("classname=GxWindowClassD3d")
 WinSetState($handle, "", @SW_MINIMIZE)
 WinSetState($handle, "", @SW_HIDE)
 If @error Then
  MsgBox(0, "error", "couldnt find WoW")
  $hiding = False
 Else
  $hiding = True
 EndIf
EndFunc  ;==>hide

Func show()
 $hiding = False
 WinSetState("World of Warcraft", "", @SW_SHOW)
 WinSetState("Worlf of Warcraft", "", @SW_MAXIMIZE)
EndFunc  ;==>show

Func Terminate()
 Exit
EndFunc  ;==>Terminate

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...