Sign in to follow this  
Followers 0
dumdum20008

Getting List Element

13 posts in this topic

Hi,

Just started AutoIT...got Stuck at this.

Im trying to get Order Information from Main Window of an application.

Order List Pop up on F3 Hit in Main window.

Its working till getting number of Orders and number of Columns in Order list....but it dont get any particular element from Order list. For example im trying to print element of 3rd order and 8th column. But its printing blank even Order list is populated with text value at that element location. Where is bug..please guide

Posted Image

Share this post


Link to post
Share on other sites



_GUICtrlListView_GetItem returns an array, the text is in $itemtext[3] in your code. You're trying to access it like its a simple variable. You could also use _GUICtrlListView_GetItemText to get it directly into a variable instead of an array.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

_GUICtrlListView_GetItem returns an array, the text is in $itemtext[3] in your code. You're trying to access it like its a simple variable. You could also use _GUICtrlListView_GetItemText to get it directly into a variable instead of an array.

I tried _GUICtrlListView_GetItemText , as you suggested...but no luck.

See pic, there are 4 orders....its getting correct...and also number of columns also counting correct to 21...but particular element ( here suppose to print "NSE" ) text is not getting printed. What im missing...?

Posted Image

Share this post


Link to post
Share on other sites

Try using _GUICtlrListView_GetItemTextArray to see if the array contains what you're looking for. Also, if you are using this on an x64 OS, try running the script in 32 bit mode to see if that makes any difference.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Use _GUICtrlListView_GetItemTextString function. Then, use StringSplit function. Hope this solves this.

Regards

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Try using _GUICtlrListView_GetItemTextArray to see if the array contains what you're looking for. Also, if you are using this on an x64 OS, try running the script in 32 bit mode to see if that makes any difference.

Its running on 32 bit.

I tried array alos...no change....getting blank as before.

Use _GUICtrlListView_GetItemTextString function. Then, use StringSplit function. Hope this solves this.

Regards

In this case im getting all 20 delimiter printed, like " | | | |.....| | |"....but no text.

Share this post


Link to post
Share on other sites

In case these snap be helpful from AutoIT Window Info of the Order List parts....

any suggestion...?

Posted Image

Posted Image

Posted Image

Posted Image

Share this post


Link to post
Share on other sites

dumdum,

Post the script (or a reproducer) otherwise the people trying to help are chasing a moving target...

Good Luck,

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

dumdum,

Post the script (or a reproducer) otherwise the people trying to help are chasing a moving target...

Good Luck,

kylomas

Ok...here is script...but one can check only syntax etc....but without operating program one cant run it.

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("Order Feeder", 300, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$checkorder = GUICtrlCreateButton("Check Order",70,80,80,30)
GUICtrlSetOnEvent($checkorder, "CheckOrder")
GUISetState(@SW_SHOW)
Global $hWindow = WinGetHandle("Some Title")
While 1
  Sleep(1000)  ; Idle around
WEnd
Func CheckOrder()

  WinActivate($hWindow)   ;Global Variable
     Send("{F3}")
  WinWaitActive($hwindow,"Orders Book - [All]")
  $hOrderList = ControlGetHandle($hWindow,"","[CLASS:SysListView32; INSTANCE:1]")
  $iOrderCnt = ControlListView($hWindow, "", $hOrderList,"GetItemCount")
  $iOrderColumnCnt = ControlListView($hWindow, "", $hOrderList,"GetSubItemCount")
  If $iOrderCnt = 0 Then
   ConsoleWrite("No Order Found")
   Else
   ControlListView($hWindow, "", $hOrderList,"DeSelect",0)
   ControlListView($hWindow, "", $hOrderList,"Select",2)
   _GUICtrlListView_SetItemFocused($hOrderList,2)
   $itemText = _GUICtrlListView_GetItemTextString($hOrderList,2)
  
   ConsoleWrite("No of Order :" & $iOrderCnt & @LF)
   ConsoleWrite("No of Column in Order List :" & $iOrderColumnCnt & @LF)
   ConsoleWrite("Order Instrument :" & $itemText & @LF)
  
  EndIf
  ControlSend($hWindow, "", $hOrderList,"{ESC}")
  EndFunc

  Func CLOSEClicked()
Exit
EndFunc

and here is output as usual....

post-71195-0-74809400-1332956658_thumb.p

Edited by dumdum20008

Share this post


Link to post
Share on other sites

I ran this script and used Task Manager as a replacement for your program, which obviously I don't have, and it ran just fine for me. Here's the output from Task Manager when I hit the button.

No of Order :43

No of Column in Order List :7

Order Instrument :AutoIt3Help.exe *32|4836|~~~~|00 |6,568 K|"F:PortableAutoIt3.3.8AppAutoIt3Help.exe" "TCPRecv"|AutoIt3Help viewer

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

This is from the Help File on Controls (and could be a possible reason you are having an issue with extracting text from the control):

Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

1 person likes this

Share this post


Link to post
Share on other sites

It feels so to me also.

Getting more interaction with Order Form feeding.

Edit Box for price entries are giving mix results.

Send("some price to price edit box" ) is working..

but below pair working without setting price entry visible in price box of application.

_GUICtrlEdit_SetText($hPriceBox, "3")

$askprice = _GUICtrlEdit_GetText($hPriceBox)

ConsoleWrite("Ask Price :" & $askprice & @LF)

Price entry box of application is not changing its default price text....but output is showing changed text. :oops:

Share this post


Link to post
Share on other sites

Ok i am getting unconfirmed clues that not getting elements text of List view might be due to ListView being Owner Draw type.

But if its the case then how its getting counts of Items and Subitems of list. Is any workaround if list is Owner Drawn type..?

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