Sign in to follow this  
Followers 0
OrthodoxyUSA

IsSelected Listbox1

23 posts in this topic

Hello all! (My first post here.)

I am developing a fairly complex script for use with Microsoft Dynamics "Great Plains" software.

I am stumped at one particular part. I hope you guys can help.

The problem is, I need to confirm that the correct user is selected in a list box before proceeding.

Here is what I have been attempting to use.

$i="TEST5"

#include <GUIConstantsEx.au3>

#include <GUIListBox.au3>

AutoItSetOption("wintitlematchmode", 4)

AutoItSetOption("winsearchchildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

Sleep(2000)

WinActive("User Access Setup","")

ControlFocus("User Access Setup","","[CLASS:ListBox; INSTANCE:1]")

ControlSend("User Access Setup","","[CLASS:ListBox; INSTANCE:1]",$i)

$text = ControlCommand("User Access Setup","","[CLASS:ListBox; INSTANCE:1]","GetCurrentSelection", "")

MsgBox(0, "Text read was:", $text)

I expected my MsgBox to popup with "Text read was: TEST5".

I have no problem using ControlSend to select "TEST5", however I have yet to be able to confirm what is selected for error control.

I have tried "ControlCommand" and "ControlListview".

I need to know that the correct user (TEST5 in this case) was selected before moving to the next step.

I have attached a screenshot of the ListBox and the "Window Spy" as well.

Many thanks to you in advance for your help!

Paul

Share this post


Link to post
Share on other sites



Hi and wellcome! muttley

You can use "ListBox1" instead of [CLASS:ListBox; INSTANCE:1]... Here is an example with GUI:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

GUICreate("Test", 300, 200)

GUICtrlCreateList("", 20, 20)
GUICtrlSetData(-1, "sa|TEST5|Test6")

GUISetState()

$sString = "TEST5"
ControlCommand("Test", "", "ListBox1", "SelectString", $sString)

$sText = ControlCommand("Test", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "Text read was:", $sText)

And btw, you do not need to use «wintitlematchmode» with Advanced Window Descriptions (when you use [CLASS:...]).


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hi and wellcome! muttley

You can use "ListBox1" instead of [CLASS:ListBox; INSTANCE:1]... Here is an example with GUI:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

GUICreate("Test", 300, 200)

GUICtrlCreateList("", 20, 20)
GUICtrlSetData(-1, "sa|TEST5|Test6")

GUISetState()

$sString = "TEST5"
ControlCommand("Test", "", "ListBox1", "SelectString", $sString)

$sText = ControlCommand("Test", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "Text read was:", $sText)

And btw, you do not need to use «wintitlematchmode» with Advanced Window Descriptions (when you use [CLASS:...]).

Thanks for your reply.

I don't want to create a ListBox, but rather read the selected item in the ListBox that is there.

I have no doubt that AutoIt can read from a ListBox that it creates.

What I'm having trouble with is verifying the current selection in the Listbox that is provided in MS Dynamics Great Plains.

GetCurrentSelection returns a (0) zero no matter what is selected.

Any ideas?

Paul

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I tried this...

#include <GUIConstantsEx.au3>

#include <GUIListBox.au3>

AutoItSetOption("winsearchchildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

Sleep(2000)

WinActive("User Access Setup","")

ControlFocus("User Access Setup","","ListBox1")

$sString = "TEST5"

ControlSend("User Access Setup","","ListBox1","SelectString", $sString)

$sText = ControlCommand("Test", "", "ListBox1", "GetCurrentSelection")

MsgBox(0, "Text read was:", $sText)

I still get the same results.

It selects the proper user (TEST5), however in a realworld enviroment I have to verify (due to errors with some user accounts) that it is the user selected before moving to the next step.

Text read was: 0

Thanks for your help!

Paul

Edited by OrthodoxyUSA

Share this post


Link to post
Share on other sites

I still get the same results.

Because you are using "Test" as title muttley

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")
WinWait("User Access Setup")
ControlFocus("User Access Setup", "", "ListBox1")

$sString = "TEST5"
ControlCommand("User Access Setup", "", "ListBox1", "SelectString", $sString)
$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")

MsgBox(0, "Text read was:", $sText)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Because you are using "Test" as title muttley

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")
WinWait("User Access Setup")
ControlFocus("User Access Setup", "", "ListBox1")

$sString = "TEST5"
ControlCommand("User Access Setup", "", "ListBox1", "SelectString", $sString)
$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")

MsgBox(0, "Text read was:", $sText)
You are correct...

I tried this too...

#include <GUIConstantsEx.au3>

#include <GUIListBox.au3>

AutoItSetOption("winsearchchildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

Sleep(2000)

WinActive("User Access Setup","")

ControlFocus("User Access Setup","","ListBox1")

$sString = "TEST5"

ControlSend("User Access Setup","","ListBox1","SelectString", $sString)

$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")

MsgBox(0, "Text read was:", $sText)

This time I got...

Text read was: (a square)

Paul

Share this post


Link to post
Share on other sites

I tried this too...

Try my example.

You are using ControlSend wrong, «SelectString» is a string to send, but $sString is the last parameter, wich is used to define how "keys" is processed (see help file).

I used ControlCommand(), not ControlSend().

Text read was: (a square)

Perhaps it can not read correctly from the ListBox...

Instead of runing whole script, just open manualy the window with the listbox, and run this two lines:

$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "Text read was:", $sText)

What you get?


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Try my example.

You are using ControlSend wrong, «SelectString» is a string to send, but $sString is the last parameter, wich is used to define how "keys" is processed (see help file).

I used ControlCommand(), not ControlSend().

Perhaps it can not read correctly from the ListBox...

Instead of runing whole script, just open manualy the window with the listbox, and run this two lines:

$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "Text read was:", $sText)

What you get?

I guess I'm showing how tired I am. muttley

Using your example...

Text read was: 0 (no matter what I had selected.)

Thanks much.

Paul

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Text read was: 0

What you get with this:

$iWinExists = WinExists("User Access Setup")
$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "", "Error = " & @error & ", WinExists = " & $iWinExists)oÝ÷ Øò¢è´Jë¢
Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

