Need help with using a GUI

07/07/2012 03:20 BitOfHope#1
I've been using AutoIt in my spare time for awhile now, but I never tried making my scripts work through a GUI.

So I used 'Koda' to make the GUI real quick.

I've got 2 basic functions to check my characters HP and MP and use potions if needed. I've got no idea how to combine this into the script.

I'd like to be able to click the check box on either/both and then click start to begin the script, and pause to... well, pause it.

I've spent the past 3 hours googling and testing things, but nothing explains HOW they do what they do, so I'm lost on how to actually do it.

Any help is appreciated.

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 250, 94, 192, 124)
$Button1 = GUICtrlCreateButton("Start", 168, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Pause", 168, 8, 75, 25)
$Checkbox1 = GUICtrlCreateCheckbox("Enable auto-HP potions", 8, 8, 137, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Enable auto-MP potions", 8, 40, 129, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd


;=====Functions=====

Func UseHP()
	$coord = PixelSearch(312, 771, 324, 776, 0xDD0033) ;define where you want to search on your HP bar
	If $coord = 0 Then
		Send("{ALT}") ;This is the macro to use an HP potion
		Sleep(1000)
	Else
		Send("{LCTRL}") ;This is what happens when your HP is fine
		Sleep(1000)
	EndIf
EndFunc   ;==>UseHP

Func UseMP()
	$coord2 = PixelSearch(485, 771, 506, 776, 0x22BBFF) ;define where you want to search on your MP bar
	If $coord2 = 0 Then
		Send("{1}") ;This is the macro to use an MP potion
		Sleep(1000)
	Else
		Send("{LCTRL}") ;This is what happens when your MP is fine
		Sleep(1000)
	EndIf
EndFunc   ;==>UseMP

;=====End Functions=====
07/07/2012 07:17 genesisVI#2
Code:
while 1
$msg = GuiGetMsg()
select
case $msg = $start<====:its a set 4 the start button u cr8ted 
$send = run("BOT.exe")<====: these works as an external call, it can run any prog. u want...
Endselect
Wend
its advisable to separate the gui and the bot....
07/07/2012 07:30 BitOfHope#3
Quote:
Originally Posted by genesisVI View Post
Code:
while 1
$msg = GuiGetMsg()
select
case $msg = $start
$send = run("BOT.exe")
endselect
wend
where $start = to ur start button
and bot.exe is ur bot ^_^ wish it helped
its advisable to separate the gui and the bot....
Sorry, could you please explain that a bit more clearly?
07/07/2012 07:53 tobindev#4
Code:
Global $nMsg
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1 ;when the start button is pressed
            ;start your bot
        Case $Button2 ;when the pause button is pressed
            ;pause your bot
        Case $GUI_EVENT_CLOSE ;when you close the window
            GUIDelete() ;delete GUI
            Exit ;and exit
    EndSwitch
WEnd