Jump to content

Check Checkbox by Name


Recommended Posts

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 by InnI
Link to comment
Share on other sites

#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

 

Link to comment
Share on other sites

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 by SlackerAl

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...