MPlb Posted August 12, 2009 Share Posted August 12, 2009 Is it possible to detect whether a check box is ticked or unticked? I am trying write something that launches an application (Outlook for example) and then displays a certain pages of that application that contains various options and see what options are ticked. Launching the app and getting to the relevant page is no problem. However, I can't work out how to reference the actual check box fields. Is this possible with AutoIt v3? Thanks Link to comment Share on other sites More sharing options...
BrettF Posted August 12, 2009 Share Posted August 12, 2009 (edited) I am assume this is an AutoIt GUI. The following does what you want in a basic manner. A quick flick through of the help file would have told you this. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 227, 78, 192, 124) $Checkbox1 = GUICtrlCreateCheckbox("Open Google", 8, 8, 210, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 8, 32, 210, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 8, 56, 210, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case GUICtrlRead ($Checkbox1) = $GUI_CHECKED MsgBox (0, "", "checked!") EndSelect WEnd There is a problem though! We'll get the message again and again! We have two options, one is to immediately uncheck the check box. But we may not want that so there is another way (one of several). #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $check1_state = False, $check2_state = False, $check3_state = False $Form1 = GUICreate("Form1", 227, 78, 192, 124) $Checkbox1 = GUICtrlCreateCheckbox("Open Google", 8, 8, 210, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 8, 32, 210, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 8, 56, 210, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case (GUICtrlRead ($Checkbox1) = $GUI_CHECKED) AND ($check1_state = False) $check1_state = True MsgBox (0, "", "checked!") Case GUICtrlRead ($Checkbox1) = $GUI_UNCHECKED $check1_state = False EndSelect WEnd If you are feeling adventurous you may even try using a dummy control. Cheers, Brett Edited August 12, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Yashied Posted August 12, 2009 Share Posted August 12, 2009 I think the OP was referring not AutoIt GUI. #Include <GUIButton.au3> $hWnd = ControlGetHandle('Mouse Properties', '', 'Button2') ConsoleWrite('Checked: ' & (_GUICtrlButton_GetCheck($hWnd) = $BST_CHECKED) & @CR) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
MPlb Posted August 12, 2009 Author Share Posted August 12, 2009 Thanks for the replies but I'm not talking about an AutoIT Gui. I'm wanting to check the state of check boxes on an application such as Outlook or Excel which I am launching with AutoIT. Link to comment Share on other sites More sharing options...
Yashied Posted August 12, 2009 Share Posted August 12, 2009 My example is not suitable for you? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
MPlb Posted August 12, 2009 Author Share Posted August 12, 2009 I'm just going to try it now... Link to comment Share on other sites More sharing options...
MPlb Posted August 12, 2009 Author Share Posted August 12, 2009 Hi Yashied That along with ControlCommand let me do exactly what I wanted. I also used the AU3Info utility to show me the information about the controls on the relevant windows. Thanks for the help... 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