Klaatu Posted November 27, 2007 Share Posted November 27, 2007 Trying to interact with the treeview control on Explorer's Tools/Options... dialog: #include <GuiTreeView.au3> $hWnd = ControlGetHandle('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]') $c = _GUICtrlTreeView_GetCount($hWnd) $d = _GUICtrlTreeView_FindItem($hWnd, 'Hide extensions for known file types', False, 0) If $d Then $e = _GUICtrlTreeView_GetText($hWnd, $d) $f = _GUICtrlTreeView_SetChecked($hWnd, $d, True) EndIf Here's the output of my DebugIt program: 0001: #include <GuiTreeView.au3> 0003: $hWnd = ControlGetHandle('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]') : ... $hWnd = 0x002A0AB2 0004: $c = _GUICtrlTreeView_GetCount($hWnd) : ... $c = 24 : ... $hWnd = 0x002A0AB2 0005: $d = _GUICtrlTreeView_FindItem($hWnd, 'Hide extensions for known file types', False, 0) : ... $d = 0x02AE7CF8 : ... $hWnd = 0x002A0AB2 0006: If $d Then : ... $d = 0x02AE7CF8 0007: $e = _GUICtrlTreeView_GetText($hWnd, $d) : ... $e = 'Hide extensions for known file types' : ... $hWnd = 0x002A0AB2 : ... $d = 0x02AE7CF8 0008: $f = _GUICtrlTreeView_SetChecked($hWnd, $d, True) : ... $f = True : ... $hWnd = 0x002A0AB2 : ... $d = 0x02AE7CF8 0009: EndIf So, the function in question is returning true, indicating success, yet when I look at the dialog still up on my screen, the item does not show a checkmark in it like I would expect. Is it broken, or, more likely, what am I doing wrong? My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
Klaatu Posted November 27, 2007 Author Share Posted November 27, 2007 Well, it looks like it's probably not _GUICtrlTreeView_SetChecked, and on a positive note it looks like it's probably not me either! I just noticed that 3.2.10.0 has a ControlTreeView command that it didn't before, so I tried using that instead:$hWnd = ControlGetHandle('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]') $c = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','GetItemCount', '#0') $d = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','IsChecked','#0|Hide extensions for known file types')And again the debug output:0001: $hWnd = ControlGetHandle('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]') : ... $hWnd = 0x002A0DE6 0002: $c = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','GetItemCount', '#0') : ... $c = 18 0003: $d = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','IsChecked','#0|Hide extensions for known file types') : ... $d = -1So, 'IsChecked' is returning -1, indicating that this item is not a checkbox, even though we can clearly see in the dialog box a series of checkboxes for the different items. So I would assume that _GUICtrlTreeView_SetChecked is finding the same thing. It must be a Microsoft trick!Still, the problem exists of how to interact with these checkboxes, but it doesn't appear that _GUICtrlTreeView_SetChecked is the culprit in this instance. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
Bowmore Posted November 27, 2007 Share Posted November 27, 2007 Well, it looks like it's probably not _GUICtrlTreeView_SetChecked, and on a positive note it looks like it's probably not me either! I just noticed that 3.2.10.0 has a ControlTreeView command that it didn't before, so I tried using that instead: $hWnd = ControlGetHandle('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]') $c = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','GetItemCount', '#0') $d = ControlTreeView('Folder Options','','[CLASS:SysTreeView32; INSTANCE:1]','IsChecked','#0|Hide extensions for known file types')oÝ÷ Ø Ýj¢Ø^uæî¦ë¡×´ÓMyóMúiÝ "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Klaatu Posted November 28, 2007 Author Share Posted November 28, 2007 Sometimes what looks like and behaves like a checkbox in treeviews is not what it seemsApparently so! Hey, thanks Bowmore, that certainly did it! How did you find out those commands would interact with what Microsoft tries to make look like a checkbox but really isn't? My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
Klaatu Posted November 28, 2007 Author Share Posted November 28, 2007 Well, looks like I spoke too soon. While the above code does appear to check the item in question, it doesn't actually change the option to match. I can see that by clicking OK to dismiss the dialog, then displaying it again. The option has not actually changed to match the visual state of the "checkbox". I can also see now that I pay attention that the "Apply" button never changes to enabled to indicate that any item in the treeview has changed state, like would normally occur if I checked the box manually. Hope this makes sense. So, while visually the above code does put a checkmark in the box, it's not doing the same thing as would normally happen when someone clicks on that option. Oh well, thanks anyway, but as for what I need the code to accomplish, it's back to the drawing board... My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
GaryFrost Posted November 28, 2007 Share Posted November 28, 2007 Next beta release there will be a _GUICtrlTreeView_ClickItem, I'm thinking that should do the trick for this. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
antan Posted March 21, 2009 Share Posted March 21, 2009 Hey! We can use _GUICtrlTreeView_GetImageIndex to see if the check box is checked! and use _GUICtrlTreeView_SelectItem to select the item we want to check and use Send("{SPACE}") to toggle the check! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now