atzoref Posted February 2, 2012 Share Posted February 2, 2012 (edited) Hi,I have a strange situation:When I set an item to be checked with:_GUICtrlTreeView_SetChecked($TestsViewHandle, $CurrentItemHandle , True)If the item is a parent : _GUICtrlTreeView_GetSelection return True Handle Value which is OK,But the problem if the item is a child : _GUICtrlTreeView_GetSelection return Wrong Handle Value = 0x000000.Although If I set a child with the mouse to be checked (not with the _GUICtrlTreeView_SetChecked function)_GUICtrlTreeView_GetSelection return True Handle Value which is OK,I hope you understand my problem.Why is that?Thanks,Adi Edited February 4, 2012 by atzoref Link to comment Share on other sites More sharing options...
atzoref Posted February 4, 2012 Author Share Posted February 4, 2012 Someone have an idea? Link to comment Share on other sites More sharing options...
KaFu Posted February 4, 2012 Share Posted February 4, 2012 Theres a difference between selected and checked. Better give _GUICtrlTreeView_GetChecked() a try. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
LarsJ Posted February 4, 2012 Share Posted February 4, 2012 Are you sure you have selected the child item before the _GetSelection command. According to the help file _GetSelection will return 0 if no item is selected. When you click an item with the mouse the item will automatically be selected. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
atzoref Posted February 4, 2012 Author Share Posted February 4, 2012 LarsJ: That is what I don't understand.... I'm doing the : (_GUICtrlTreeView_SetChecked) before (_GetSelection) when it is a parent it OK but when it is a child it doesn't get true output from (_GetSelection) Like I wrote. What is the different? it should works the save way between parent and child. Kafu: I will try to play with it, I hope it will still work by this method.... Link to comment Share on other sites More sharing options...
LarsJ Posted February 4, 2012 Share Posted February 4, 2012 Yes, but _setChecked does not set the selection. If _GetSelection returns 0 it's because the item is not selected. If _GetSelection works with the parent, it's because the parent has the selection. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
atzoref Posted February 4, 2012 Author Share Posted February 4, 2012 Yes, but _setChecked does not set the selection. If _GetSelection returns 0 it's because the item is not selected. If _GetSelection works with the parent, it's because the parent has the selection.So how you can explain why (_setChecked) does set the Selcetion with parent item whereas child not? what is the different? Link to comment Share on other sites More sharing options...
LarsJ Posted February 4, 2012 Share Posted February 4, 2012 Can you post the code with the problems? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
LarsJ Posted February 4, 2012 Share Posted February 4, 2012 A quick answer. I don't think it's the _SetChecked command that gave the parent the selection. It must have got the selection in some other way. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
atzoref Posted February 5, 2012 Author Share Posted February 5, 2012 (edited) You are right, Set_checked not change the GetSelection (it ihas been changed only if the mouse checked an item or even just press on the item without checking the item) But I must use the GetSelection command, so what command can do this like the mouse press on an item? Or another command which can return the handle of an item which Checked or Selected by a command (and not by a mouse) I tried : SetSelected but it didn't changed. Edited February 5, 2012 by atzoref Link to comment Share on other sites More sharing options...
KaFu Posted February 5, 2012 Share Posted February 5, 2012 Are you trying to manipulate a none Autoit program? If so, try something like ControlListView ( "title", "text", controlID, "Select", From [, To]) and follow the remarks "Some commands may fail when using a 32-bit AutoIt process to read from a 64-bit process. Likewise commands may fail when using a 64-bit AutoIt process to read from a 32-bit process." meaning that if the target program is x64 then also Autoit needs to run as x64 and vice versa. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
atzoref Posted February 5, 2012 Author Share Posted February 5, 2012 (edited) No, I'm working on my Autoit Script Edited February 5, 2012 by atzoref Link to comment Share on other sites More sharing options...
KaFu Posted February 5, 2012 Share Posted February 5, 2012 Here's an adjusted example from the help-file working for me. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hItem[10], $hItem_child[10][11],$iRand, $hTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Set Selected", 400, 300) $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 0 To 9 $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView) For $y = 1 To Random(2, 10, 1) $hItem_child[$x][$y] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $hItem[$x]) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[1]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem_child[1][3]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem_child[1][5]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[3]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[5]) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
atzoref Posted February 5, 2012 Author Share Posted February 5, 2012 This example not answer my problem... Link to comment Share on other sites More sharing options...
LarsJ Posted February 5, 2012 Share Posted February 5, 2012 With _GetSelected/_GetChecked (not _GetSelection) you can work through all the items to check if they are selected/checked. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
KaFu Posted February 5, 2012 Share Posted February 5, 2012 expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hItem[10], $hItem_child[10][11],$iRand, $hTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Set Selected", 400, 300) $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 0 To 9 $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView) For $y = 1 To 10 $hItem_child[$x][$y] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $hItem[$x]) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[1]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem_child[1][3]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem_child[1][5]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[3]) _GUICtrlTreeView_SetSelected($hTreeView, $hItem[5]) For $x = 0 To 9 Switch _GUICtrlTreeView_GetSelected($hTreeView,$hItem[$x]) Case True ConsoleWrite("! " & $x & @crlf) Case Else ConsoleWrite($x & @crlf) EndSwitch For $y = 1 To 10 Switch _GUICtrlTreeView_GetSelected($hTreeView,$hItem_child[$x][$y]) Case True ConsoleWrite("! " & $x & " " & $y & @crlf) Case Else ConsoleWrite($x & " " & $y & @crlf) EndSwitch Next Next ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
atzoref Posted February 8, 2012 Author Share Posted February 8, 2012 Before I try this example I look in the Help File about (_GUICtrlTreeView_GetSelection( In the example there, they do: $iRand = Random(0, 9, 1) _GUICtrlTreeView_SelectItem($hTreeView, $hItem[$iRand]) MsgBox(4160, "Information", "Selection? " & _GUICtrlTreeView_GetSelection($hTreeView)) I do the same thing in my tree, But why (GetSelection) always shows 0x0000000 (and not the handle which set by SelectItem Function)? Link to comment Share on other sites More sharing options...
atzoref Posted February 12, 2012 Author Share Posted February 12, 2012 ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 12, 2012 Moderators Share Posted February 12, 2012 atzoref, You have been here long enough to know that posting 3 lines of code is not going to get you very far - particularly when those 3 lines work perfectly in the Help file example. Obviously the problem lies elsewhere in you code, so without seeing it we cannot offer you any help at all. Post a working script and we will take a look. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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