Xenobiologist Posted October 30, 2007 Share Posted October 30, 2007 Hi, I'm trying to use the new treeview funcs from Gary. I cannot get them to work in this example. The code : expandcollapse popup#include<GuiTreeView.au3> ConsoleWrite('AutoitVersion: ' & @AutoItVersion & @CRLF) Opt("WinTitleMatchMode", 4) Global $Debug_TV = False Global $DEFAULT_GUI_FONT = 0 HotKeySet("{ESC}", "_Quit") ; Get an explorer window open to C:\ If WinExists('[CLASS:ExploreWClass;Title:C:\]') Then $hWin = WinGetHandle('[CLASS:ExploreWClass;Title:C:\]') Else If Not WinExists('[CLASS:CabinetWClass;Title:C:\]') Then Run("Explorer.exe C:\") WinWait('[CLASS:CabinetWClass;Title:C:\]') EndIf $hWin = WinGetHandle('[CLASS:CabinetWClass;Title:C:\]') EndIf WinActivate($hWin) WinWaitActive($hWin) ConsoleWrite('Winhandle: ' & $hWin & @CRLF) ; Create folder view (SysTreeView321) if required $hSTV1 = ControlGetHandle($hWin, "", "[CLASS:SysTreeView32;INSTANCE:1]") ; Folder explorer control If $hSTV1 = "" Then ControlSend($hWin, "", "", "!x") ; View <--- GERMAN!!! ControlSend($hWin, "", "", "o") ; Explorer ControlSend($hWin, "", "", "^{TAB}") ; Folder Sleep(2000) $hSTV1 = ControlGetHandle($hWin, "", 30120);, "[CLASS:SysTreeView32;INSTANCE:1]") ; Folder explorer control ConsoleWrite("Handle: " & $hSTV1 & @CRLF) $hitem = _GUICtrlTreeView_FindItem ($hSTV1, 'Erweiterungen bei bekannten Dateitypen ausblenden') If $hitem = 0 Then ConsoleWrite("Debug: item not found " & @LF) Else $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked before = " & $checked & @LF) If Not $checked Then _GUICtrlTreeView_SetChecked ($hSTV1, $hitem, True) $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked after = " & $checked & @LF) EndIf EndIf Func _Quit() Exit EndFunc ;==>_Quit The console output : C:\Programme\AutoIt3\beta\Include\GuiTreeView.au3(468,68) : WARNING: $DEFAULT_GUI_FONT: possibly used before declaration. _WinAPI_SetFont ($hTree, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\TreeviewZedna.au3 - 0 error(s), 1 warning(s) ->20:27:45 AU3Check ended.rc:1 >Running:(3.2.9.4):C:\Programme\AutoIt3\beta\autoit3.exe "C:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\TreeviewZedna.au3" AutoitVersion: 3.2.9.4 Winhandle: 0x00100FFE Handle: Debug: item not found +>20:27:48 AutoIT3.exe ended.rc:0 +>20:27:49 AutoIt3Wrapper Finished >Exit code: 0 Time: 4.543 Thanks for guiding me ... So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Zedna Posted October 30, 2007 Share Posted October 30, 2007 You can't get right treeview handle instead of $hSTV1 = ControlGetHandle($hWin, "", 30120);, "[CLASS:SysTreeView32;INSTANCE:1]")oÝ÷ ÚÚòjëh×6$hSTV1 = ControlGetHandle($hWin, "", "SysTreeView321") Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted October 30, 2007 Share Posted October 30, 2007 Problem is maybe in very early ControlGetHandle() when Window with treeview is not opened yet So instead of ControlSend($hWin, "", "", "^{TAB}") ; Folder Sleep(2000) $hSTV1 = ControlGetHandle($hWin, "", "SysTreeView321")oÝ÷ ÚÚòjëh×6ControlSend($hWin, "", "", "^{TAB}") ; Folder While 1 $hSTV1 = ControlGetHandle($hWin, "", "SysTreeView321") If Not @error Then ExitLoop Sleep(100) WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 30, 2007 Author Share Posted October 30, 2007 Hi, thanks. I changed it to this, but it still doesn't work. Now I get the handle :-) expandcollapse popup#include<GuiTreeView.au3> ConsoleWrite('AutoitVersion: ' & @AutoItVersion & @CRLF) Opt("WinTitleMatchMode", 4) Global $Debug_TV = False Global $DEFAULT_GUI_FONT = 0 HotKeySet("{ESC}", "_Quit") ; Get an explorer window open to C:\ If WinExists('[CLASS:ExploreWClass;Title:C:\]') Then $hWin = WinGetHandle('[CLASS:ExploreWClass;Title:C:\]') Else If Not WinExists('[CLASS:CabinetWClass;Title:C:\]') Then Run("Explorer.exe C:\") WinWait('[CLASS:CabinetWClass;Title:C:\]') EndIf $hWin = WinGetHandle('[CLASS:CabinetWClass;Title:C:\]') EndIf WinActivate($hWin) WinWaitActive($hWin) ConsoleWrite('Winhandle: ' & $hWin & @CRLF) ; Create folder view (SysTreeView321) if required $hSTV1 = ControlGetHandle($hWin, "", "[CLASS:SysTreeView32;INSTANCE:1]") ; Folder explorer control If $hSTV1 = "" Then ControlSend($hWin, "", "", "!x") ; View <--- GERMAN!!! ControlSend($hWin, "", "", "o") ; Explorer ControlSend($hWin, "", "", "^{TAB}") ; Folder While 1 $hSTV1 = ControlGetHandle($hWin, "", '');,"SysTreeView321") If Not @error Then ExitLoop Sleep(100) WEnd ConsoleWrite('TV Handle : ' & $hSTV1 & @CRLF) $hitem = _GUICtrlTreeView_FindItem ($hSTV1, 'Erweiterungen bei bekannten Dateitypen ausblenden') If $hitem = 0 Then ConsoleWrite("Debug: item not found " & @LF) Else $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked before = " & $checked & @LF) If Not $checked Then _GUICtrlTreeView_SetChecked ($hSTV1, $hitem, True) $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked after = " & $checked & @LF) EndIf EndIf Func _Quit() Exit EndFunc ;==>_Quit So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Zedna Posted October 30, 2007 Share Posted October 30, 2007 (edited) Hi,thanks. I changed it to this, but it still doesn't work. Now I get the handle :-)So long,MegaWhat's the output?I can't test it so I wrote my propositions without test only based on informations from yours given output. Edited October 30, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
GaryFrost Posted October 30, 2007 Share Posted October 30, 2007 (edited) This should get you a little closer, the title might be the problem, I changed it for what it is on mine. expandcollapse popup#include<GuiTreeView.au3> ConsoleWrite('AutoitVersion: ' & @AutoItVersion & @CRLF) Opt("WinTitleMatchMode", 4) Global $Debug_TV = False Global $DEFAULT_GUI_FONT = 0 HotKeySet("{ESC}", "_Quit") ; Get an explorer window open to C:\ If WinExists('[CLASS:ExploreWClass;Title:Local Disk (C:)]') Then $hWin = WinGetHandle('[CLASS:ExploreWClass;Title:Local Disk (C:)]') Else If Not WinExists('[CLASS:CabinetWClass;Title:Local Disk (C:)]') Then Run("Explorer.exe C:\") WinWait('[CLASS:CabinetWClass;Title:Local Disk (C:)]') EndIf $hWin = WinGetHandle('[CLASS:CabinetWClass;Title:Local Disk (C:)]') EndIf WinActivate($hWin) WinWaitActive($hWin) ConsoleWrite('Winhandle: ' & $hWin & @CRLF) ; Create folder view (SysTreeView321) if required $hSTV1 = ControlGetHandle($hWin, "", "[CLASS:SysTreeView32;INSTANCE:1]") ; Folder explorer control If $hSTV1 = "" Then ControlSend($hWin, "", "", "!x") ; View <--- GERMAN!!! ControlSend($hWin, "", "", "o") ; Explorer ControlSend($hWin, "", "", "^{TAB}") ; Folder While 1 $hSTV1 = ControlGetHandle($hWin, "", "SysTreeView321") If Not @error Then ExitLoop Sleep(100) WEnd ConsoleWrite('TV Handle : ' & $hSTV1 & @CRLF) $hitem = _GUICtrlTreeView_FindItem ($hSTV1, 'Erweiterungen bei bekannten Dateitypen ausblenden') If $hitem = 0 Then ConsoleWrite("Debug: item not found " & @LF) Else $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked before = " & $checked & @LF) If Not $checked Then _GUICtrlTreeView_SetChecked ($hSTV1, $hitem, True) $checked = _GUICtrlTreeView_GetChecked ($hSTV1, $hitem) ConsoleWrite("Debug: checked after = " & $checked & @LF) EndIf EndIf Func _Quit() Exit EndFunc ;==>_Quit Edited October 30, 2007 by GaryFrost 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...
GaryFrost Posted October 30, 2007 Share Posted October 30, 2007 Looks like when the SysTreeView is in the CabinetWClass window can't get the handle for example: Run(@WindowsDir & "\explorer.exe c:\") WinWaitActive('Local Disk (C:)') $hTree = ControlGetHandle('Local Disk (C:)', "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) Run(@WindowsDir & "\explorer.exe") WinWaitActive("My Documents") $hTree = ControlGetHandle("My Documents", "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) 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...
Xenobiologist Posted October 31, 2007 Author Share Posted October 31, 2007 Hi, thanks for reply. But I still didn#t get it to work. I won't give up and start a next try later. If @OSLang = 0407 Then $title = 'C:\' $title1 = 'Eigene Dateien' Else $title = 'Local Disk (C:)' $title1 = "My Documents" EndIf Run(@WindowsDir & "\explorer.exe c:\") WinWaitActive($title) $hTree = ControlGetHandle($title, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) Run(@WindowsDir & "\explorer.exe") WinWaitActive($title1) $hTree = ControlGetHandle($title1, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) #cs output TreeHandle: TreeHandle: 0x001C0884 #ce Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Siao Posted October 31, 2007 Share Posted October 31, 2007 (edited) Maybe it's because I'm slow, but I'm really failing to see the point of this exercise... The example in the post above, what's it supposed to show? First case, there's no treeview, so no handle. Second case, there is treeview, so returned correct handle. Everything as it should be. Also, quick look reveals that most of these treeview functions (stuff like _GUICtrlTreeView_FindItem) from beta 3.2.9.3 do not support external treeviews, so they will fail miserably when attempted on such (actually crashed explorer for me). The structs must be allocated in the memory of that external process for it to work. See Auto3Lib, its treeview funcs work on explorer treeviews. Edited October 31, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
GaryFrost Posted October 31, 2007 Share Posted October 31, 2007 Also, quick look reveals that most of these treeview functions (stuff like _GUICtrlTreeView_FindItem) from beta 3.2.9.3 do not support external treeviews, so they will fail miserably when attempted on such (actually crashed explorer for me). The structs must be allocated in the memory of that external process for it to work.See Auto3Lib, its treeview funcs work on explorer treeviews.Actually they are supposed to, but found a bug in the _GUICtrlTreeView_GetText function, was missing the mem calls, this has been fixed and now works for me. I'm currently looking thru the functions to see if I can find any others that need correction.Gary 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...
Xenobiologist Posted October 31, 2007 Author Share Posted October 31, 2007 HI, thanks! I thought that nearly all the funcs from Auto3Lib were ported to latest beta and that is why I thought those funcs should work with external treewviews. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
smashly Posted October 31, 2007 Share Posted October 31, 2007 Maybe it's because I'm slow, but I'm really failing to see the point of this exercise...The example in the post above, what's it supposed to show? First case, there's no treeview, so no handle. Second case, there is treeview, so returned correct handle. Everything as it should be.Also, quick look reveals that most of these treeview functions (stuff like _GUICtrlTreeView_FindItem) from beta 3.2.9.3 do not support external treeviews, so they will fail miserably when attempted on such (actually crashed explorer for me). The structs must be allocated in the memory of that external process for it to work.See Auto3Lib, its treeview funcs work on explorer treeviews.I found the same results with most the _GUICtrlTreeView_XXX functions in beta 3.2.9.4 failed externally , but some do sota work, eg: _GUICtrlTreeView_GetFirstItem() , _GUICtrlTreeView_GetFirstVisible(), _GUICtrlTreeView_GetSelection(), _GUICtrlTreeView_GetNext() .. etcI say sorta because they do actually return something other then a crash, 0 or false, but try and do anything with the returns from those functions and it's a differant story.Cheers Link to comment Share on other sites More sharing options...
GaryFrost Posted October 31, 2007 Share Posted October 31, 2007 I found the same results with most the _GUICtrlTreeView_XXX functions in beta 3.2.9.4 failed externally , but some do sota work, eg: _GUICtrlTreeView_GetFirstItem() , _GUICtrlTreeView_GetFirstVisible(), _GUICtrlTreeView_GetSelection(), _GUICtrlTreeView_GetNext() .. etcI say sorta because they do actually return something other then a crash, 0 or false, but try and do anything with the returns from those functions and it's a differant story.CheersAnd that's what bug reports is about.....A3L lib was not ported it was merged, some functions were not used from the lib some were, so there may be some problems, therefore "beta"Gary 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...
Zedna Posted October 31, 2007 Share Posted October 31, 2007 (edited) Hi, thanks for reply. But I still didn#t get it to work. I won't give up and start a next try later. expandcollapse popupIf @OSLang = 0407 Then $title = 'C:\' $title1 = 'Eigene Dateien' Else $title = 'Local Disk (C:)' $title1 = "My Documents" EndIf Run(@WindowsDir & "\explorer.exe c:\") WinWaitActive($title) $hTree = ControlGetHandle($title, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) Run(@WindowsDir & "\explorer.exe") WinWaitActive($title1) $hTree = ControlGetHandle($title1, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) #cs output TreeHandle: TreeHandle: 0x001C0884 #ceoÝ÷ Ûú®¢×¯&vØb±©ÝµéeûajØ^¡×uÞ4Ó~Ù^×Vp¶+Úµî4Ó~Ù^×r^jëh×6If @OSLang = 0407 Then $title = 'C:\' $title1 = 'Eigene Dateien' Else $title = 'Local Disk (C:)' $title1 = "My Documents" EndIf Run(@WindowsDir & "\explorer.exe c:\") WinWait($title) WinActivate($title) WinWaitActive($title) $hTree = ControlGetHandle($title, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) Run(@WindowsDir & "\explorer.exe") WinWait($title1) WinActivate($title1) WinWaitActive($title1) $hTree = ControlGetHandle($title1, "", "SysTreeView321") ConsoleWrite("TreeHandle: " & $hTree & @LF) #cs output TreeHandle: TreeHandle: 0x001C0884 #ce EDIT: First ControlGetHandle() can't get TreeView handle because there is no TreeView in "Local Disk (C:)" window!! There is only ListView in this case. As I said you before: Use Au3Info to check right control names/classes/instances/etc. Edited October 31, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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