Jump to content

Need help about GUI not closing.


DuyV
 Share

Recommended Posts

Hello, This is the first time I use autoit to make a game bot. I create a GUI with KODA and after writing all the codes. Nothing works and I can't even close the GUI.

Here is my script

#include 
#include 
#include 
#include 
#include 
#include 
#Region ### START Koda GUI section ### Form=C:\Users\Duy Vo\Desktop\audi-auto\Forms\AuditionAuto.kxf
$AuditionAuto = GUICreate("Audition Auto", 306, 434, 288, 179, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
GUISetFont(11, 400, 0, "MS Sans Serif")
$water = GUICtrlCreateCheckbox("Water", 16, 32, 97, 17)
$brush = GUICtrlCreateCheckbox("Brush", 16, 64, 97, 17)
$fert = GUICtrlCreateCheckbox("Fert", 16, 96, 97, 17)
$gift = GUICtrlCreateCheckbox("Gift", 192, 32, 97, 17)
$heart = GUICtrlCreateCheckbox("Heart", 192, 64, 97, 17)
$money = GUICtrlCreateCheckbox("Money", 192, 96, 97, 17)
$delay = GUICtrlCreateInput("Delay Time In Second", 16, 120, 150, 24)
$nos = GUICtrlCreateInput("Number Of Spin", 128, 224, 81, 21)
GUICtrlSetFont($nos, 4, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor($nos, 0xFFFFE1)
$gdtitle = GUICtrlCreateLabel("Garden Auto", 120, 8, 79, 20)
$hbtitle = GUICtrlCreateLabel("Happy Box Auto", 120, 200, 101, 20)
$x1K = GUICtrlCreateRadio("1K", 16, 256, 113, 17)
$x2K = GUICtrlCreateRadio("2K", 16, 280, 113, 17)
$x3K = GUICtrlCreateRadio("3K", 16, 304, 113, 17)
$x4K = GUICtrlCreateRadio("4K", 16, 328, 113, 17)
$x5K = GUICtrlCreateRadio("5K", 16, 352, 113, 17)
$x6K = GUICtrlCreateRadio("6K", 170, 256, 113, 17)
$x7K = GUICtrlCreateRadio("7K", 170, 280, 113, 17)
$x8K = GUICtrlCreateRadio("8K", 170, 304, 113, 17)
$x9K = GUICtrlCreateRadio("9K", 170, 328, 113, 17)
$x10K = GUICtrlCreateRadio("10K", 170, 352, 113, 17)
$gdstart = GUICtrlCreateButton("Start Garden Auto", 8, 152, 113, 33)
$hbstart = GUICtrlCreateButton("Start Happy Box Auto", 8, 384, 137, 33)
$gdstop = GUICtrlCreateButton("Stop", 176, 152, 121, 33)
$hbstop = GUICtrlCreateButton("Stop", 176, 384, 121, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



Opt("MouseCoordMode", 0)
Opt("CaretCoordMode", 0)
Opt("MouseClickDownDelay", 200)
Opt("PixelCoordMode", 0)

HotKeySet("^g","gdstop")
HotKeySet("^h","hbstop")

$am = 0
$gdstophk = 0




While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $x1K
$am = 1
Case $x2K
$am = 2
Case $x3K
$am = 3
Case $x4K
$am = 4
Case $x5K
$am = 5
Case $x6K
$am = 6
Case $x7K
$am = 7
Case $x8K
$am = 8
Case $x9K
$am = 9
Case $x10K
$am = 10
Case $gdstart
gd()
Case $hbstart
hb()
EndSwitch

WEnd


Func gd()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gdstop
ExitLoop
Case $gdstophk = 1
ExitLoop
Case $water
water()
Case $brush
brush()
Case $fert
fert()
Case $gift
gift()
Case $heart
heart()
Case $money
money()
EndSwitch

Sleep($delay * 1000)
WEnd
EndFunc

Func gdstop()
$gdstophk = 1
EndFunc


Func water()
$Search = 1

MouseMove(344,494)
MouseClick("left", 344, 494, 1, 50)
While $Search = 1
$Search = 0
$Search = _ImageSearch('water.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)
EndIf
WEnd
EndFunc

Func brush()
$Search = 1

MouseMove(512,494)
MouseClick("left", 344, 494, 1, 50)
While $Search = 1
$Search = 0
$Search = _ImageSearch('brush.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)
EndIf
WEnd
EndFunc


Func fert()
$Search = 1

MouseMove(405,494)
MouseClick("left", 344, 494, 1, 50)
While $Search = 1
$Search = 0
$Search = _ImageSearch('fert.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)

EndIf
WEnd
EndFunc


Func gift()
$Search = 1
While $Search = 1
$Search = 0
$Search = _ImageSearch('gift.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseClick("right")
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)

EndIf
WEnd
EndFunc


Func heart()
$Search = 1
While $Search = 1
$Search = 0
$Search = _ImageSearch('heart.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseClick("right")
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)

EndIf
WEnd
EndFunc


Func money()
$Search = 1
While $Search = 1
$Search = 0
$Search = _ImageSearch('money.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseClick("right")
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)

EndIf
WEnd
EndFunc



Func hb()
While $nos < 0
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hbstop
ExitLoop
Case Else
$Search = _ImageSearch('hb.bmp', 0, $x, $y, 0)
If $Search = 1 Then
MouseMove($x, $y, 1)
MouseClick("left", $x, $y, 1, 50)
Else
MsgBox(0, "Can't Find Happy Box Icon", "We're unable to find your Happybox icon. Please make sure that you are in lobby or a room. Or purchase happybox")
EndIf

MouseMove(521,356, 20)
MouseClick("left",521,356, $am, 20)
MouseMove(519,552,20)
MouseClick("left",519,552,1,20)
MouseMove(524,586,20)
Sleep(4000)
MouseClick("left",524,586,1,20)
$nos = $nos - 1
EndSwitch
WEnd
EndFunc


Func hbstop()
$nos = 0
EndFunc
Link to comment
Share on other sites

Welcome to AutoIt and the forum!

First thing you need to do is read the forum rules!

You will see that game automation isn't permitted here. This is why you won't get any help on the subject.

Hope to see you with a legitimate question soon.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

Enough said.

Please follow the forum rules.

Thanks for your cooperation.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...