Jump to content

Help - Getting Text from 'AfxFrameOrView100'


Recommended Posts

Hello ,

Facing a issue.
Trying to retrieve the text of the MTM value.
Please see screenshot.

Tried all combinations :

Can you please assist.

 

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Excel.au3>



AutoItSetOption("WinTitleMatchMode", 2)
$appName = "Admin Positions"
$hWnd = WinGetHandle($appName)
WinActivate($appName, "")
Sleep(200)
ConsoleWrite("Active Handle=" & $hWnd & @CRLF)

$sID = ControlGetText($hWnd, "", "[CLASS:AfxFrameOrView100; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASS:#32770; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASS:32770; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[ID:59653; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASSNN:AfxFrameOrView1009; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)


AutoItSetOption("WinTitleMatchMode", 2)
$appName = "NEST Trader"
$hWnd = WinGetHandle($appName)
WinActivate($appName, "")
Sleep(200)
ConsoleWrite("Active Handle=" & $hWnd & @CRLF)


$sID = ControlGetText($hWnd, "", "[CLASS:AfxFrameOrView100; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASS:#32770; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASS:32770; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[ID:59653; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)
$sID = ControlGetText($hWnd, "", "[CLASSNN:AfxFrameOrView1009; INSTANCE:9]")
ConsoleWrite($sID & @CRLF)

 

Error.png

Link to comment
Share on other sites

Hi @adityaparakh :)

Could you please attach the AutoItWindowInfoTool summary of the Control you are trying to get the text from?

And, just to do a little step further, check out the ListView too (with AutoItWindowInfoTool), and attach the summary as well.

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Sure , There are no records now. However you can see the black border (see carefully).
Attached the screenshots for the List as well as the toolbar/statusbar which holds the MTM.


BTW ,
The control set text code , below is able to set to 50 for the Quantity % edit box.
The control click code below is able to press the Square off Button.
The ControlListView , - am not sure if it does SelectsAll , as only row was darkened visibly. Not sure what was happening behind the scene.

 

$sID = ControlSetText   ($hWnd,"","[CLASS:Edit; INSTANCE:1]","50")

$sClick = ControlClick($hWnd, "Admin Positions - 126591","[CLASS:Button; INSTANCE:5]")

$sClick = ControlListView($hWnd, "Admin Positions - 126591","[CLASS:SysListView32; INSTANCE:1]","SelectAll")

 

The List.png

The List 2.png

The List 3.png

Link to comment
Share on other sites

@adityaparakh
Try to use ControlGetHandle() to get the handle of the ListView in this way:

Global $hdlListView = ControlGetHandle("Admin Positions - 126591", "", "SysListView321")

If you manage to do this, than you can do whatever you want with the ListView using _GUICtrlListView_* functions :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Thanks a lot :)@FrancescoDiMuro,

Yes. It does access the list.
That will not help get the MTM value displayed at the bottom thought right ?

I can indirectly get the MTM value , as the 5th column lists it for each record.
Can you please give the command for determining the number of rows.
And for that many rows , get column 5 into array.
I can add that column every moment.

I was trying , the help file and google search but struggling with the syntax being a newbie.
Also , can you give the command for select all - the entire list.

 

Link to comment
Share on other sites

@adityaparakh
Now you have the handle of the ListView.
You can use _GUICtrlListView_GetItemCount() to determine the number of items in the ListView.
This will give you the possibility to loop thorugh the ListView using _GUICtrlListView_GetItemTextArray(), which returns an array in which there are all the columns' values for the item (i-item in the loop); doing that, you can access to all ListView items, and all item columns' values.
Remember that the MTM you are looking for is in the 5th column (starting from 1), so, in your array, you'll have that value in the 4th column.
For the other things, look at _GUICtrlListView_* functions in the Help file :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

I did try a bit , @FrancescoDiMuro
It is able to retreive the column count and row count , but not the contents of cells.

Tried using a function from this page , that i dont make errors.

But just shows blank array dialog ,with zero contents.
 

Also , Should we rule out being able to access "MTM" below , and hence go for this list retrieval approach ?
When I googled "AfxFrameOrView100 AutoIt" , did find another post with a similar issue , which was eventually resolved by using a different handle of parent window.

 

 

