automatic Posted January 21, 2009 Share Posted January 21, 2009 hi all, i am writing a script where the script woud keep testing for the condition of the checkbox, perform a task when checkbox is CHECKED and vice versa. the problem i have encountered is that i have to CLICK on the checkbox for it to test for the condition of the checkbox. How can i make it so it will keep automatically check for the condition of the checkbox without the user clicking on it? my code is listed below, ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> _Main() Func _Main() Local $hGUI,$msg,$box1info Local $box1 ; Create GUI $hGUI = GUICreate("checkbox test", 150, 100) GUISetState() GuiCtrlCreateGroup("checkbox", 5, 5) $box1 = GUICtrlCreateCheckbox("checkbox1", 20, 60, 100) Do $msg = GUIGetMsg() Select case $msg = $box1 $box1info = guictrlread($box1) if $box1info = $GUI_CHECKED then run("notepad") sleep(500) send("x") elseif $box1info = $GUI_UNCHECKED then run("notepad") sleep(500) send(y) endif EndSelect Until GUIGetMsg() = $GUI_EVENT_CLOSE Endfunc Link to comment Share on other sites More sharing options...
KaFu Posted January 21, 2009 Share Posted January 21, 2009 (edited) But be careful, this way the script will open up notepad instances on and on... thats why i added a timerdiff check to limit execution to every 5 secs and set the gui to topmost ... expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> _Main() Func _Main() Local $hGUI, $msg, $box1info Local $box1 ; Create GUI $hGUI = GUICreate("checkbox test", 150, 100, Default, Default, Default, $WS_EX_TOPMOST) GUISetState() GUICtrlCreateGroup("checkbox", 5, 5) $box1 = GUICtrlCreateCheckbox("checkbox1", 20, 60, 100) $begin = TimerInit() Do $msg = GUIGetMsg() If TimerDiff($begin) > 5000 Then $begin = TimerInit() If GUICtrlRead($box1) = $GUI_CHECKED Then Run("notepad") Sleep(500) Send("x") ElseIf GUICtrlRead($box1) = $GUI_UNCHECKED Then Run("notepad") Sleep(500) Send("y") EndIf EndIf Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main Edited January 21, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
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