Sign in to follow this  
Followers 0
zerocool808

Please help!

5 posts in this topic

ok first off i just started using autoit yesterday so its pretty new to me, was wondering if anyone could help me with my code. i'm going to explain what im trying to accomplish and what this code is for. Basically this is an AFK bot for a game. What im trying to do is make a gui of my code so i can compile it to run on computers without autoit installed. First the code i have works when i run the script using autoit but when trying to make a gui of the same code it brings up errors. So i'm going to just post the code that i have without my attempt using the gui system. Pretty much how i get it to work using autoit is run the script then press "p" to activate and "u" to deactivate. CODE:

HotKeySet("p","Start")
HotKeySet("u","Stop")

Func Start()
While 1
$Temp = PixelGetColor(109, 45)
If $Temp = 6771269 Then
Send("{0}") 
EndIf
$Temp = PixelGetColor(172, 33)
If $Temp = 6968645 Then
Send("{7}") 
Sleep(100)
Send("{4}")
Sleep(100)
Send("{7}") 
Sleep(100)
EndIf
Send("{TAB}")
Sleep(50)
$Temp = PixelGetColor(738, 36)
If $Temp = 16756389 Then
Send("{1}") 
Sleep(100)
Send("{2}") 
Sleep(100)
Send("{4}")
Sleep(100)
Send("{1}")     
Sleep(100)
Send("{2}")
Sleep(100)
Send("{4}") 
Sleep(100)
Send("{4}") 
Sleep(100)
Send("{4}")
Sleep(100)
Send("{1}")
Sleep(100)
Send("{3}")
Sleep(100)
Send("{4}")     
Sleep(100)
Send("{2}") 
Sleep(100)
Send("{5}") 
$Temp = PixelGetColor(172, 33)
If $Temp = 6968645 Then
Send("{7}") 
Sleep(100)
Send("{7}") 
Sleep(100)
Send("{4}")
Sleep(100)
EndIf
Send("{5}")
Sleep(100)
Send("{5}")
Sleep(100)
Send("{5}")
Sleep(100)
Send("{5}")
Sleep(100)
;Send ("{LEFT down}")
;Sleep(200)
;Send ("{LEFT up}")
EndIf   
Sleep(10)                           
WEnd                                                                        
                                                    
EndFunc

While 2
    Sleep(100)
WEnd

Func Stop()
While 2

WEnd
    
EndFunc

Could someone please help me with the gui. Basically all i want is just a popup box with 2 buttons, "enable" and "disable" of course, the enable button with start and disable will stop the program. Thanks.

Share this post


Link to post
Share on other sites



If what you have already works, then in SciTE go to Tools -> Compile. This will package it in an EXE which will then be usable by computers that do not have AutoIt installed.

You don't really need a GUI in this case. Just run the .exe and then use "p" or "u" to run or stop the script.

Share this post


Link to post
Share on other sites

If what you have already works, then in SciTE go to Tools -> Compile. This will package it in an EXE which will then be usable by computers that do not have AutoIt installed.

You don't really need a GUI in this case. Just run the .exe and then use "p" or "u" to run or stop the script.

Thanks for the reply, i need a gui for it so that i can close the script/program when needed, cause if i need to type i wont be able to type the letter "p" or "u" or whatever key that i set it to. i need to disable the script some how.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
$continue = FALSE
GUICreate("GUI", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$start = GUICtrlCreateButton("START", 10, 10, 180, 80)
    GUICtrlSetOnEvent($start, "Start")
GUISetState()

While 1
    Sleep(1000)
    While $continue = TRUE
        ; Insert main script to loop when script is active
    WEnd
WEnd

Func Start()
    HotKeySet("u","Stop")   ; Enable HotKey
    GUICtrlSetState($start, $GUI_DISABLE)
    $continue = TRUE
;~  WinWaitActive(...)  ; After clicking start, you will want your script to start with the correct window in focus
EndFunc

Func Stop()
    HotKeySet("u")  ; Disable HotKey
    GUICtrlSetState($start, $GUI_ENABLE)
    $continue = FALSE
EndFunc

Func Close()
    Exit
EndFunc

Due to limitations which I am not aware of a workaround for (besides running two scripts, one for the GUI, one for the loop) when you press "u" to stop the script, it will not stop until that run of the looping script is finished. This is because the OnEvent triggers won't work if a trigger is launched that never ends (so the Start and Stop functions MUST end). As you have your code now, you end up nesting while loops every time you start or stop the script.

Also, the HotKey is disabled unless the script is actively running, so the GUI can be open without affecting your typing.

Edited by JRouleau

Share this post


Link to post
Share on other sites

Thank you so much for taking the time to help me. It works perfectly. I really appreciate the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0