lakshmi10 Posted July 17, 2008 Share Posted July 17, 2008 Hi,I am writing scripts to automate a .Net Windows based application. In the application i need to verify whether a checkbox is selected or not (i.e. need to get the state of a checkbox). I used the below mentioned code snippets. Everytime the message "Not Checked" is displayed irrespective whether the checkbox is selected or not.; Using GUICtrlRead#include <GUIConstants.au3>$hndl = WinGetHandle(WinGetTitle("Test",""),"")WinActivate($hndl,"")$chndl = ControlGetHandle($hndl,"","WindowsForms10.BUTTON.app.0.21af1a517")if BitAnd(GUICtrlRead($chndl),$GUI_CHECKED) = $GUI_CHECKED then MsgBox(1, "Status", "Checked")else MsgBox(1, "Status", "Not Checked")endif;Using _SendMessage FunctionGlobal Const $BM_GETSTATE = 0xF0$hndl = WinGetHandle(WinGetTitle("Test",""),"")WinActivate($hndl,"")$chndl = ControlGetHandle($hndl,"","WindowsForms10.BUTTON.app.0.21af1a517")$chkstat = _SendMessage($chndl, $BM_GETSTATE, 0, 0)if $chkstat= 0 then MsgBox(1, "Status", "Not checked")else MsgBox(1, "Status", "Checked")endif;Using ControlCommand Function$hndl = WinGetHandle(WinGetTitle("Test",""),"")WinActivate($hndl,"")$chndl = ControlGetHandle($hndl,"","WindowsForms10.BUTTON.app.0.21af1a517")$chkstat= ControlCommand($hndl,"",$chndl ,"IsChecked")if $chkstat= 0 then MsgBox(1, "Status", "Not checked")else MsgBox(1, "Status", "Checked")endifPlease let me know what is wrong in the above mentioned code snippets or let me know if you have any alternative solution.Thanks in advance. Link to comment Share on other sites More sharing options...
dmob Posted July 17, 2008 Share Posted July 17, 2008 Afaik GUICtrlRead and ControlCommand work with the ControlID, not the control handle, but I may be wrong. 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