Jump to content

Can't press button twice


Silas
 Share

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)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $start
            Start()
         Case $Internet
            Internet()
    EndSwitch
WEnd

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

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

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

 

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.

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

Link to comment
Share on other sites

  • Moderators

Silas,

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

Quote

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.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

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...