seamonkeysproject, I think this script runs as you wish - the buttons toggle the various "Send" processes as you press them. Look in the SciTE console to see what is happening - i have slowed the whole thing down so that you can see each keypress and Send action as the script runs. Note that I have kept the loop in the main part of the script - that way all your buttons remain active and you do not have to break into the functions as each one just toggles a flag and returns to the main loop: #include <GUIConstantsEx.au3>
; Create some flags to show whether to run a certain process
Global $fActivated = False
Global $fSend1 = False
Global $fSend2 = False
HotKeySet("{F3}", "exitthescript")
$Form2 = GUICreate("Form2", 405, 294, 391, 270)
$Button1 = GUICtrlCreateButton("activate", 128, 64, 131, 25)
$Button2 = GUICtrlCreateButton("send1", 136, 96, 115, 25)
GUICtrlSetState($Button2, $GUI_DISABLE) ; Disable this button
$Button3 = GUICtrlCreateButton("send2", 136, 136, 115, 25)
GUICtrlSetState($Button3, $GUI_DISABLE) ; Disable this button
$Button4 = GUICtrlCreateButton("pause", 120, 176, 147, 25)
GUICtrlSetState($Button4, $GUI_DISABLE) ; Disable this button
$Button5 = GUICtrlCreateButton("exit", 120, 224, 147, 25)
GUISetState(@SW_SHOW)
$iBegin = TimerInit() ; This is just for testing to slow down the process so you can see what is happening
While 1
; Here we look for button presses
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $Button5 ; Notice you can have more than 1 control per case
exitthescript()
Case $Button1
; Change the button states
GUICtrlSetState($Button1, $GUI_DISABLE) ; Disable this button
GUICtrlSetState($Button2, $GUI_ENABLE) ; Enable the send1 button
GUICtrlSetState($Button3, $GUI_ENABLE) ; Enable the send2 button
GUICtrlSetState($Button4, $GUI_ENABLE) ; Enable the pause/resume button
ContinueCase ; This means run the next case down - so we toggle the Main flag
Case $Button4
pause_resume() ; Toggle the Main flag
Case $Button2
send1() ; Toggle the Send1 flag
Case $Button3
send2() ; Toggle the Send2 flag
EndSwitch
If TimerDiff($iBegin) > 1000 Then ; This is just for testing to slow down the process so you can see what is happening
; Here we see if the Mian process is activated
If $fActivated Then
ConsoleWrite("Main Send sending keys" & @CRLF)
; now check on the 2 Send processes
If $fSend1 Then
ConsoleWrite("Send1 sending keys" & @CRLF)
EndIf
If $fSend2 Then
ConsoleWrite("Send2 sending keys" & @CRLF)
EndIf
EndIf
$iBegin = TimerInit() ; This is just for testing to slow down the process so you can see what is happening
EndIf ; This is just for testing to slow down the process so you can see what is happening
WEnd
Func send1()
; Toggle the Send1 flag
$fSend1 = Not $fSend1
; This is just for testing so that you can see what is happening
If $fSend1 Then
ConsoleWrite("+Send1 running" & @CRLF)
Else
ConsoleWrite("!Send1 paused" & @CRLF)
EndIf
EndFunc ;==>send1
Func send2()
; Toggle the Send2 flag
$fSend2 = Not $fSend2
; This is just for testing so that you can see what is happening
If $fSend2 Then
ConsoleWrite("+Send2 running" & @CRLF)
Else
ConsoleWrite("!Send2 paused" & @CRLF)
EndIf
EndFunc ;==>send2
Func pause_resume()
; Toggle the Main flag
$fActivated = Not $fActivated
; We need this If structure to change the button text
If $fActivated Then
GUICtrlSetData($Button4, "Pause")
ConsoleWrite("+Main process running" & @CRLF) ; But this is just for testing
Else
GUICtrlSetData($Button4, "Resume")
ConsoleWrite("!Main process paused" & @CRLF) ; But this is just for testing
EndIf
EndFunc ;==>pause/resume
Func exitthescript()
Exit
EndFunc ;==>exitthescriptI have changed a lot from your script. Read the comments carefully and ask if you do not understand what I have done or why I have done it. M23