Jump to content

[Solved] Check TreeView Box


Recommended Posts

I am trying to automate the setup for my computer after I recover it. This includes changing the system properties to maximize the speed of my computer. My code will get me to the correct screen, but I can't check any of the boxes in the treeview. I tried to use ControlTreeView but it wouldn't work. I need help checking the boxes. Thanks in advance!

If WinExists("System Properties") Then WinKill("System Properties")
 Send("{LWINDOWN}")
 Send("{PAUSE}")
 Send("{LWINUP}")
 WinWait("System Properties")
 Sleep(100)
 WinActivate("System Properties")
 ControlCommand("System Properties", "", 12320, "TabRight", "")
 Sleep(100)
 ControlCommand("System Properties", "", 12320, "TabRight", "")
 Sleep(100)
 ControlCommand("System Properties", "", 12320, "TabRight", "")
 Sleep(100)
 ControlClick("System Properties", "", 110)
 WinWait("Performance Options")
 Sleep(100)
 WinActivate("Performance Options")
 Sleep(100)
 $TreeHandle = ControlGetHandle("Performance Options", "", 2020)
Edited by dantay9
Link to comment
Share on other sites

This is a start for you. Note that some Treeview UDFs do not work logically with M$ windows.

TraySetState()
#include <GuiTreeView.au3>

If WinExists("System Properties") Then WinKill("System Properties")
Send("{LWINDOWN}")
Send("{PAUSE}")
Send("{LWINUP}")
WinWait("System Properties")
Sleep(100)
WinActivate("System Properties")
ControlCommand("System Properties", "", 12320, "TabRight", "")
Sleep(100)
ControlCommand("System Properties", "", 12320, "TabRight", "")
Sleep(100)
ControlCommand("System Properties", "", 12320, "TabRight", "")
Sleep(100)
ControlClick("System Properties", "", 110)
WinWait("Performance Options")
Sleep(100)
WinActivate("Performance Options")
Sleep(100)

$hTreeView = ControlGetHandle('Performance Options', '', 'SysTreeView321')

Navigate($hTreeView, 'Slide taskbar buttons', 1) ;check slide taskbar buttons
Navigate($hTreeView, 'slide open combo', 0) ;uncheck slide open combo boxes
Navigate($hTreeView, 'animate', 0) ;uncheck Animate windows when minimizing and maximizing

;When you're ready to commit changes, uncomment the next line
;If WinWait("Performance Options", "", 3) Then ControlClick("Performance Options", "", "Button5")

Func Navigate($Handle, $Control, $Check = 0) ;$Check 0 = Uncheck, 1 = Check
    ;True Flag means $Control anywhere in the Treeview's string, like WinTitleMatchMode 2
    Local $hItem = _GUICtrlTreeView_FindItem($Handle, $Control, True, 0)
    If $hItem Then
        ;had to use GetImageIndex instead of GetChecked because the latter does not work consistenly with M$ windows
        Switch _GUICtrlTreeView_GetImageIndex($Handle, $hItem)
            ;item is checked...this is actually backwards from logic, but Treeview UDFs have issues
            Case 0
                ;unchecks item if $Check flag is set to 0
                If Not $Check Then _GUICtrlTreeView_ClickItem($Handle, $hItem, 'left', False, 1)
            ;item is not checked...this is actually backwards from logic, but Treeview UDFs have issues
            Case 1
                ;checks item if $Check flag is set to 1
                If $Check Then _GUICtrlTreeView_ClickItem($Handle, $hItem, 'left', False, 1)
        EndSwitch
    Else
        MsgBox(0, 'Error', 'Cannot Find ' & $Control)
    EndIf
EndFunc   ;==>Navigate
Edited by Varian
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...