Jump to content

Looping With GUI Button


 Share

Recommended Posts

Alright im still new to this but i wrote a pretty basic script to stop anti-idle in a game! I got most of the GUI and Displays working correctly except this one... It only plays out once then stops i want this to repeat until the gui exit button is selected!

Case $msg = $Button_1
$bLoop = 3
        ControlFocus("[CLASS:Second Life]", "", "")
            Sleep(2000)
                MouseClick("left", 647, 213, 1)
            Sleep(30000)
                MouseClick("left", 660, 213, 1)
            Sleep(30000)
Link to comment
Share on other sites

Ok here is the whole script!

I just need it to loop on press of button 1... Until Button 2 is pressed!

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Verification For DCS Anti Idle", "Please enter the password!")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Dragon", "OK.  Bye!")
    Exit
EndIf

HotKeySet("^!x", "MyExit")

; Loop around until the user gives a valid "autoit" answer
$bLoop = 1
While $bLoop = 1
    $text = InputBox("Verification For DCS Anti Idle", "Plase enter the password!")
    If @error = 1 Then
        MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    Else
        ; They clicked OK, but did they type the right thing?
        If $text <> "Dragon" Then
            MsgBox(4096, "Error", "You typed in the wrong password - try again!")
        Else

        If Not WinExists("[CLASS:Second Life]") Then
            MsgBox(0, "", "Please make sure you have Second Life open before starting the program!")
        EndIf

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("DCS2 Anti-Idle", "250", "75")

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Start Anti-Idle", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("End Anti-Idle", 0, -1)

    GUISetState()      ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Button_1
 $bLoop = 1
        ControlFocus("[CLASS:Second Life]", "", "")
            Sleep(2000)
                MouseClick("left", 647, 213, 1)
            Sleep(30000)
                MouseClick("left", 660, 213, 1)
            Sleep(30000)
            Case $msg = $Button_2
            Exit
        EndSelect
    WEnd
EndFunc 

Func MyExit()
    Exit
EndFunc 
        EndIf
    EndIf
WEnd
Link to comment
Share on other sites

Maybe....

#include <GUIConstantsEx.au3>

;Opt('MustDeclareVars', 1)
Opt("GUICoordMode", 2)

HotKeySet("^!x", "MyExit")

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Verification For DCS Anti Idle", "Please enter the password!")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Dragon", "OK.  Bye!")
    Exit
EndIf



; Loop around until the user gives a valid "autoit" answer
$bLoop = 1
While $bLoop = 1
    $text = InputBox("Verification For DCS Anti Idle", "Plase enter the password!")
    If @error = 1 Then
        MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    Else
        ; They clicked OK, but did they type the right thing?
        If $text <> "Dragon" Then
            MsgBox(4096, "Error", "You typed in the wrong password - try again!")
        Else

            If Not WinExists("[CLASS:Second Life]") Then
                MsgBox(0, "", "Please make sure you have Second Life open before starting the program!")
            Else
                Example()
            EndIf
        EndIf
    EndIf
WEnd



Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("DCS2 Anti-Idle", "250", "75")


    $Button_1 = GUICtrlCreateButton("Start Anti-Idle", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("End Anti-Idle", 0, -1)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Button_1
                $bLoop = 1
                ControlFocus("[CLASS:Second Life]", "", "")
                Sleep(2000)
                MouseClick("left", 647, 213, 1)
                Sleep(30000)
                MouseClick("left", 660, 213, 1)
                Sleep(30000)
                GUICtrlSetState($Button_1, $GUI_DISABLE)
            Case $msg = $Button_2
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func MyExit()
    Exit
EndFunc   ;==>MyExit

****** NOT TESTED

8)

NEWHeader1.png

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