Jump to content

Beginner needs some help with basic GUI


Recommended Posts

I made a simple script which presses some buttons, I would like to make a gui so i can start and stop that script but i seem to fail there. (keep in mind that i started with autoit 20 mins ago :blink: )

the basic gui is ready and when i press start it works, but i would love that the script stops when i press stop. (so it won't auto press the keys anymore).

and is there a way to put the GUI always on foreground even when selecting another window ?

Thanks in advance for the help and advice.

; A simple custom messagebox that uses the OnEvent mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID

_Main()

Func _Main()
    Local $StartID, $StopID

    GUICreate("Distiny's AFK Farmer", 300, 80)

    GUICtrlCreateLabel("Start or Stop the script!", 10, 10)
    $StartID = GUICtrlCreateButton("Start", 10, 50, 50, 20)
    GUICtrlSetOnEvent($StartID, "onstart")
    $StopID = GUICtrlCreateButton("Stop", 80, 50, 50, 20)
    GUICtrlSetOnEvent($StopID, "onstop")
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)
    GUICtrlSetOnEvent($ExitID, "OnExit")

    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

    GUISetState() ; display the GUI

    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main

;--------------- Functions ---------------
Func onstart()

    Local $loopcount
    ;   MsgBox(0, "Distiny's test", "Start")    ;My original script STARTS HERE
    $loopcount = 1

    ; $loopcount will always be higher then 0 thus this is an infinite loop
    While $loopcount > 0
        ; Increase the count by one
        $loopcount = $loopcount + 1

        ; we are doing the press Y button + wait 10 secs  10 times
        For $i = 1 To 10 Step +1
            Send("y")
            Sleep(6000) ; Wait 6 secs



        Next
        ; After Y has been pressed 10 times we press b and wait 1 sec
        Send("b")
        Sleep(1000) ; Wait 1 sec

    WEnd  ;My original script STOPS HERE
EndFunc   ;==>onstart

Func onstop()
    MsgBox(0, "Distiny's test", "Stop")
EndFunc   ;==>onstop

Func OnExit()
    If @GUI_CtrlId = $ExitID Then
        MsgBox(0, "Exit", "Report Bugs To Distiny please !")
    EndIf

    Exit
EndFunc   ;==>OnExit
Edited by Distiny
Link to comment
Share on other sites

GUICreate("Distiny's AFK Farmer", 300, 80)

Not a very smart way to start here on your very first post.

If you read the announcement http://www.autoitscript.com/forum/index.php?showannouncement=11&f=2 you could have realised that Game Bots doesn't get much support in here and in your case I'm 99% sure it is about an online multiplayer game.

I really doubt anyone would give any help.

If you want to learn AutoIt there are better ways than making a bot.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

yes i did read it, but this is for a web based game and nowhere in the rules is there something about automated macro's cause it's basicly a macro.

but I came here to learn and improve my code, I ain't asking how to code bots, this was a gui and probably a func question, I'm sry if I broke rules, I thought I understood only of the program breaks the EULA or TOS it wasn't allowed

Link to comment
Share on other sites

Everyone and their cats interpret that announcement differently. In any case, you will find it much harder to get help if you make any reference to a game, or otherwise make it look like a bot (like writing "AFK Farmer").

Play it safe, don't discuss game bots here.

Link to comment
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
 Share

  • Recently Browsing   0 members

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