Sign in to follow this  
Followers 0
ivan

TListBox controls sussed!

10 posts in this topic

#1 ·  Posted (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 solution

To see what I mean take a look at:

Controlling/getting info from a TListbox

How to handle Class: TListBox1

WinGetText returning nothing

Can't get "GetSelected" to work

ANYWAY, SOLVED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :P

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 handle

3) 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 by ivan

Share this post


Link to post
Share on other sites



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.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by ivan

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by cbadal

Share this post


Link to post
Share on other sites

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 :rolleyes:

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

Share this post


Link to post
Share on other sites

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 :rambo:

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)

:rolleyes:


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

Share this post


Link to post
Share on other sites

$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 :whistle:

Share this post


Link to post
Share on other sites

We are discussing this issue in the following topic.

http://www.autoitscript.com/forum/index.php?showtopic=48701

Try 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 1

Func _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  ;==>_IsClassName

Run your script and see what you get.

Share this post


Link to post
Share on other sites

@cbadal

It works flawlessly! Thank you!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0