Jump to content

Automating "Treeview" checkbox


loglorry
 Share

Recommended Posts

Dear Board

Sorry for the newbie question I'm new to autoit. I want to automate turning on a particular taskbar toolbar:-

Run ("rundll32.exe shell32.dll,Options_RunDLL 1", "", @SW_HIDE)
WinWaitActive ( "Taskbar and Start Menu Properties")
WinActivate ( "Taskbar and Start Menu Properties")
Send("^{TAB 3}")

This script is pretty close to what I want to do. It displays a list of checkboxes and I want to search for a particular one "by name" and set it (not toggle it) (see picture attached).

Unfortunately the control is not a simple list of checkboxes. I used AutiIt Window Info tool and discovered the controls are all in a type ofSysTreeView32 see below:

>>>> Control <<<<

Class: SysTreeView32

Instance: 1

ClassnameNN: SysTreeView321

ID: 1137

Text: DeskBandList

Position: 21, 62

Size: 354, 260

ControlClick Coords: 232, 148

Style: 0x50010000

ExStyle: 0x00000204

Is there a way to control these checkboxes ?

post-29039-1194885471_thumb.gif

Link to comment
Share on other sites

  • Moderators

You could see if ControlCommand() has what you want... and if it works.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

No ControlCommand seems to only work with listbox, editbox, checkbox etc. etc. but not this treeview type control

Did you try it?

Also, there are other Control functions, including a treeview one.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Download latest beta and look into helpfile at

User Defined Function Reference/GUITreeView Management

There are lots of usefull functions like:

_GUICtrlTreeView_FindItem

_GUICtrlTreeView_GetText

_GUICtrlTreeView_SelectItem

_GUICtrlTreeView_SetChecked

...

You may also look at ControlTreeView()

EDIT: ControlCommand really doesn't work wit TreeView

Edited by Zedna
Link to comment
Share on other sites

Download latest beta and look into helpfile at

User Defined Function Reference/GUITreeView Management

There are lots of usefull functions like:

_GUICtrlTreeView_FindItem

_GUICtrlTreeView_GetText

_GUICtrlTreeView_SelectItem

_GUICtrlTreeView_SetChecked

...

You may also look at ControlTreeView()

EDIT: ControlCommand really doesn't work wit TreeView

Thanks from my understanding of the documentation this should work :-

Run ("rundll32.exe shell32.dll,Options_RunDLL 1", "", @SW_HIDE)
WinWaitActive ( "Taskbar and Start Menu Properties")
WinActivate ( "Taskbar and Start Menu Properties")
Send("^{TAB 3}")


ControlTreeView( "Taskbar and Start Menu Properties", "", "[ID:1137]", "Check", "Links")

Alas it does not :-(

The control seems to be ID:1137 so that should have worked.

Link to comment
Share on other sites

Okay cool I guess I could of wrote that more clear but you got exactly what I ment. Anyway how do I get TreeNode Handles? I have Winspector Spy but it doesn't reveal this it only shows the ID of the Systreeview.

Edited by mbkowns
Link to comment
Share on other sites

  • 5 months later...

;you should
#Include <GuiTreeView.au3>
;replace "Window Title" and ID with the appropriate values
$hSTV = ControlGetHandle("Window Title", "", ID)

;to find the search text in the item string (partial text search vs. exact match) set to true
$fInStr = True

;get the handles for two items, replace the search text with the appropriate text for your items
$hFirst = _GUICtrlTreeView_FindItem($hSTV, "search text1", $fInStr)
$hSecond = _GUICtrlTreeView_FindItem($hSTV, "search text2", $fInStr)

;if false unchecks the items, if true checks the items
$fCheck = False

;change the items checked/unchecked status
_GUICtrlTreeView_SetChecked($hSTV, $hFirst, $fCheck)
_GUICtrlTreeView_SetChecked($hSTV, $hSecond, $fCheck)

Now if someone would tell me why @#$$@! @$#%#% @!#(*)@$&! $@) /me colapses

$currsel = ControlTreeView("Window title", "Window Text", ID, "IsChecked", "#1")

works and returns the proper value, yet

ControlTreeView("Window title", "Window Text", ID, "Check", "#1")

does nothing more than select the item ?!

I might know why/if i had to learn the answer to mbkowns's question on my second day of using autoit

Edited by Twisten
Link to comment
Share on other sites

oh, never mind about my answer - it looks like its working but the parent window dosen't remember the changes :)

looks like its back to the drawing board. why oh why couldn't ControlTreeView's "Check" command just work

Link to comment
Share on other sites

so after reading through the ginormous amount of posts conserning this very problem in several variation the conclution is that the autoit functions do exactly as they're suppose to but not as they are expected to!

some cause the gui to refresh and display the unchecked / checked checkbox and all change its state to unchecked.

(UDF and ControlTreeView).

the expected result (especialy expected when using controltreeview) isn't accomplished the parent window dosen't seem to get the proper message that there was a state change and takes no notice of the checkbox.

the solution i compromised on until someone with enough know how will write a short 'how to' for this, is to use controltreeview to select the checkbox that send a keyboard stroke (space) to the tree control, this produces the expected result since the parent window takes notice of the keyboard event.

as an aside, i've also tried using control click with the tree item handle, which reports success but dosen't produce the end result. not sure if its because the tree items have handles but no IDs or some other reason, maybe that 'someone' :( mentioned before will also be able to explain this :)

anyhow i hope this helps.

Edited by Twisten
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...