Jump to content

Getting List Box selected item from another app


 Share

Recommended Posts

After a long absence from using AutoIT to drive an application under test, I've returned to find that Paul Williams Auto3Lib has been subsumed into the UDF libraries.

Yea! to this.

However, I seem to be having some issues getting this to work like I was expecting it to.

In particular, I'm trying to the get text of the selected item in a ListBox in an application I'm testing.

I could probably do this handily enough using the "ControlCommand" function, but for a variety of reasons, I'd like to see if I can get this using the _GUICtrlListBox_ UDFs instead.

The code I've got is this

CODE
Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

#include <GuiConstantsEx.au3>

#include <GuiListBox.au3>

WinWait("Add User Tables","A&vailable Tables:")

If Not WinActive("Add User Tables","A&vailable Tables:") Then WinActivate("Add User Tables","A&vailable Tables:")

WinWaitActive("Add User Tables","A&vailable Tables:")

$hWndListBox = ControlGetHandle("Add User Tables", "", "WindowsForms10.SysListView32.app.0.33c0d9d2")

MsgBox(0, "LBHwnd", $hWndListBox)

$LBItem = _GUICtrlListBox_GetText($hWndListBox, 1)

MsgBox(0,"LBItem", $LBItem)

ControlGetHandle is returning the correct handle for the list box.

However, the _GUICtrlListBox_GetText call is only returning a null string.

I am aware of the issues getting information from external applications (e.g., you need to allocate some memory in the external app that you've got a pointer to, then you need to get the info from that memory). However, I thought that Auto3Lib handled all that magic for you. Did that go away when then this got imported into the UDF? Or am I just making a particularly boneheaded mistake?

Link to comment
Share on other sites

Judging by the classname it would be safe to assume that the control is a ListView.

So do you really think it's a good idea to treat it as if it was a ListBox?

"be smart, drink your wine"

Link to comment
Share on other sites

Judging by the classname it would be safe to assume that the control is a ListView.

So do you really think it's a good idea to treat it as if it was a ListBox?

Thanks for noticing this for me. It did look like a list box, so I went and made an ass of myself and umption.

However, even correcting for this, it still seems to not be working in the same way.

CODE
Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

#include <GuiConstantsEx.au3>

#include <GuiListView.au3>

WinWait("Add User Tables","A&vailable Tables:")

If Not WinActive("Add User Tables","A&vailable Tables:") Then WinActivate("Add User Tables","A&vailable Tables:")

WinWaitActive("Add User Tables","A&vailable Tables:")

$hWndListBox = ControlGetHandle("Add User Tables", "", "WindowsForms10.SysListView32.app.0.33c0d9d2")

MsgBox(0, "LBHwnd", $hWndListBox)

$SelItem = _GUICtrlListView_GetItemTextString($hWndListBox, 1)

MsgBox(0,"#SelItems", $SelItem)

$SelItem = _GUICtrlListView_GetItemText($hWndListBox, 1)

MsgBox(0,"#SelItems", $SelItem)

This returns a null string for both _GUICtrlListView_GetItemTextString and _GUICtrlListView_GetItemTextString.

Any other thoughts?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...