Servasius Posted May 27, 2018 Share Posted May 27, 2018 Hello, I am new to AutoIT, in fact, this is my first script. I'm trying to create some script to automate some activities within the game. I have managed to get the Auto_Loot_Start function to work but I can't seem to get out of the infinite loop using the button when I press EXIT. I try to find the solution and found some that might work. One of them is to set a HotKey. Though I don't really want to use HotKey since I want to keep it all GUI based. Another solution I read was OnEvent Mode to interrupt the infinite loop. I tried to understand some of the examples that I found online but I don't get it how to implement it in my script. I hope all the experts in here can help me with this problem and please explain your answer in details so I can understand them better. To make things clearer, The startAutoLoot() function is supposed to send x key in an infinite loop. Which I think I get it to work. stopAutoLoot() function is supposed to pause the script without closing it. I don't know if I'm doing it right or not. terminateScript() function is supposed to exit the program/script. This only work only if startAutoLoot() function is not started yet. startAutoBuff() and startHolyForce() are not implemented yet. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=Z:\GuNkzZ\Documents\RF_Script.kxf Global $RF_Script = GUICreate("RF_Script", 213, 211, -1, -1) GUISetFont(8, 400, 0, "Open Sans") GUISetBkColor(0x000000) Global $Auto_Loot_Start = GUICtrlCreateButton("Auto_Loot_Start", 8, 8, 195, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $Auto_Loot_Stop = GUICtrlCreateButton("Auto_Loot_Stop", 8, 48, 195, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $Auto_Buff_Start = GUICtrlCreateButton("Auto_Buff_Start", 8, 88, 195, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $Holy_Force_Buff = GUICtrlCreateButton("Holy_Force_Buff", 8, 128, 195, 33) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $EXIT = GUICtrlCreateButton("EXIT", 8, 168, 195, 33) GUICtrlSetFont(-1, 10, 800, 0, "Open Sans") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Auto_Loot_Start startAutoLoot() Case $Auto_Loot_Stop stopAutoLoot() Case $Auto_Buff_Start startAutoBuff() Case $Holy_Force_Buff startHolyForce() Case $EXIT terminateScript() EndSwitch WEnd Func startAutoLoot() if WinExists("RF Online") Then WinActivate("RF Online") while(1) Send("{x}") Sleep (100) WEnd EndIf EndFunc ;==>Start Auto Loot Func stopAutoLoot() if WinExists("RF Online") Then WinActivate("RF Online") while(1) Sleep (50) WEnd EndIf EndFunc ;==>Stop Auto Loot Func terminateScript() Exit EndFunc ;==>Stop the script Thank you for the help! Link to comment Share on other sites More sharing options...
TheDcoder Posted May 27, 2018 Share Posted May 27, 2018 I have not looked your post but you can try ExitLoop which will end the loop. While True ; Infinite Sleep(1000) ExitLoop Wend EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2018 Moderators Share Posted May 27, 2018 Servasius, 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 automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. TheDcoder, Please actually read the post before replying - I have seldom seen a thread which made it quite so clear that the code was for a gamebot. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts