Quote:
Originally Posted by insteadof
Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Forsaken
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
GUICreate("Forsaken's Bot", 335, 100)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)
$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $startbutton
$send1 = GUICtrlRead($key1)
$sleep1 = GUICtrlRead($time1)
While 1
Send($send1)
Sleep($sleep1)
WEnd
Case $msg = $GUI_EVENT_CLOSE
GUIDelete()
ExitLoop
EndSelect
WEnd
how to make pause button and exit button ?
help :confused:
|
your script stucks in the 2nd while loop. to prevent such things, you should learn to use states.
you could simply set a variable which holds a "run" state. if run is true, the script will do some stuff. since you're allready in an endless loop, for scanning the gui events, you can put a simple if query.
if $run is true, then do your actions.
this will enable you to only set the $run variable, once the startbutton is called.
now that we've got a variable which is true or false, depending on the state the script is in currently, we can even modify the button to show us 'Start' or 'Stop', depending on the state.
if the actions are currently running, we wanna set the button label to Stop. if the script is not running ($run = False ( = 0 )), we set the button label to Start.
beside that, you should never use the sleep command in your script. it's way better to use timer functions, since sleep blocks your script.
once the script gets into sleep mode, no other commands will be applied. that means, that the gui won't get checked for events. (if you use a button the script won't get to know about it).
a reworked script could look like this:
Code:
Dim $timer, $run = False, $label[2]=['Start','Stop']
$gui = GUICreate("Forsaken's Bot", 335, 100)
GUISetState()
GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)
$button = GUICtrlCreateButton($label[$run], 190, 8, 60)
While 1
Switch GUIGetMsg()
Case -3
ExitLoop
Case $button
$run = Not $run
GUICtrlSetData($button, $label[$run])
$timer = 0
Case Else
If $run Then
If TimerDiff($timer) > GUICtrlRead($time1) And Not WinActive($gui) Then
Send(GUICtrlRead($key1))
$timer = TimerInit()
EndIf
EndIf
EndSwitch
WEnd