What you get with this:

$iWinExists = WinExists("User Access Setup")
$sText = ControlCommand("User Access Setup", "", "ListBox1", "GetCurrentSelection")
MsgBox(0, "", "Error = " & @error & ", WinExists = " & $iWinExists)oÝ÷ Øò¢è´Jë¢
On the first one I got just what you predicted. «Error = 0, WinExists = 1»

On the second I get a square box. Like a checkbox.

No luck so far. It is very kind of you to be such a help.

muttley

Paul

Edited by OrthodoxyUSA

Share this post


Link to post
Share on other sites

Anybody else got any ideas?

Paul

Share this post


Link to post
Share on other sites

On the second I get a square box. Like a checkbox.

Can you please show a screenshot?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Can you please show a screenshot?

As requested.

Thanks much. muttley

Share this post


Link to post
Share on other sites

Hm, that strange, perhaps the ListBox is not a standard listbox control. If i just could test it somewhere...


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hm, that strange, perhaps the ListBox is not a standard listbox control. If i just could test it somewhere...

I agree, tis strange.

How else can I test what is selected before I move on to the next step?

I don't suppose you have a copy of MS Dynamics Great Plains to test with...

BTW~ Thanks for helping!

Paul

Share this post


Link to post
Share on other sites

How else can I test what is selected before I move on to the next step?

Try this:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

WinWait("User Access Setup")
WinActivate("User Access Setup")
WinWaitActive("User Access Setup")

$hList = ControlGetHandle("User Access Setup", "", "ListBox1")

$sString = "TEST5"
ControlCommand("User Access Setup", "", "ListBox1", "SelectString", $sString)

$sText = _GUICtrlListBox_GetSelItemsText($hList)
MsgBox(0, "", "Text read was: " & $sText[1])

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

WinWait("User Access Setup")
WinActivate("User Access Setup")
WinWaitActive("User Access Setup")

$hList = ControlGetHandle("User Access Setup", "", "ListBox1")

