Jump to content

ControlTreeView


Recommended Posts

Okay, I have tried everything (or at least I feel I have) I am trying to set some TaskBar and Start Menu settings... Below is my code. It's not de-selecting as it's supposed to.

_OpenTaskBarProperties()
WinWait("Taskbar and Start Menu Properties")
WinActivate("Taskbar and Start Menu Properties")
_ChangeTaskBarProperties()

; I use the function always to terminate to be
; always sure it's terminating where I want
; and expect it to. It also allows for possible
; cleanup when necessary.
_TerminateApp()

Func _TerminateApp()    
    Exit
EndFunc

Func _OpenTaskBarProperties()
    ; TODO: If it isn't an object update the log or GUI
    Local $obj_Shell
    
    $obj_Shell = ObjCreate("Shell.Application")
    If IsObj($obj_Shell) Then
        $obj_Shell.TrayProperties
    Else ; Error
    EndIf
EndFunc

Func _ChangeTaskBarProperties()
    ; TaskBar Properties title: Taskbar and Start Menu Properties
    
    ;Auto-hide the taskbar - CHECK
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1102) ; ClassnameNN = Button2
    ControlCommand("Taskbar and Start Menu Properties", "", "Button2", "Check", "")
    
    ;Hide inactive icons - UNCHECK
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1000) ; ClassnameNN = Button7
    ControlCommand("Taskbar and Start Menu Properties", "", "Button7", "UnCheck", "")
    
    ;Select Start Menu tab
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 12320, "left", 1, 70, 10) ; ClassnameNN = SysTabControl321
    ControlCommand("Taskbar and Start Menu Properties", "", "SysTabControl321", "TabRight", "")
    
    ;Classic Start Menu - CHECK
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1133) ; ClassnameNN = Button2
    ControlCommand("Taskbar and Start Menu Properties", "", "Button2", "Check", "")
    
    ;Customize... (The Classic Start Menu)
    ControlClick("Taskbar and Start Menu Properties", "", 1130) ; ClassnameNN = Button4
    
    ;Wait for Window to Exist and Activate
    ;This shouldn't be necessary, but is
    ;being added for longevity.
    WinWait("Customize Classic Start Menu")
    WinActivate("Customize Classic Start Menu")
    
    ;Use Personalized Menus - UNCHECK
    ;MsgBox(0, "Test", ControlTreeView("Customize Classic Start Menu", "", 1123, "GetItemCount", ""))
    ;MsgBox(0, "Test", ControlTreeView("Customize Classic Start Menu", "", 1123, "GetItemText", "#12"))
    ControlTreeView("Customize Classic Start Menu", "", 1123, "Uncheck", "Use Personalized Menus")
    
    ;Sort
    ;ControlClick("Customize Classic Start Menu", "", 1124) ; ClassnameNN = Button5
    
    ;Clear
    ;ControlClick("Customize Classic Start Menu", "", 1125) ; ClassnameNN = Button6
    
    ;OK
    ;ControlClick("Customize Classic Start Menu", "", 1) ; ClassnameNN = Button7
EndFunc

The above I would think would work, but it doesn't I have tried as stated above many items, and nothing is working. I have even tried selecting, checking, and unchecking the first item in the list, and it's not working.

Anyone have any advice? I know I could select item twelve, and then control click it, but that's dirty.

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Okay, I have tried everything (or at least I feel I have) I am trying to set some TaskBar and Start Menu settings... Below is my code. It's not de-selecting as it's supposed to.

CODE
_OpenTaskBarProperties()

WinWait("Taskbar and Start Menu Properties")

WinActivate("Taskbar and Start Menu Properties")

_ChangeTaskBarProperties()

; I use the function always to terminate to be

; always sure it's terminating where I want

; and expect it to. It also allows for possible

; cleanup when necessary.

_TerminateApp()

Func _TerminateApp()

Exit

EndFunc

Func _OpenTaskBarProperties()

; TODO: If it isn't an object update the log or GUI

Local $obj_Shell

$obj_Shell = ObjCreate("Shell.Application")

If IsObj($obj_Shell) Then

$obj_Shell.TrayProperties

Else ; Error

EndIf

EndFunc

Func _ChangeTaskBarProperties()

; TaskBar Properties title: Taskbar and Start Menu Properties

;Auto-hide the taskbar - CHECK

;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1102) ; ClassnameNN = Button2

ControlCommand("Taskbar and Start Menu Properties", "", "Button2", "Check", "")

;Hide inactive icons - UNCHECK

;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1000) ; ClassnameNN = Button7

ControlCommand("Taskbar and Start Menu Properties", "", "Button7", "UnCheck", "")

;Select Start Menu tab

;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 12320, "left", 1, 70, 10) ; ClassnameNN = SysTabControl321

