Jump to content

Can't press button twice

Recommended Posts


Hello everyone,

When I want to start the start function after i  stopped it i can't start it again.
Can someone help me?

Here are my codes:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Silas Peters\Desktop\Bots\Cookie Clicker.kxf
Global $Form1 = GUICreate("Cookie Clicker Bot", 267, 87, -1, -1)
Global $Start = GUICtrlCreateButton("Start", 160, 48, 75, 25)
Global $Stop = GUICtrlCreateLabel("Om te stoppen druk op de 'ESC' knop", 40, 16, 182, 17)
Global $Internet = GUICtrlCreateButton("Open Coockie Clicker", 24, 48, 123, 25)
#EndRegion ### END Koda GUI section ###

HotKeySet("{ESC}", "Stop")
Local $i = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
         Case $start
         Case $Internet

Func Start()
   $i = 1
   While 1
      If  $i = 1 Then MouseClick ("left", 215, 379)

 Func Internet()
    ShellExecute ("http://orteil.dashnet.org/cookieclicker/")
    WinWaitActive ("" , "Chrome Legacy Window" )
    Sleep (3000)
    WinActivate ("Cookie Clicker Bot")

 Func Stop()
  $i = 0
   WinActivate ("Cookie Clicker Bot")


And also, if you guy's know it too, can you tell me how i can keep the window of the bot in front all the time while the website is starting?

I would really apreciate it if you guy's can help me.

Share this post

Link to post
Share on other sites

Problem is with your start func. When you press start, you enter start func and then enter while loop and newer get out of that loop. After you press stop you only set i=0 so "if" check is false but while loop is still runing. If you wanna play like this you have to go back to main program loop.

Share this post

Link to post
Share on other sites


Your previous thread asking the same question was locked - please read the Forum rules to which you were linked more carefully:


7. Do not repost the same question if the previous thread has been locked

Please do NOT repost the question a third time - our patience has limits.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites
This topic is now closed to further replies.