Fur Posted April 19, 2005 Author Posted April 19, 2005 Latest additions to let you loop over all the items in a treeview: HTREEITEM EXPORT GetTreeViewNameByItem(HWND hWnd, HTREEITEM hItem, char *szItemName) { if (!hItem) { *szItemName = '\0'; return 0; } // Open a handle to the remote process's kernel object DWORD dwProcessId; GetWindowThreadProcessId(hWnd, &dwProcessId); HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId); SneakyGetTreeItemName(hWnd, hItem, hProcess, szItemName, 100); return hItem; } HTREEITEM EXPORT TreeViewGetRoot(HWND hWnd) { return (HTREEITEM) SendMessage(hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0); } HTREEITEM EXPORT TreeViewNextChild(HWND hWnd, HTREEITEM hItem) { return TreeView_GetNextItem(hWnd, hItem, TVGN_CHILD); } HTREEITEM EXPORT TreeViewNextSibling(HWND hWnd, HTREEITEM hItem) { return TreeView_GetNextItem(hWnd, hItem, TVGN_NEXT); } Autoit example code/ C++ wrappers: expandcollapse popupLocal $tree = GetActiveControl($title) Local $root = TreeViewGetRoot($tree) DumpTreeView($tree, $root) Func DumpTreeView($tree, $node) While $node Local $str = GetTreeViewNameByItem($tree, $node) ConsoleWrite("node is " & $str & @LF); ExpandTreeViewItem($tree, $node) Local $child = TreeViewNextChild($tree, $node) if $child <> 0 Then DumpTreeView($tree, $child) Local $node = TreeViewNextSibling($tree, $node) WEnd Endfunc Func GetTreeViewNameByItem($hwnd, $hitem) Local $str = "" Local $foo = DllCall($g_socdll, "long", "GetTreeViewNameByItem", "hwnd", $hwnd, "long", $hitem, "str", $str) If @error Then MsgBox(0, "Debug", "Error with DllCall(GetTreeViewNameByItem)") Endif Return $foo[3] Endfunc Func TreeViewGetRoot($hwnd) Local $foo = DllCall($g_socdll, "long", "TreeViewGetRoot", "hwnd", $hwnd) If @error Then MsgBox(0, "Debug", "Error with DllCall(TreeViewGetRoot)") Endif Return $foo[0] Endfunc Func TreeViewNextChild($hwnd, $hitem) Local $foo = DllCall($g_socdll, "long", "TreeViewNextChild", "hwnd", $hwnd, "long", $hitem) If @error Then MsgBox(0, "Debug", "Error with DllCall(TreeViewNextChild)") Endif Return $foo[0] Endfunc Func TreeViewNextSibling($hwnd, $hitem) Local $foo = DllCall($g_socdll, "long", "TreeViewNextSibling", "hwnd", $hwnd, "long", $hitem) If @error Then MsgBox(0, "Debug", "Error with DllCall(TreeViewNextSibling)") Endif Return $foo[0] Endfunc
Zedna Posted November 14, 2005 Posted November 14, 2005 (edited) I need TreeView control functions too.All of that manipulating with TreeViews can be done by DllCall & SendMessage.Only one thing is not possible this way: TreeViewGetItemText/TreeViewSetItemTextSo I tried use C++ code from this topic a make simple DLL only with one function TreeViewGetItemTextIt's based on combination of GetTreeViewItemByName and SneakyGetTreeItemName (merged).It's only for WIN NT/XP - not for WIN Me/9xI tried to compile it in Dev-Cpp, but there was errors in standard include files.So I compiled it in MSVC++ 2003 at my friend's computer.But it seems to be some problem with this DLL - when running dllcall there is error: listed procedure (in DLL) not foundI'm not so experienced in C++, so please can somebody help me with this?Where is problem with compilation and/or running this DLL...Here are my files:DLL.CPP - source of DLLDLL.H - header file of DLLtreeview_app.au3 - sample application with treeview (to be controled)treeview_test.au3 - testing script (with dllcall for manipulating with treeview)Win32_1.zip - compressed binary DLL treeview_app.au3treeview_test.au3 Edited November 14, 2005 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted November 15, 2005 Posted November 15, 2005 My problem is probably somewhere in project preferences in MSVC ,because in compiled DLL is my function exported somehow strange.Here is dump of exports from my DLL:dumpbin.exe /exports Win32_1.dllMicrosoft ® COFF/PE Dumper Version 7.10.3077Copyright © Microsoft Corporation. All rights reserved.Dump of file Win32_1.dllFile Type: DLL Section contains the following exports for Win32_1.dll 00000000 characteristics 4378B8B6 time date stamp Mon Nov 14 17:17:58 2005 0.00 version 1 ordinal base 1 number of functions 1 number of names ordinal hint RVA name 1 0 0001102D ?TreeViewGetItemText@@YAPAU_TREEITEM@@PAUHWND__@@PAU1@ Summary 4000 .data 1000 .idata 5000 .rdata 2000 .reloc 1F000 .text 10000 .textbssSo problem is that my function is not exported under name TreeViewGetItemTextbut under name ?TreeViewGetItemText@@YAPAU_TREEITEM@@PAUHWND__@@PAU1@Can somebody help me with this?Thank you Resources UDF ResourcesEx UDF AutoIt Forum Search
Shibuya Posted November 16, 2005 Posted November 16, 2005 I'm not familiar with C++ but then i copied the code and tried compiling under Dev-C++ anyway Gave up immediately when it returned me a whole bunch of errors, I didn't know what I was doing anyway I'm just desperate for a SysTreeView functionality The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"
Zedna Posted November 16, 2005 Posted November 16, 2005 (edited) I'm not familiar with C++but then i copied the code and tried compiling under Dev-C++ anywayGave up immediately when it returned me a whole bunch of errors, I didn't know what I was doing anywayI'm just desperate for a SysTreeView functionalityIn Dev-cpp are some strange versions of include files (*.h) - undefined some types, structures, included nested include files which couldn't then be compiled.In MSVC++ are all these header files correct, so the same code can be compiled without errors.So maybe there is somewhere new version of header files for Dev-cpp, but I don't know.So I'm still waiting for little help from somebody skilled in compiling this small piece of C++ code under Dev-cpp/MSVC++ (or other compiler).Thank you Edited November 16, 2005 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
jpm Posted November 17, 2005 Posted November 17, 2005 did you use the plugin_sdk environment under Extra to compile your dll plugin I think it is the best todo
Zedna Posted November 17, 2005 Posted November 17, 2005 did you use the plugin_sdk environment under Extra to compile your dll plugin I think it is the best todoWhen plugins appeared I looked into this plugins SDK, but now I forget about it. I will look at it and try something.At first look I think there is missing extern "C" before __declspec(dllexport)in my dll.h.Thank you very much for this good tip. Resources UDF ResourcesEx UDF AutoIt Forum Search
tweast Posted May 25, 2006 Posted May 25, 2006 Fur, Have you posted or would you post a copy of the compiled DLL. I have tried to compile your code but the latest VC++ is having problems digesting it. TIA Todd
Zedna Posted May 25, 2006 Posted May 25, 2006 Fur,Have you posted or would you post a copy of the compiled DLL. I have tried to compile your code but the latest VC++ is having problems digesting it.TIAToddIf your question was for me:No I haven't done this my attepts to succefull finish Resources UDF ResourcesEx UDF AutoIt Forum Search
tweast Posted May 25, 2006 Posted May 25, 2006 If your question was for me:No I haven't done this my attepts to succefull finish Thanks Zedna.I think by just sending the text for the option I want to select I can work around the problem for what I need to do right now. I just can't verify I'm on the correct options when I select them. I have found another tool called TextCatch that does successfully grab the info from a TreeView control and has a COM interface. I haven't tried to mate it to AutoIt yet. I'm going to use my work around for my 1.0 and I'll readdress the issue in 1.1.Todd
ptrex Posted May 25, 2006 Posted May 25, 2006 @tweastHere is an other application that can grab text from a screen.SnagItI am also looking for functions to grab text from non windows standard controls. I was hoping AutoIT has a way into this, but I have not found it.I understand that it is possible as long as they are standard controls, but non standard is not possible.Nevertheless these applications are able to do so. If someone can explain me why they can and we can't ?regardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
tweast Posted May 26, 2006 Posted May 26, 2006 Working DLL Please note that credit for this solution should be given to Fur. Thanks to a friend that knows VC++ much better than I, we created a mostly working DLL. I have not had any crashes or errors generated, but the CopyTreeViewToClipboard function does not seem to work. I don't need that function for the project I'm working on now so I'll look into it at a future date. I did a minor correction in the wrappers and I added an additional compound wrapper to select item by name. I have only tested on WinXP and have not yet tested all the functions. Your mileage may vary. I do not suggest all of it will work on any system or any of it will work on all systems. Included for your download: AutoItTreeViewExtension.dll TreeView Testing.au3 (includes the wrappers) TreeView_app.au3 (Provided by Zedna in an earlier post)AutoItTreeViewExtension.dllTreeView_Testing.au3treeview_app.au3
Zedna Posted May 26, 2006 Posted May 26, 2006 tweast GREAT!Can you post here C++ source of this DLL? Thanks.Look here for my post about possibility of converting this from C++ to AU3 Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted May 26, 2006 Posted May 26, 2006 (edited) I have only tested on WinXP and have not yet tested all the functions. Your mileage may vary. I do not suggest all of it will work on any system or any of it will work on all systems.Original code from this post is working only WIN NT/XP/200x (and not on WIN 9x/ME) due to diferent API functions on these platforms for VirtualAlloc/VirtualAllocEx and VirtualFree/VirtualFreeExFor detailed diferences look into great _mem.au3 UDF here: MEM UDF- functions _MemAlloc, _MemFree are there maded for both platforms. Edited May 26, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Lapo Posted May 27, 2006 Posted May 27, 2006 (edited) I have only tested on WinXPWorks on a win98se>"C:\PROGRAMMI\AUTOIT3\EXTRA\EDITORS\SCITE\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "C:\WINDOWS\TEMP\Treewiew test.au3" /autoit3dir "C:\Programmi\Autoit3\beta" /UserParams >Running AU3Check C:\Programmi\Autoit3\Extra\Editors\SciTE\Defs\Unstable\Au3Check\au3check.dat>AU3Check Ended. No Error(s).>Running: (3.1.1.125):C:\Programmi\Autoit3\autoit3.exe "C:\WINDOWS\TEMP\Treewiew test.au3" Tree/Root is 0Item 21 is 0 Item 22 is 0 >AutoIT3.exe ended.>Exit code: 0 Time: 2.880 Edited May 27, 2006 by Lapo
Zedna Posted May 27, 2006 Posted May 27, 2006 Works on a win98seYou didn't run treeview_app.au3 which should be manipulated!I ran this on my WIN98 SE and it's NOT working:>"C:\PROGRAM FILES\AUTOIT3\SCITE\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "C:\PZ\AUTOIT\POK\TREEVIEW\!VirtualAllocEx\CPP\FORUM_DLL_OK\TreeView_Testing.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams >Running AU3Check...C:\Program Files\AutoIt3\SciTe\Defs\Unstable\Au3Check\au3check.dat>AU3Check Ended.>Running: (3.1.1.67):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\PZ\AUTOIT\POK\TREEVIEW\!VirtualAllocEx\CPP\FORUM_DLL_OK\TreeView_Testing.au3" Tree/Root is 0x00000314 4729764node is þ³node is þ³node is þ³node is þ³node is þ³node is þ³node is þ³node is þ³node is þ³node is þ³Item 21 is 0 Item 22 is 0 Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)Error calling SendMessage(TVIF_TEXT)>AutoIT3.exe ended.>Exit code: 0 Time: 4.703 Resources UDF ResourcesEx UDF AutoIt Forum Search
Lapo Posted May 28, 2006 Posted May 28, 2006 (edited) You didn't run treeview_app.au3 which should be manipulated!I ran this on my WIN98 SE and it's NOT working:You are right .. tested again clicked on treeview_app.au3 and runTreewiew test.au3 in scite .. and same output as you .. but the items in app.au3 are expadning .. same result in >> explorer.exe (C:\WINDOWS\EXPLORER.SCF)changing $title ="" in Treewiew test.au3 Edited May 28, 2006 by Lapo
jvetter713 Posted May 28, 2006 Posted May 28, 2006 Any chance at all at exporting the functions so I can access them via COM?
Zedna Posted May 28, 2006 Posted May 28, 2006 Working DLL I have only tested on WinXP and have not yet tested all the functions. Your mileage may vary. I do not suggest all of it will work on any system or any of it will work on all systems.I tested on WINXP also some of your untested functions and all OK:CollapseTreeViewItemGetSelectedTreeViewItemAlso note: SelectTreeViewItemByName - will expand parent if it's not expandedGood work.Now when things are working can be added also SetTreeViewNameByItem --> TVM_SETITEM instead of TVM_GETITEM (GetTreeViewNameByItem), but this is not so important as GetTreeViewNameByItem. Resources UDF ResourcesEx UDF AutoIt Forum Search
Iznogoud Posted June 13, 2006 Posted June 13, 2006 The select tree does work fine, but how can i select things in a listview?I am trying to make a script wich enables alot of policy settings.I described my situatie at: http://www.autoitscript.com/forum/index.ph...topic=27426&hl=Is there a way to do this?
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