mar3011 Posted August 8, 2018 Posted August 8, 2018 I have a problem, I want the function :send key in loop to be activated when the checkbox is selected and when the check box is turned off, the function turns off. I tried and only one checkbox works after selecting the second checkbox is flashing and cant be unchecked. I have looked through the entire forum and there is no such topic anywhere code expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> #include <MsgBoxConstants.au3> #include<Date.au3> #include <DateTimeConstants.au3> #include <InetConstants.au3> #include <WinAPIFiles.au3> #RequireAdmin Global $Paused HotKeySet("{f9}", "TogglePause") Opt("GUIOnEventMode", 1) $Form1 = GUICreate("test)", 269, 165, 228, 373) Local $Checkbox1 = GUICtrlCreateCheckbox("", 240, 24, 17, 17) GUICtrlSetOnEvent($Checkbox1,"test1") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 240, 48, 17, 17) GUICtrlSetOnEvent($Checkbox2,"test2") #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) global $start1 = 0 Lglobal $start2=0 While 1 if GUICtrlRead($Checkbox2)= 1 Then Send( "{f1}" ) EndIf if GUICtrlRead($Checkbox1)= 1 Then Send( "{f2}" ) EndIf WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused = SCRIPT IS NOT RUNNING = you wont get another message if you dont unpause it"',0,0) WEnd ToolTip("") EndFunc Func test1() $start1 =1 EndFunc Func test2() $start2=1 EndFunc Func _Exit() Exit EndFunc
LisHawj Posted August 9, 2018 Posted August 9, 2018 (edited) Works fine for me. I can check and uncheck both checkboxes without any issues. You did misspell the line at "Global start2 = 0". expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <DateTimeConstants.au3> #include <InetConstants.au3> #include <WinAPIFiles.au3> #RequireAdmin Global $Paused HotKeySet("{f9}", "TogglePause") Opt("GUIOnEventMode", 1) $Form1 = GUICreate("test)", 269, 165, 228, 373) Local $Checkbox1 = GUICtrlCreateCheckbox("", 240, 24, 17, 17) GUICtrlSetOnEvent($Checkbox1, "test1") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 240, 48, 17, 17) GUICtrlSetOnEvent($Checkbox2, "test2") #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) Global $start1 = 0 Global $start2 = 0 While 1 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then Send("{f1}") Msgbox(0,"", "2nd checkbox is checked.", 1) EndIf If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Send("{f2}") Msgbox(0,"", "1st checkbox is checked.", 1) EndIf WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused = SCRIPT IS NOT RUNNING = you wont get another message if you dont unpause it"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func test1() $start1 = 1 EndFunc ;==>test1 Func test2() $start2 = 1 EndFunc ;==>test2 Func _Exit() Exit EndFunc ;==>_Exit Edited August 9, 2018 by LisHawj
mar3011 Posted August 9, 2018 Author Posted August 9, 2018 On 8/9/2018 at 2:45 AM, LisHawj said: Works fine for me. I can check and uncheck both checkboxes without any issues. You did misspell the line at "Global start2 = 0". expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <DateTimeConstants.au3> #include <InetConstants.au3> #include <WinAPIFiles.au3> #RequireAdmin Global $Paused HotKeySet("{f9}", "TogglePause") Opt("GUIOnEventMode", 1) $Form1 = GUICreate("test)", 269, 165, 228, 373) Local $Checkbox1 = GUICtrlCreateCheckbox("", 240, 24, 17, 17) GUICtrlSetOnEvent($Checkbox1, "test1") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 240, 48, 17, 17) GUICtrlSetOnEvent($Checkbox2, "test2") #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) Global $start1 = 0 Global $start2 = 0 While 1 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then Send("{f1}") Msgbox(0,"", "2nd checkbox is checked.", 1) EndIf If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Send("{f2}") Msgbox(0,"", "1st checkbox is checked.", 1) EndIf WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused = SCRIPT IS NOT RUNNING = you wont get another message if you dont unpause it"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func test1() $start1 = 1 EndFunc ;==>test1 Func test2() $start2 = 1 EndFunc ;==>test2 Func _Exit() Exit EndFunc ;==>_Exit Expand thank you
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now