Adnihil

How to use GUI while non-looping function is playing?

2 posts in this topic

Hey what's up

I'm having some trouble with a creating a GUI that can be used while a function is happening.

There's this online game I play that often crashes so I made a script that automatically opens the game and logs me back in when the game is closed (and it closes error messageboxes too if there are any). I've got a GUI with buttons to start, pauze, and end the script, which works fine when the login-function is not playing, but when the login-function is playing, the buttons become unresponsive until it is finished. Stripped down, the script looks something like this:

Global $started = 0

; GUI
Global $hGUI = GUICreate("Auto login")
Global $idSTART = GUICtrlCreateButton("Start", 210, 370, 85, 25)
Global $idCLOSE = GUICtrlCreateButton("Quitter", 305, 370, 85, 25)
GUISetState(@SW_SHOW, $hGUI)

;Hotkeys: Toggle to switch between Func Deactivated() and Func Activated(). Close to end the entire script.
HotKeySet("{PGDN}", "Toggle")
HotKeySet("{HOME}", "Close")

Deactivated()

Func Deactivated()
    $started = 0
    While 1
        Switch GUIGetMsg()
            Case $idSTART
                Activated()
            Case $idCLOSE
                Exit
        EndSwitch
    WEnd
EndFunc

Func Activated()
   $started = 1
   While 1
      Switch GUIGetMsg()
         Case $idSTART
            Deactivated()
         Case $idCLOSE
            Exit
      EndSwitch
      
      ;Function that closes error messages, checks if the game isn't already open, and starts Func Login() if it's not.
      
   WEnd
EndFunc

Func Login()
      ; Function that opens the game, checks if there's a valid connection, waits for the game to be ready etc, enters the login information, and logs in.
EndFunc

;Toggle between Activated() and Deactivated().
Func Toggle()
   If $started = 0 Then
      Activated()
   Else
      Deactivated()
   EndIf
EndFunc

;Ends entire script.
 Func Close()
      Exit
 EndFunc

I could post the entire script if needed.

Now, I know why the buttons become unresponsive; There is no 'SwitchGUIGetMsg' in Func Login(), and Func Login() is not in a loop (because it's only supposed to play once every time Func Activated() tells it to).

So how can I make it so I can still use the buttons while the Login() is playing?

Many thanks in advance!

Share this post


Link to post
Share on other sites

Adnihil,

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game interaction - and then you will understand why you will get no specific help and this thread will now be locked. However, you might find the Interrupting a running function tutorial in the Wiki a useful read.

See you soon with a legitimate question I hope.

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
Guest
This topic is now closed to further replies.