Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 01:40

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Need help with using a GUI

Discussion on Need help with using a GUI within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
BitOfHope's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 69
Received Thanks: 11
Need help with using a GUI

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=====
BitOfHope is offline  
Old 07/07/2012, 07:17   #2
 
genesisVI's Avatar
 
elite*gold: 0
Join Date: Jul 2011
Posts: 796
Received Thanks: 434
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....
genesisVI is offline  
Old 07/07/2012, 07:30   #3
 
BitOfHope's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 69
Received Thanks: 11
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?
BitOfHope is offline  
Old 07/07/2012, 07:53   #4
 
elite*gold: 40
Join Date: Apr 2012
Posts: 674
Received Thanks: 83
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
tobindev is offline  
Thanks
1 User
Reply




All times are GMT +2. The time now is 01:40.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.