Sh4rk Posted November 2, 2010 Share Posted November 2, 2010 Im new to Autoit and i have just registered. My problem is to get the status of a checkbox, which is 1.) in a SysTreeView32 and2.) in a ListboxWith help of the window info tool i only get the information above, no ID or class of the Checkboxes.So how do I get the status of the checkboxes?1.)2.) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 2, 2010 Share Posted November 2, 2010 (edited) The more advanced functions of the User Defined Functions (UDFs) will be required. You can find these in the help file, i.e. _GUICtrlTreeView_GetChecked() or _GUICtrlListView_GetItemChecked(). If you are familiar with Hwnd handles and the like it won't hurt, but you'll want to learn some basics first if you are completely new to this. Edited November 2, 2010 by PsaltyDS 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 More sharing options...
Sh4rk Posted November 3, 2010 Author Share Posted November 3, 2010 ok. I looked up the functions in the help file. But i don't understand what parameters are required in my case. What parameter should I specify for the item? A name as string or an index? I tried something like this, but it always returns false. MsgBox(0, "Checkbox status", _GUICtrlTreeView_GetChecked("[CLASS:SysTreeView32; INSTANCE:1]", 1)) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 You have to get the handle to the control, and the handle to the item. The UDF doesn't use AutoIt's specification strings or numeric indexes. It would look more like this: #include <GuiTreeView.au3> ; ... $hTreeView = ControlGetHandle("Extensions", "", "[CLASS:SysTreeView32; INSTANCE:1]") $hItem = _GUICtrlTreeView_FindItem($hTreeView, "Median") $bolChecked = _GUICtrlTreeView_GetChecked($hTreeView, $hItem) MsgBox(64, "Result", "Checked = " & $bolChecked) 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 More sharing options...
Sh4rk Posted November 3, 2010 Author Share Posted November 3, 2010 thanks for your code snippet, but unfortunately it does not work. The function always returns false independent of the status Do you have antoher idea? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 Add some error checking. Which part of it failed? Did it get the correct handle for the control in $hTreeView (compare with value from AU3Info.exe)? Did it get a valid handle for the item in $hItem, or a zero (not found)? 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 More sharing options...
Sh4rk Posted November 4, 2010 Author Share Posted November 4, 2010 Here is screenshot of the Window Info:For the treeView I get 0x000505E4, same as in window info.For the item I get 0x079C3CE8, can't find that value in the window info.So the handle seems to be correct.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 4, 2010 Share Posted November 4, 2010 (edited) That's good. You can only match the parent control handle via AU3Info.exe, it won't show you item handles under the control. The item handle would be better tested with IsHwnd(), but that looks like it is probably a valid handle by the format. With a valid handle for the control and the item, _GUICtrlTreeView_GetChecked() should have worked. If you run the unmodified example script in the help file for _GUICtrlTreeView_GetChecked() on the same PC, does it work correctly? Also, what is the OS? Edited November 4, 2010 by PsaltyDS 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 More sharing options...
Sh4rk Posted November 4, 2010 Author Share Posted November 4, 2010 The example script works correct. The OS is Windows XP (Service Pack 3). I also tried $hItem = _GUICtrlTreeView_GetFirstItem($hTreeView) to get the first item, but without success. It always returns false... Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 4, 2010 Share Posted November 4, 2010 Hmmm... Try _GUICtrlTreeView_GetImageIndex() on the same item and see if you get a different result index for checked/unchecked. 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 More sharing options...
Sh4rk Posted November 5, 2010 Author Share Posted November 5, 2010 I tried the following: $hTreeView = ControlGetHandle("Extensions", "", "[CLASS:SysTreeView32; INSTANCE:1]") ;$hItem = _GUICtrlTreeView_FindItem($hTreeView, "Median") $hItem = _GUICtrlTreeView_GetFirstItem($hTreeView) $index = _GUICtrlTreeView_GetImageIndex($hTreeView, $hItem) MsgBox(64, "Result", "index = " & $index) $bolChecked = _GUICtrlTreeView_GetChecked($hTreeView, $hItem) MsgBox(64, "Result", "Checked = " & $bolChecked) the first item has an image index of 3. Shouldn't it be 0 or 1? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 5, 2010 Share Posted November 5, 2010 the first item has an image index of 3.And is it different when checked?The image index is not a Boolean value, it is an integer index that specifies which image to show. If there are a dozen different images in the Image List, then there are that many different indexes. You might have images for Enabled/Unchecked, Enabled/Checked, Enabled/Gray-Checked, Disabled/Unchecked, Disabled/Checked, etc.The point is that not all apps respond to every control message as expected. If you can't get that particular one to reply with the checked value as a Boolean, then check the image index to see if it changes usefully when checked/unchecked. 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 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