ControlCommand("Taskbar and Start Menu Properties", "", "SysTabControl321", "TabRight", "")

;Classic Start Menu - CHECK

;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1133) ; ClassnameNN = Button2

ControlCommand("Taskbar and Start Menu Properties", "", "Button2", "Check", "")

;Customize... (The Classic Start Menu)

ControlClick("Taskbar and Start Menu Properties", "", 1130) ; ClassnameNN = Button4

;Wait for Window to Exist and Activate

;This shouldn't be necessary, but is

;being added for longevity.

WinWait("Customize Classic Start Menu")

WinActivate("Customize Classic Start Menu")

;Use Personalized Menus - UNCHECK

;MsgBox(0, "Test", ControlTreeView("Customize Classic Start Menu", "", 1123, "GetItemCount", ""))

;MsgBox(0, "Test", ControlTreeView("Customize Classic Start Menu", "", 1123, "GetItemText", "#12"))

ControlTreeView("Customize Classic Start Menu", "", 1123, "Uncheck", "Use Personalized Menus")

;Sort

;ControlClick("Customize Classic Start Menu", "", 1124) ; ClassnameNN = Button5

;Clear

;ControlClick("Customize Classic Start Menu", "", 1125) ; ClassnameNN = Button6

;OK

;ControlClick("Customize Classic Start Menu", "", 1) ; ClassnameNN = Button7

EndFunc

The above I would think would work, but it doesn't I have tried as stated above many items, and nothing is working. I have even tried selecting, checking, and unchecking the first item in the list, and it's not working.

Anyone have any advice? I know I could select item twelve, and then control click it, but that's dirty.

Thanks,

Jarvis

Try it like this:
$hWin = _OpenTaskBarProperties()
_ChangeTaskBarProperties($hWin, "AutoHide", 1)
Sleep(2000)
_ChangeTaskBarProperties($hWin, "AutoHide", 0)

Func _OpenTaskBarProperties()
    Local $sWinTitle = "[CLASS:#32770; TITLE:Taskbar and Start Menu Properties]"
    Local $obj_Shell = ObjCreate("Shell.Application")
    $obj_Shell.TrayProperties
    WinWait($sWinTitle)
    Return WinGetHandle($sWinTitle)
EndFunc

Func _ChangeTaskBarProperties($hWND, $sProp, $f_Check)
    Local $sCtrlID
    
; Set the command string
    Local $sCmnd = "UnCheck"
    If $f_Check Then $sCmnd = "Check"
    
; Pick the button to change
    Switch $sProp
        Case "LockTaskbar"
        ; Not written yet...
            
        Case "AutoHide"
            Local $sCtrlID = "[CLASS:Button; INSTANCE:2]"
        
        Case "Etc., Etc., Etc."
        ; Not written yet...
    EndSwitch
    
; Make the change
    ControlCommand($hWND, "", $sCtrlID, $sCmnd)
EndFunc

Just fill in more cases to select the $sCtrlID string for the right button (only Auto-Hide Taskbar works in the demo).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Try it like this:

$hWin = _OpenTaskBarProperties()
_ChangeTaskBarProperties($hWin, "AutoHide", 1)
Sleep(2000)
_ChangeTaskBarProperties($hWin, "AutoHide", 0)

Func _OpenTaskBarProperties()
    Local $sWinTitle = "[CLASS:#32770; TITLE:Taskbar and Start Menu Properties]"
    Local $obj_Shell = ObjCreate("Shell.Application")
    $obj_Shell.TrayProperties
    WinWait($sWinTitle)
    Return WinGetHandle($sWinTitle)
EndFunc

Func _ChangeTaskBarProperties($hWND, $sProp, $f_Check)
    Local $sCtrlID
    
; Set the command string
    Local $sCmnd = "UnCheck"
    If $f_Check Then $sCmnd = "Check"
    
; Pick the button to change
    Switch $sProp
        Case "LockTaskbar"
; Not written yet...
            
        Case "AutoHide"
            Local $sCtrlID = "[CLASS:Button; INSTANCE:2]"
        
        Case "Etc., Etc., Etc."
; Not written yet...
    EndSwitch
    
; Make the change
    ControlCommand($hWND, "", $sCtrlID, $sCmnd)
EndFunc

Just fill in more cases to select the $sCtrlID string for the right button (only Auto-Hide Taskbar works in the demo).

:)

I love the method you're using there, however, that doesn't solve my problem. Those items are working great. It's once I get to the classic start menu configuration is where I run into problems. It was with the TreeView control that I had an issue selecting and checking the items necessary. I am fine selecting and checking the boxes on the taskbar properties window as that works perfectly everytime for me.

Edit 01: Clarification

