How do i use more then 1 button?

10/23/2018 22:18 sadusten#1
Okay so, ive spent 2 days updating and making my uw skele looking and working neat. Now i've comed to a conclusion where i want to have 3 buttons on it.

1st being the normal start for doing the underworld loop
2nd being going la to turn in quests
3rd being opening tots.

i've been messing around with the eventhandler and the while 1 loop for a day, and i havnt really had much knowledge about the eventhandler functions, since i've always copied somebody elses loop and just put my functions in there.

So what i want is basically to be able to run underworld, then press pause, and once paused i can then press button 2 to go LA and turn in quests, and open tots with button 3. Everything without having to close down the bot at all.
Is that possible? any info would be very much appreciated!


LEADER SCRIPT
Code:
Global Const $btnStart = GUICtrlCreateButton("Start", 8, 200, 154, 25)
Global Const $btnAcceptor = GUICtrlCreateButton("Grab ToT", 8, 230, 154, 25)
Global Const $btnOpenToT = GUICtrlCreateButton("Open ToT", 8, 260, 154, 25)


GUICtrlSetOnEvent($cbxHideGW, "EventHandler")
GUICtrlSetOnEvent($btnStart, "EventHandler")
GUICtrlSetOnEvent($btnAcceptor, "EventHandler")
GUICtrlSetOnEvent($btnOpenToT, "EventHandler")
GUISetOnEvent($GUI_EVENT_CLOSE, "EventHandler")
GUISetState(@SW_SHOW)

#include "Shared.au3"


Out("Ready")


Do
	Sleep(500)
Until $yeetInitialized Or $boolInitialized Or $dabInitialized


SetMaxMemory()


While 1


	If $boolRunning Then ;UW SKELE
		Main()
	Else
		Out("Bot Paused")
		GUICtrlSetState($btnStart, $GUI_ENABLE)
		GUICtrlSetData($btnStart, "Start")
		GUICtrlSetState($btnAcceptor, $GUI_ENABLE)
		GUICtrlSetData($btnAcceptor, "ToT Time")
		If Not $boolRunning Then
			Do
				Sleep(500)
			Until $boolRunning Or $yeetrunning Or $dabrunning
		EndIf

	EndIf


	If $yeetrunning Then ;LA QUEST
	GoQuests()
	Else
		out("Bot Paused")
		GUICtrlSetState($btnStart, $GUI_ENABLE)
		GUICtrlSetData($btnStart, "Start")
		GUICtrlSetState($btnAcceptor, $GUI_ENABLE)
		GUICtrlSetData($btnAcceptor, "ToT Time")
		If Not $yeetrunning Then
			Do
				Sleep(250)
			Until $boolRunning Or $yeetrunning Or $dabrunning
		EndIf
	EndIf



	If $dabrunning Then ;OPEN TOTS
		GORAPESOMETOTS()
	Else
		Out("Bot Paused")
		GUICtrlSetState($btnStart, $GUI_ENABLE)
		GUICtrlSetData($btnStart, "Start")
		GUICtrlSetState($btnAcceptor, $GUI_ENABLE)
		GUICtrlSetData($btnAcceptor, "ToT Time")
		If Not $dabrunning Then
			Do
				Sleep(500)
			Until $boolRunning Or $yeetrunning Or $dabrunning
		EndIf

	EndIf

WEnd

SHARED SCRIPT.
Code:
Global $yeetrunning = False
Global $yeetInitialized = False

Global $dabrunning = False
Global $dabInitialized = False

Global $boolRunning = False
Global $boolInitialized = False

Global $Rendering = True

Global Const $USED_CITY = $TOA_ID
Global Const $POSITION_NEAR_AVATAR = $POSITION_NEAR_AVATAR_CHANTRY
Global Const $POSITION_AVATAR = $POSITION_AVATAR_CHANTRY

Global $runs = 0
Global $fails = 0
Global $GoldDrops = 0
Global $qcount = 0
Global $lastDistrict = -1


