Sign in to follow this  
Followers 0
dantay9

[Solved] Check TreeView Box

3 posts in this topic

#1 ·  Posted (edited)

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

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I'll remember that when I have trouble next time. Thanks a bunch.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0