$sString = "TEST5"
ControlCommand("User Access Setup", "", "ListBox1", "SelectString", $sString)

$sText = _GUICtrlListBox_GetSelItemsText($hList)
MsgBox(0, "", "Text read was: " & $sText[1])
Hmmm.... I get an error.

MsgBox(0, "", "Text read was: " & $sText[1])

MsgBox(0, "", "Text read was: " & ^ ERROR

If I run it without [1], I get nothing in my MsgBox.

Paul

Share this post


Link to post
Share on other sites

Hmmm.... I get an error.

The item is selected? Can you

Try instead _GUICtrlListBox_GetSelItemsText just use _GUICtrlListBox_GetText($hList, 1), what you get?

I think the listbox you got there is not a standard listbox...


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

One more shot:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

WinWait("User Access Setup")
WinActivate("User Access Setup")
WinWaitActive("User Access Setup")

$hList = ControlGetHandle("User Access Setup", "", "ListBox1")

_GUICtrlListBox_SetCurSel($hList, 1)

$sText = _GUICtrlListBox_GetSelItemsTextEx($hList)
MsgBox(0, "", "Text read was: " & $sText)


Func _GUICtrlListBox_GetSelItemsTextEx($hWnd)
    Local $iI, $iCount, $tArray, $sRet = ""
    
    $iCount = _SendMessage($hWnd, $LB_GETSELCOUNT)
    
    If $iCount > 0 Then
        $tArray = DllStructCreate("int[" & $iCount & "]")
        
        _SendMessage($hWnd, $LB_GETSELITEMS, $iCount, DllStructGetPtr($tArray), 0, "wparam", "ptr")
        
        For $i = 1 To $iCount
            $iIndex = DllStructGetData($tArray, 1, $i)
            
            Local $struct = DllStructCreate("char Text[" & _SendMessage($hWnd, $LB_GETTEXTLEN, $iIndex) + 1 & "]")
            _SendMessage($hWnd, $LB_GETTEXT, $iIndex, DllStructGetPtr($struct), 0, "wparam", "ptr")
            
            $sRet &= DllStructGetData($struct, "Text") & @CRLF
        Next
    EndIf
    
    Return StringStripWS($sRet, 3)
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

One more shot:

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>

Opt("WinSearchChildren", 1)

WinWaitActive("Microsoft Dynamics GP - Customer Service Mgt")

WinWait("User Access Setup")
WinActivate("User Access Setup")
WinWaitActive("User Access Setup")

$hList = ControlGetHandle("User Access Setup", "", "ListBox1")

_GUICtrlListBox_SetCurSel($hList, 1)

$sText = _GUICtrlListBox_GetSelItemsTextEx($hList)
MsgBox(0, "", "Text read was: " & $sText)


Func _GUICtrlListBox_GetSelItemsTextEx($hWnd)
    Local $iI, $iCount, $tArray, $sRet = ""
    
    $iCount = _SendMessage($hWnd, $LB_GETSELCOUNT)
    
    If $iCount > 0 Then
        $tArray = DllStructCreate("int[" & $iCount & "]")
        
        _SendMessage($hWnd, $LB_GETSELITEMS, $iCount, DllStructGetPtr($tArray), 0, "wparam", "ptr")
        
        For $i = 1 To $iCount
            $iIndex = DllStructGetData($tArray, 1, $i)
            
            Local $struct = DllStructCreate("char Text[" & _SendMessage($hWnd, $LB_GETTEXTLEN, $iIndex) + 1 & "]")
            _SendMessage($hWnd, $LB_GETTEXT, $iIndex, DllStructGetPtr($struct), 0, "wparam", "ptr")
            
            $sRet &= DllStructGetData($struct, "Text") & @CRLF
        Next
    EndIf
    
    Return StringStripWS($sRet, 3)
EndFunc
Sorry,

Again, I get an empty reply... Text read was:

I think you are correct, this is not a standard box. I am now working on solving this problem using an OSQL statement.

Thanks so much for you time.

Forgive me...

Paul

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