Thanks,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I love the method you're using there, however, that doesn't solve my problem. Those items are working great. It's once I get to the classic start menu configuration is where I run into problems. It was with the TreeView control that I had an issue selecting and checking the items necessary. I am fine selecting and checking the boxes on the taskbar properties window as that works perfectly everytime for me.

Edit 01: Clarification

Thanks,

Jarvis

The code you posted only opens the TaskBar Dialog and makes changes there.

If you want to operate on the Start Menu tab, use _GuiCtrlTab_ClickTab() to select the Start Menu tab, then ControlClick() the button for Classic start menu, then again for customize. Get the handle to the new Customize Classic Start Menu window, and then the handle to the TreeView.

Once you get that far, post what you tried to check the boxes. Then your code will match what you're talking about.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The code you posted only opens the TaskBar Dialog and makes changes there.

If you want to operate on the Start Menu tab, use _GuiCtrlTab_ClickTab() to select the Start Menu tab, then ControlClick() the button for Classic start menu, then again for customize. Get the handle to the new Customize Classic Start Menu window, and then the handle to the TreeView.

Once you get that far, post what you tried to check the boxes. Then your code will match what you're talking about.

:)

Please re-check my first post, and notice that the code in there from line 109 (viewable below...)

;Select Start Menu tab
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 12320, "left", 1, 70, 10) ; ClassnameNN = SysTabControl321
    ControlCommand("Taskbar and Start Menu Properties", "", "SysTabControl321", "TabRight", "")
    
    ;Classic Start Menu - CHECK
    ;Alternate: ControlClick("Taskbar and Start Menu Properties", "", 1133) ; ClassnameNN = Button2
    ControlCommand("Taskbar and Start Menu Properties", "", "Button2", "Check", "")
    
    ;Customize... (The Classic Start Menu)
    ControlClick("Taskbar and Start Menu Properties", "", 1130) ; ClassnameNN = Button4
    
    ;Wait for Window to Exist and Activate
    ;This shouldn't be necessary, but is
    ;being added for longevity.
    WinWait("Customize Classic Start Menu")
    WinActivate("Customize Classic Start Menu")
    
    ;Use Personalized Menus - UNCHECK
    ;MsgBox(0, "Test", ControlTreeView("Customize Classic Start Menu", "", 1123, "GetItemCount", ""))
    ControlTreeView("Customize Classic Start Menu", "", 1123, "Uncheck", "Use Personalized Menus")

You will notice I...

"RightTab" (that works)

"Check" the classic styel (that works)

"Click Customize" (that works)

Await the arrival of the window with the title of it. (that works)

Now is where the problem lies...I want to uncheck the "Use Personalized Menus" item in the tree view on that next window. If you would have ran the script on a Windows XP box it would have gotten there and showed you that. I didn't supply my full script just for my benefit.

Now that you know where I am at any tips or suggestions would be more than welcome, and I again appreciate your first set of code as I love learning new ways to do the same thing because sometimes there are better ways to skin the cat.

Edit 01: Just for arguments sake, you can even check that I haven't edited the first post. :)

Thanks,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Please re-check my first post, and notice that the code in there from line 109 (viewable below...)

You will notice I...

"RightTab" (that works)

"Check" the classic styel (that works)

"Click Customize" (that works)

Await the arrival of the window with the title of it. (that works)

Now is where the problem lies...I want to uncheck the "Use Personalized Menus" item in the tree view on that next window. If you would have ran the script on a Windows XP box it would have gotten there and showed you that. I didn't supply my full script just for my benefit.

Now that you know where I am at any tips or suggestions would be more than welcome, and I again appreciate your first set of code as I love learning new ways to do the same thing because sometimes there are better ways to skin the cat.

Edit 01: Just for arguments sake, you can even check that I haven't edited the first post. :)

Thanks,

Jarvis

You're right, I didn't read down that far. I NEVER run code from the forum that will make changes to my machine, but I should have looked closer before mouthing off. My bad.

The next step is to get the handle and try the GuiTreeView.au3 UDF functions on it, as Zedna already said.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

1) Try just ControlTreeView("Customize Classic Start Menu", "", 1123, "Exists", "Use Personalized Menus") what it returns

2) Try "SysTreeView321" instead of 1123

3) Try to use ControlGetHandle() + _GUICtrlTreeView_SetChecked() instead of  ControlTreeView()

Zedna,

Thanks for the pointers. I will let you know how they turn out.

1) Returns 1

2) Have tried both. They work interchangeably.

3) Tried it, but I don't know the handle to the tree item. I assumed it was #12 as shown in my code.

$h_TreeView = ControlGetHandle("Customize Classic Start Menu", "", "SysTreeView321")
    _GUICtrlTreeView_SetChecked($h_TreeView, "#12", False)
Please let me know how I can go about obtaining the handle of an item in the list.

Thanks,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

