ivan Posted August 19, 2006 Share Posted August 19, 2006 (edited) I posted this here because it's more akin to support than anything else, as it constitutes a solution to problem some of us have faced in the past and for which there was no viable solution. This, so that next time someone is stuck and searches the forum, they can find a reference to a possible way out of the nightmare posed in automation of Delphi TListBox controls.To anyone who's tried to automate Delphi TListBox controls, which resist automation by normal means there's a dirty solutionTo see what I mean take a look at:Controlling/getting info from a TListboxHow to handle Class: TListBox1 WinGetText returning nothing Can't get "GetSelected" to work ANYWAY, SOLVED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RIGHT, here's the procedure, it works and please don't ask why ? If you do know the answer, I'd be really pleased if you could explain. I just know IT WORKS! (I've been trying this for yonks!)1) include GuiList at the top of your script:#Include <GuiList.au3> 2) retreive the control handle for the TlistBox control:example:$ControlHandle=ControlGetHandle ( $WindowHandle, "", 'TListBox1' ) where handle is the $WindowHandle is the window's handle3) use the _GUICtrlList functions as you think fit.I can't find a native window application to suggest trying, but on 2 applications which I unfortunately can't distribute I can finally manipulate them frigging TListBoxes.I only wish I knew this earlier....IVAN Edited August 19, 2006 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
GaryFrost Posted August 19, 2006 Share Posted August 19, 2006 My guess would be the TListBox is a ownerdrawn ListBox. And The GuiList is written to hand AutoIt ListBoxes and External ListBoxes (I check if it is a handle being passed in verses a control id). I'm glad it worked for you. 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...
ivan Posted August 21, 2006 Author Share Posted August 21, 2006 (edited) gafrost:Thanks for the explanation. I always wondered why Tlistboxes were so damnd hard to work with, they resist automation with normal Listbox procedures, and using #Include <GuiList.au3> is the only way I found to manipulate those types of controls.I came to the conclusion that Delphi forms create T controls, including TTBXToolbar, TPanel, TListView, TGroupBox, TListView, TShellList, etc... besides theit Listboxes counterparts, ie, TLisbox.Although not what I wanted to automate, one of my favorite php editors is written in Delphi, and has numerous T controls. I f someone wants to experiement with it here's the linkphpDesigner It just went commercial! I used the freeware 2006 version which had a few problems, but wasn't a commercial version. There's still a personal version but legally not much can be done with it.IVAN Edited August 21, 2006 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
cbadal Posted April 12, 2007 Share Posted April 12, 2007 (edited) Ivan, you are my hero. I just started using AutoIt for the intended purpose of automating a Delphi App. I had made decent progress (had to stoop to using mouse clicks is some places) until I came accross a TListBox. After my initial searching I came away with nothing but hatred for that Damn TList box and the Delphi language. Then I came back today and simply searched for "Delphi" and found this thread. Now I feel empowered again and can continue my automation project. Thank you very much for posting your findings. Edited April 12, 2007 by cbadal Link to comment Share on other sites More sharing options...
Zedna Posted April 12, 2007 Share Posted April 12, 2007 (edited) I think Auto3Library should do the same work, with all _Listbox_xxx() functions inside A3LListBox.au3 include file.Just for complex info. Edited April 12, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
NiTroGen Posted June 30, 2007 Share Posted June 30, 2007 It doesn't work in my case. TControl is really troublesome!!! Any suggestion? $WindowTitle="GSA Email Spider v3.78 - DEMOVERSION" $ControlID="TListBox1" $WindowHandle=WinGetHandle($WindowTitle) $ControlHandle=ControlGetHandle ( $WindowHandle, "", $ControlID ) $x=_GUICtrlListCount($ControlHandle) ConsoleWrite("HWnd = " & String($ControlHandle) & @CRLF) ConsoleWrite("ItemCount = " & $x & @CRLF) It always give -1 for ItemCount I have tried using $WindowHandle or $WindowTitle for ControlGerHandle function,. but it won't help Maybe I better stick to SysExporter and save my time to have a coffee Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 30, 2007 Share Posted June 30, 2007 It doesn't work in my case. TControl is really troublesome!!! Any suggestion? $WindowTitle="GSA Email Spider v3.78 - DEMOVERSION" $ControlID="TListBox1" $WindowHandle=WinGetHandle($WindowTitle) $ControlHandle=ControlGetHandle ( $WindowHandle, "", $ControlID ) $x=_GUICtrlListCount($ControlHandle) ConsoleWrite("HWnd = " & String($ControlHandle) & @CRLF) ConsoleWrite("ItemCount = " & $x & @CRLF) It always give -1 for ItemCount I have tried using $WindowHandle or $WindowTitle for ControlGerHandle function,. but it won't help Maybe I better stick to SysExporter and save my time to have a coffee Just for giggles, try: $x = _GUICtrlListViewGetItemCount($ControlHandle) 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...
NiTroGen Posted July 3, 2007 Share Posted July 3, 2007 $x = _GUICtrlListViewGetItemCount($ControlHandle)Same result........ -1 again........Since system exporter works perfectly, I am sure there is some way to get the text out. Let's see if I can find out my old API Spy...But I need a beer first Link to comment Share on other sites More sharing options...
cbadal Posted July 3, 2007 Share Posted July 3, 2007 We are discussing this issue in the following topic.http://www.autoitscript.com/forum/index.php?showtopic=48701Try this:Go to the 'Include' folder and edit the File 'Misc.au3' (you'll need to remove the read-only attribute).Edit the _IsClassName function to always return 1Func _IsClassName($h_hWnd, $s_ClassName) Return 1 ; If Not IsHWnd($h_hWnd) Then $h_hWnd = GUICtrlGetHandle($h_hWnd) ; Local $aResult = DllCall("user32.dll", "int", "GetClassNameA", "hwnd", $h_hWnd, "str", "", "int", 256) ; If @error Then Return SetError(@error, @error, "") ; If IsArray($aResult) Then ; If StringUpper(StringMid($aResult[2], 1, StringLen($s_ClassName))) = StringUpper($s_ClassName) Then ; Return 1 ; Else ; Return 0 ; EndIf ; Else ; Return SetError(-1, -1, 0) ; EndIf EndFunc ;==>_IsClassNameRun your script and see what you get. Link to comment Share on other sites More sharing options...
NiTroGen Posted July 4, 2007 Share Posted July 4, 2007 @cbadal It works flawlessly! Thank you! 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