Func EventHandler()
	Switch (@GUI_CtrlId)


		Case $btnStart
			If $boolRunning Then
				GUICtrlSetData($btnStart, "Will pause after this run")
				GUICtrlSetState($btnStart, $GUI_DISABLE)
				$boolRunning = False
			ElseIf $boolInitialized Then
				GUICtrlSetData($btnStart, "Pause")
				$boolRunning = True
			Else
				$boolRunning = True
				GUICtrlSetData($btnStart, "Initializing...")
				GUICtrlSetState($btnStart, $GUI_DISABLE)
				GUICtrlSetState($inputCharName, $GUI_DISABLE)
				WinSetTitle($MainGui, "", GUICtrlRead($inputCharName))
				If GUICtrlRead($inputCharName) = "" Then
					If Initialize(ProcessExists("gw.exe"), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Guild Wars it not running.")
						Exit
					EndIf
				Else
					If Initialize(GUICtrlRead($inputCharName), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Can't find a Guild Wars client with that character name.")
						Exit
					EndIf
				EndIf
				GUICtrlSetData($btnStart, "Pause")
				GUICtrlSetState($btnStart, $GUI_ENABLE)
				$boolInitialized = True
			EndIf


					Case $btnAcceptor
			If $boolRunning Then
				GUICtrlSetData($btnAcceptor, "Will pause after this run")
				GUICtrlSetState($btnAcceptor, $GUI_DISABLE)
				$boolRunning = False
			ElseIf $boolInitialized Then
				GUICtrlSetData($btnAcceptor, "Pause")
				$boolRunning = True
			Else
				$boolRunning = True
				GUICtrlSetData($btnAcceptor, "Initializing...")
				GUICtrlSetState($btnAcceptor, $GUI_DISABLE)
				GUICtrlSetState($inputCharName, $GUI_DISABLE)
				WinSetTitle($MainGui, "", GUICtrlRead($inputCharName))
				If GUICtrlRead($inputCharName) = "" Then
					If Initialize(ProcessExists("gw.exe"), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Guild Wars it not running.")
						Exit
					EndIf
				Else
					If Initialize(GUICtrlRead($inputCharName), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Can't find a Guild Wars client with that character name.")
						Exit
					EndIf
				EndIf
				GUICtrlSetData($btnAcceptor, "Pause")
				GUICtrlSetState($btnAcceptor, $GUI_ENABLE)
				$boolInitialized = True
			EndIf



		Case $btnOpenToT
			If $dabrunning Then
				GUICtrlSetData($btnOpenToT, "Will pause after this run")
				GUICtrlSetState($btnOpenToT, $GUI_DISABLE)
				$dabrunning = False
			ElseIf $dabInitialized Then
				GUICtrlSetData($btnOpenToT, "Pause")
				$dabrunning = True
			Else
				$dabrunning = True
				GUICtrlSetData($btnOpenToT, "Initializing...")
				GUICtrlSetState($btnOpenToT, $GUI_DISABLE)
				GUICtrlSetState($inputCharName, $GUI_DISABLE)
				WinSetTitle($MainGui, "", GUICtrlRead($inputCharName))
				If GUICtrlRead($inputCharName) = "" Then
					If Initialize(ProcessExists("gw.exe"), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Guild Wars it not running.")
						Exit
					EndIf
				Else
					If Initialize(GUICtrlRead($inputCharName), True, False, False) = False Then ; don't need string logs or event system
						MsgBox(0, "Error", "Can't find a Guild Wars client with that character name.")
						Exit
					EndIf
				EndIf
				GUICtrlSetData($btnOpenToT, "Pause")
				GUICtrlSetState($btnOpenToT, $GUI_ENABLE)
				$dabInitialized = True
			EndIf



		Case $cbxHideGW
			ClearMemory()
			ToggleRendering()




		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
EndFunc   ;==>EventHandler
10/24/2018 02:16 savsuds#2
Take a peek at how I did something similar. Ignore the tabs part, because I like tabs.

[Only registered and activated users can see links. Click Here To Register...]
Code:
While 1
	Sleep(1000)
	If $BoolRun Then
		Switch $CurrentTab
			Case 0
			   If GUICtrlRead($Glint, "") == "Cast and Chill" Then
				  CastBonds()
				  GoChill()
				  $BoolRun = False
				  GUICtrlSetData($btnStart, "Start")
			   ElseIf GUICtrlRead($Glint, "") == "Cast Spirits" Then
				  CastSpirits()
				  $BoolRun = False
				  GUICtrlSetData($btnStart, "Start")
			   EndIf
10/24/2018 15:21 sadusten#3
Quote:
Originally Posted by savsuds View Post
Take a peek at how I did something similar. Ignore the tabs part, because I like tabs.

[Only registered and activated users can see links. Click Here To Register...]
Code:
While 1
	Sleep(1000)
	If $BoolRun Then
		Switch $CurrentTab
			Case 0
			   If GUICtrlRead($Glint, "") == "Cast and Chill" Then
				  CastBonds()
				  GoChill()
				  $BoolRun = False
				  GUICtrlSetData($btnStart, "Start")
			   ElseIf GUICtrlRead($Glint, "") == "Cast Spirits" Then
				  CastSpirits()
				  $BoolRun = False
				  GUICtrlSetData($btnStart, "Start")
			   EndIf
It looks very interesting, but i've never used any tabs, and also never created a switch, ive seen different of switches but im not near experienced in them. In this case since i have 3 different buttons, what should the Switch expression be? Should i have more than just $boolrun and $boolinitialize variables inside the eventhandler for different buttons? Like i have in my earlier post where $yeetrun and $dabrunning would be False for a specific button. Wouldnt wanna do tabs and other stuff, just wanna keep it simple :) sorry im tired, and its fine if u dont have the time <3

My buttons:
Code:
Global Const $btnStart = GUICtrlCreateButton("Start", 8, 200, 154, 25)
Global Const $btnAcceptor = GUICtrlCreateButton("Grab ToT", 8, 230, 154, 25)
Global Const $btnOpenToT = GUICtrlCreateButton("Open ToT", 8, 260, 154, 25)


Example from your while loop, and i just popped in the buttons i guess.



While 1
	Sleep(1000)
	If $BoolRun Then
		Switch <<<<<<<
			Case 0
			   If *button 1
				  UnderworldSKELETING()		  
				  $BoolRun = False
				  GUICtrlSetData($btnStart, "Start")
			   ElseIf *Button 2
				   GRABQUESTREWARD()
				  $BoolRun = False
				  GUICtrlSetData($btnAcceptor , "Start")
			   ElseIf *Button 3
				   OPENTOTS()
				  $BoolRun = False ;
				  GUICtrlSetData($btnOpenToT , "Start")
			   EndIf
                   endswitch
            endif
wend
10/25/2018 15:48 sadusten#4
Sorry just ignore my recent post, atm im making a gui with tab, everything will look smoother, ill tell you if i succeed or not :), and also the link to your pauls helper doesnt initialize, would like to have a look at your gui to get the understanding throughout.
10/27/2018 16:01 sadusten#5
I got it working perfect, but instead of tabs and switch, i ended up using


Code:
Func GetChecked($GUICtrl)
	Return (GUICtrlRead($GUICtrl) == $GUI_Checked)
EndFunc   ;==>GetChecked

out("Ready")

Do
	Sleep(100)
Until GetChecked($CboxQUESTANDTOT) Or GetChecked($CboxUNDERWORLDSKELE)

If GetChecked($CboxUNDERWORLDSKELE) Then
	out("Underworld Selected")
ElseIf GetChecked($CboxQUESTANDTOT) Then
	out("Quest + Tot's Selected")
EndIf


Do
	Sleep(100)
Until $BoolInitialized

SetMaxMemory()

While 1
	If $BoolRun Then
		If GetChecked($CboxUNDERWORLDSKELE) Then
			SkelefarmFollower()
		EndIf
		If GetChecked($CboxQUESTANDTOT) Then
			GrabAndOpenToTs()
		EndIf
	Else
		out("Bot Paused")
		GUICtrlSetState($btnStart, $GUI_ENABLE)
		GUICtrlSetData($btnStart, "Start")
		While Not $BoolRun
			Sleep(100)
		WEnd
	EndIf
WEnd