$h_TreeView = ControlGetHandle("Customize Classic Start Menu", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItem($h_TreeView, "Use Personalized Menus")
_GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
Thanks for the quick reply, but no go. It didn't work.

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Thanks for the quick reply, but no go. It didn't work.

Thanks,

Jarvis

Then try to specify absolute treeview path:

Opt("GUIDataSeparatorChar", "\")

$h_TreeView = ControlGetHandle("Customize Classic Start Menu", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItemEx($h_TreeView, "First level Name\Use Personalized Menus")
_GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
Link to comment
Share on other sites

Then try to specify absolute treeview path:

Opt("GUIDataSeparatorChar", "\")

$h_TreeView = ControlGetHandle("Customize Classic Start Menu", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItemEx($h_TreeView, "First level Name\Use Personalized Menus")
_GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
It is one of the root items. I have already tried that route. There are no "root" items to it. The way I counted this was to get the count of the root. There are 13 root items, and there are no child items of any of them. Use Personalized Menus is item number 13 so to access you can alternately use #12 in the ControlTreeView() function.

Have any other tricks up your sleeve? Also, keep in mind that anyone with Windows XP Pro can check this system setting out, and try to script it.

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Have any other tricks up your sleeve? Also, keep in mind that anyone with Windows XP Pro can check this system setting out, and try to script it.

Thanks,

Jarvis

You are right. I tested it on my Czech WINXP and code looks good but no checked/unchecked state change :-(

#include <GUITreeView.au3>

;~ Opt("GUIDataSeparatorChar", "\")

WinActivate("Vlastní nastavení klasické nabídky Start", "")

$h_TreeView = ControlGetHandle("Vlastní nastavení klasické nabídky Start", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItem($h_TreeView, "Používat individuální nabídky")
ConsoleWrite($hitem & @CRLF) ; return good handle
$ret = _GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
ConsoleWrite($ret & @CRLF) ; returns True (success)

;~ ControlTreeView("Customize Classic Start Menu", "", 1123, "Uncheck", "Use Personalized Menus")

It might be some BUG in GUITreeView UDF...

EDIT:

1) _GUICtrlTreeView_GetChecked($h_TreeView, $hitem) doesn't work either

2) _GUICtrlTreeView_ClickItem($h_TreeView, $hitem) works fine --> changes checked status to opposite one

Edited by Zedna
Link to comment
Share on other sites

You are right. I tested it on my Czech WINXP and code looks good but no checked/unchecked state change :-(

#include <GUITreeView.au3>

;~ Opt("GUIDataSeparatorChar", "\")

WinActivate("Vlastní nastavení klasické nabídky Start", "")

$h_TreeView = ControlGetHandle("Vlastní nastavení klasické nabídky Start", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItem($h_TreeView, "Pouívat individuální nabídky")
ConsoleWrite($hitem & @CRLF) ; return good handle
$ret = _GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
ConsoleWrite($ret & @CRLF) ; returns True (success)

;~ ControlTreeView("Customize Classic Start Menu", "", 1123, "Uncheck", "Use Personalized Menus")

It might be some BUG in GUITreeView UDF...

EDIT:

1) _GUICtrlTreeView_GetChecked($h_TreeView, $hitem) doesn't work either

2) _GUICtrlTreeView_ClickItem($h_TreeView, $hitem) works fine --> changes checked status to opposite one

Zedna, thanks for trying it on your system. I suppose the UDF could be messed up, but also the ControlTreeView seemingly is messed up as it doesn't work either, and it should be accessing the same API. So I can use the ClickItem as it is always checked upon startup, but that doesn't help that I would like to make a GUI that also checks the status of all the little settings I am wanting to change to be sure they are all made. This would allow me to allow them to undo changes, or re-make changes individually if one item doesn't show up properly.

Thanks for the additional assistance. If you are able to get anything else working please let me know!

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

It's something strange.

If I test it on my own (external) treeview app it works fine (GetChecked/SetChecked):

http://www.autoitscript.com/forum/index.php?showtopic=18409

treeview_item_state_example.au3

#include <GUITreeView.au3>

$h_TreeView = ControlGetHandle("Treeview item state", "", "SysTreeView321")
$hitem = _GUICtrlTreeView_FindItem($h_TreeView, "Item 2")
ConsoleWrite($hitem & @CRLF); return good handle
$ret = _GUICtrlTreeView_SetChecked($h_TreeView, $hitem, False)
;~ $ret = _GUICtrlTreeView_GetChecked($h_TreeView, $hitem)
Link to comment
Share on other sites

So would this be something that needs to be reported to the Devs in the form of a bug?

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I have heard that some ListView/TreeView controls have their data not directly in it but in some other memory.

Maybe Gary can tell more ...

Question is, how to get Gary over here to take a peak?

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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...