Global $hdlListView = ControlGetHandle("Net Position - 126591", "", "SysListView321")
_GUICtrlListView_GetColumnCount ( $hdlListView )
Msgbox("","Column Count : ",_GUICtrlListView_GetColumnCount ( $hdlListView ))
MsgBox($MB_SYSTEMMODAL, "Information", "Row Count: " & _GUICtrlListView_GetItemCount($hdlListView))


$arr = _GUICtrlListView_GetContents($hdlListView)
_ArrayDisplay($arr)

Func _GUICtrlListView_GetContents($hdlListView)
    $iCol = _GUICtrlListView_GetColumnCount($hdlListView)
    If $iCol = 0 Then Return 0
    Dim $arrListView[1][$iCol]
    For $i = 0 to $iCol-1
        Local $Col=_GUICtrlListView_GetColumn($hdlListView,$i)
        $arrListView[0][$i]=$Col[5]
    Next
    $Col = 0
    $iRows = _GUICtrlListView_GetItemCount($hdlListView)
    For $i = 0 to $iRows-1
        Redim $arrListView[UBound($arrListView)+1][$iCol]
        $arrListView[UBound($arrListView)-1][0]=_GUICtrlListView_GetItemText($hdlListView,$i)
        For $j = 1 To $iCol-1
            $arrListView[UBound($arrListView)-1][$j]=_GUICtrlListView_GetItemText($hdlListView,$i,$j)
        Next
    Next
    Return $arrListView
EndFunc   ;==>_GUICtrlListView_GetContents

 

The List 4.png

Link to comment
Share on other sites

@adityaparakh
Happy to have helped :)
By the way, you could do something like that to get all the ListView items' values:

Spoiler
#include <Array.au3>
#include <GuiListView.au3>

Func _GUICtrlListView_GetListViewContent($hdlListView)

    Local $intLVRows = 0, _    ; Number of rows/items in the ListView
          $intLVColumns = 0, _ ; Number of columns/sub-items in the ListView
          $arrLVItemText, _    ; Array in which will be stored the content of each column of a given item
          $arrLVContent[0][0]  ; Array in which will be stored the whole content of the ListView

    
    ; Get the number of rows/item in the ListView
    $intLVRows = _GUICtrlListView_GetItemCount($hdlListView)

    ; Get the number of columns/sub-items in the ListView
    $intLVColumns = _GUICtrlListView_GetColumnCount($hdlListView)

    ; ReDim the array, so the values will fit into it
    Redim $arrLVContent[1][$intLVColumns]

    ; Loop through each ListView item/row and add the content to the "main" array
    For $i = 0 To $intLVRows - 1 Step 1
        $arrLVItemText = _GUICtrlListView_GetItemTextArray($hdlListView, $i)
        _ArrayDelete($arrLVItemText, 0) ; Remove the number of columns/sub-items from the array

        ; Add the content of the array in the "main" array
        _ArrayAdd($arrLVContent, _ArrayToString($arrLVItemText))
        If @error Then
            ConsoleWrite("Error while adding the element in the array. Error: " & @error & @CRLF)
            Return 0
        EndIf
    Next

    ; Delete the 0th element in the "main" array (which is blank)
    _ArrayDelete($arrLVContent, 0)

    Return $arrLVContent

EndFunc

 

29 minutes ago, adityaparakh said:

I am working on getting the sum of the columns and "SelectAll".

ControlListView("Net Position - 126591", "", $hdlListView, "SelectAll")
29 minutes ago, adityaparakh said:

Meanwhile can you confirm , that we were / will not be able to get the MTM value directly from the window ?

Just play a little bit with Control* functions :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@FrancescoDiMuro , thanks a ton.

I did try a lot for the MTM retreival directly.
Was not able. Treid all combinations of ControlGetText with the handle as suggested by Au Info tool - first screenshot.
If you do know how , please do help.

Else I am retreiving the full 2D array and using a second for loop after that to SUM Column I desire.
Not efficient , but thats the simplest way I am able to.

Two more questions :
Is it possible to press the "Refresh" button of the apllication - without changing focus.
I mean I can continue doing my work on Windows , while Autoit monitors the MTM and presses Refresh every second.
It is supposed to press SquareOff if MTM goes below a said value.

 

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...