13lack13lade Posted September 21, 2017 Share Posted September 21, 2017 Hi All! Feel like a noob here but im trying to get the status of a check box or just simply set it to checked. I have tried controlclick, controlcommand, without luck... i think it is due to only being able to select the checkbox by name... Here is the autoit window info: Link to comment Share on other sites More sharing options...
InnI Posted September 21, 2017 Share Posted September 21, 2017 (edited) 3 hours ago, 13lack13lade said: just simply set it to checked. I have tried controlclick Does this code really not work? WinActivate("Personal Options") ControlClick("Personal Options", "", "[NAME:chkShortPortfolios]") Also try this ControlSend("Personal Options", "", "[NAME:chkShortPortfolios]", "{space}") ; or ControlCommand("Personal Options", "", "[NAME:chkShortPortfolios]", "SendCommandID", 0xF5) ; $BM_CLICK Edited September 21, 2017 by InnI Link to comment Share on other sites More sharing options...
13lack13lade Posted September 21, 2017 Author Share Posted September 21, 2017 Hi Innl Thanks for your help! The only one that works is : ControlSend("Personal Options", "", "[NAME:chkShortPortfolios]", "{space}") and that is not viable as the checkbox might already be ticked in which case that would uncheck it. Link to comment Share on other sites More sharing options...
InnI Posted September 22, 2017 Share Posted September 22, 2017 #include "CUIAutomation2.au3" $Checked = _GetCheckBoxState(ControlGetHandle("Personal Options", "", "[NAME:chkShortPortfolios]")) If Not @error And Not $Checked Then ControlSend("Personal Options", "", "[NAME:chkShortPortfolios]", "{space}") Func _GetCheckBoxState($hControl) Local $oUIAutomation, $pElement, $oElement, $iState, $iErrorCode $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return SetError(1, 0, -1) $oUIAutomation.ElementFromHandle($hControl, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oElement) Then Return SetError(2, 0, -1) $iErrorCode = $oElement.GetCurrentPropertyValue($UIA_ToggleToggleStatePropertyId, $iState) If $iErrorCode Then Return SetError(3, 0, -1) Return $iState EndFunc 13lack13lade 1 Link to comment Share on other sites More sharing options...
SlackerAl Posted September 22, 2017 Share Posted September 22, 2017 (edited) Can this not be made to work with: If Not ControlCommand("Personal Options", "", "[NAME:chkShortPortfolios]", "IsChecked") Then ControlCommand("Personal Options", "", "[NAME:chkShortPortfolios]", "Check") EndIf Edit: Oops, need to add a NOT into that IsChecked Edited September 22, 2017 by SlackerAl Problem solving step 1: Write a simple, self-contained, running, replicator of your problem. Link to comment Share on other sites More sharing options...
13lack13lade Posted September 24, 2017 Author Share Posted September 24, 2017 Slacker, unfortunately that does not work as i cannot control the object using usual methods for some reason that is the whole dilemma. Fortunately InnI has provided a solution for me! - Thank you !!!! will be using this IUIAutomation in the future !!!!!! 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