Jump to content

Read Values out of Table on a Window


Recommended Posts

Hi all

First of all: I'm absolute AutoIt-rookie.

Now my "not so common" Problem:

How do I get values out of a table displayed in an Application window (not InternetExplorer/HTML).

==> All Details please see my attachement.

So far, I can get the window activated and the correct WindowHandle of the Table

But now, how do I get the values of the table e.g. into an array where I can check numbers?

The goal would be, to check every 30sec and if a line gets inserted into the Window that exceeds a certain amount (e.g. 1'000)

I'd like to get once a popup (MessageBox)

Your help will be much appreciated.

Jan

Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • Moderators

Jaenchen,

Welcome to the AutoIt forum. :(

All Details please see my attachement

If you were to actually attach the attachment, we might be able to do something. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Jaenchen,

The syntax for your ControlGetText command is not correct. You should be able to get the text without having to get all the handles first. Try this and see what it returns:

$sText = ControlGetText("FX daily deal blotter", "", "{CLASS:PaneWindowCL;INSTANCE:5]")
MsgBox(0, "", $sText)

If it returns nothing - what does the Window Info tool give in its "Visible Text" tab when over the PaneWindowCL?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi M23

Thanks for your quick response.

I'm getting an empty Messagebox and the visible Text Tab shows:

General

Release

SLC

E&Exit

On the Control Tab it shows nothing on the Line: Text

On the Form I've got 5 Instances

1 = ButtonBar

2 = StatusBar

3 = RadioButton Bar

4 = Bar where the Exit button is put on

5 = the Table with the data I want to check.

Regards

Jan

Link to comment
Share on other sites

  • Moderators

Jaenchen,

It looks as if these are custom-drawn controls rather than standard Windows items - which means that it might well prove difficult to interact with them.

However, let us not give up too quickly! :(

It looks like a ListView - perhaps it might act like one. Try this and see what you get:

$iNumber = ControlListView("FX daily deal blotter", "", "{CLASS:PaneWindowCL;INSTANCE:5]", "GetItemCount")
ConsoleWrite($iNumber & @CRLF)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23

This might be.

I've run your code and got:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "H:\AUTOIT_DEV\ATS_MONITOR.au3"

0

>Exit code: 0 Time: 0.324

seems not realy helpful.

I already was thinking about doing a printscreen and then re-read it with ORCB.... but this I might

choose as a "last solution".

Link to comment
Share on other sites

  • Moderators

Jaenchen,

I am afraid that my fears might be correct. I have been Googling a bit and there are painfully few references to PaneWindowCL controls and those I do find are ususally seeking help in reading them! :)

But you might be able to do a bit better than pure OCR on a screen grab. You have only 10 digits to match and well defined areas in which they appear - it would be possible to do some form of Pixel check on these areas and identify the digit there. Pixel functions are not blindingly fast, but looking at the timings you are dealing with, that will not be a problem. It also looks as if any new values pop in at the top of the list - which further reduces the difficulty.

Would you be interested in trying to develop something along those lines? :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23

Honestly, that's exactly what I expected. The application comes from IBM. No wonder everything is locked down.

I think I'll place a "change request" at the SW Provider ($$$$$$$$$). They should implement it on the next release....

But, I'm allways interested to learn new stuff so I'm also interested in your "Pixel solution".

Anyway, thank you so much for looking into my problem and thank you for the time you've spent to try to find

a solution.

Any further help is still appreciated.

Best Regards

Jan

Link to comment
Share on other sites

  • Moderators

Jaenchen,

Well, I am happy to give the "Pixel solution" a go - I need a new project at the moment. :(

Could you please let me have a another image of the window in question which contains a "6" - I need all 10 digits so that I can determine the different values returned when we scan the area containing each one. I take it the top line always has that lovely purple background and the digits are only the shown red and blue? I really only need that one digit in a small image - I can do the location calculations on the image you provided earlier.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

post-56750-12689292549762_thumb.gif

M23

Cool thing!

I'll send you an additional picture. Unfortunately, the colors are a bit messed up and are not purple.

For the 1s Row, the background seems to be allways light grey and the numbers will be in red and blue.

Do you think it might be a problem if I later add new columns that might move the monitored one further to the right?

good luck with the pic.

Jan

I'll also upload the numbers 1-10 in red and blue.

Edited by Jaenchen
Link to comment
Share on other sites

  • Moderators

Jaenchen,

All we (I) maybe then have to do is to change the parms of the monitored column in the dialog. right.

I just love the optimism displayed there! :)

I will keep you posted on progress (or the lack of it) via PM. Timings will, of course, depend on the weather at the golf course. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Jaenchen,

STOP!!!!!!!!!!!!!!!!!!!

I have all I need from the previous pictures. :) Here is a proof of concept script:

#include <GUIConstantsEx.au3>
#include <Array.au3>

; All pixel functions relative to window client area
Opt("PixelCoordMode", 2)

; Array of digit and sign breakdown
Global $aChecks[12] = [ _
"011110100001100001100001100001100001100001100001100001011110", _
"000100001100010100000100000100000100000100000100000100000100", _
"011110100001000001000001000001000010000100001000010000111111", _
"011110100001000001000001001110000001000001000001100001011110", _
"000010000110000110001010001010010010010010111111000010000010", _
"011111010000010000100000111110100001000001000001100001011110", _
"011110100001100000100000101110110001100001100001100001011110", _
"111111000010000010000100000100001000001000010000010000010000", _
"011110100001100001100001011110100001100001100001100001011110", _
"011110100001100001100001100011011101000001000001100010011100", _
"000000000000000100000100000100111111000100000100000100000000", _
"000000000000000000000000000000000000000111000000000000000000"]

; Coords of zones to check
Global $aX_Coords[9] = [96, 103, 110, 114, 121, 128, 135, 146, 153]
$iY_Coord = 128

; Create a GUI to show the window image
$hGUI = GUICreate("Test", 500, 500)
$hPic = GUICtrlCreatePic("Pane2.bmp", 10, 10, 318, 433)
GUISetState()

; Move down line by line
For $iY_Index = 0 To 14

    ; Check colour of background
    $iBackgroundColour = Hex(PixelGetColor(96, $iY_Coord + ($iY_Index * 16) - 1, $hGUI), 6)

    ; Zero the number
    $sNumber = ""

    ; Move through the digit/sign spaces from left
    For $iX_Index = 0 To 8

        ; Move through the space
        $sString = ""
        For $y = 0 To 9
            For $x = 0 To 5
                $sColour = Hex(PixelGetColor($aX_Coords[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $hGUI), 6)
                ; Depending on teh background colour - look for the correct text colout and set the bit
                If $iBackgroundColour = "0000F8" Then
                    If $sColour = "FFFFFF" Then
                        $sString &= "1"
                    Else
                        $sString &= "0"
                    EndIf
                Else
                    If $sColour = "0000F8" Or $sColour = "F80000" Then
                        $sString &= "1"
                    Else
                        $sString &= "0"
                    EndIf
                EndIf
            Next
        Next

        ; Check in the index for a match
        $iIndex = _ArraySearch($aChecks, $sString)

        ; Add the correct digit/sign to the list
        Switch $iIndex
            Case 0 To 9
                $sNumber &= $iIndex
            Case 10
                $sNumber &= "+"
            Case 11
                $sNumber &= "-"
        EndSwitch

        If $iX_Index = 2 Then
            ; If we did not find a digit at the thousands point, check for a sign
            ; If we did,  add a comma
            If $iIndex > 0 Then
                $iX_Index = 3
                $sNumber &= ","
            Else

            EndIf
        EndIf

        ; Add the decimal at the correct point
        If $iX_Index = 6 Then $sNumber &= "."

    Next

    ; Display the list for each line
    ConsoleWrite($sNumber & @CRLF)

Next

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

You will need this image:

It looks quite promising so far - the proof will be when we try on your screen! I will try and get the whole thing such that you need only enter 2 coordinates for it to work.

But that may be for tomorrow! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Jaenchen,

My lot for today - here is a more advanced version of the script. :)

When you run it, do NOT move the mouse. A small cross appears on the GUI to the right of "Amount1" - you should use the cursor keys to place it exactly over the grey line intersection just above and to the right of the +420.00 number. Once you have it in place, press Enter and you should get a read out of the numbers in the column as before. If I have it correct, the same code should work directly on your window - but we need to take things one step at a time. :)

Anyway try it and see what you think - use the same image as last time:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc

; All pixel functions relative to window client area
Opt("PixelCoordMode", 2)

; Array of digit and sign breakdown
Global $aChecks[12] = [ _
"011110100001100001100001100001100001100001100001100001011110", _
"000100001100010100000100000100000100000100000100000100000100", _
"011110100001000001000001000001000010000100001000010000111111", _
"011110100001000001000001001110000001000001000001100001011110", _
"000010000110000110001010001010010010010010111111000010000010", _
"011111010000010000100000111110100001000001000001100001011110", _
"011110100001100000100000101110110001100001100001100001011110", _
"111111000010000010000100000100001000001000010000010000010000", _
"011110100001100001100001011110100001100001100001100001011110", _
"011110100001100001100001100011011101000001000001100010011100", _
"000000000000000100000100000100111111000100000100000100000000", _
"000000000000000000000000000000000000000111000000000000000000"]

; Create a GUI to show the window image
$hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP)
$hPic = GUICtrlCreatePic("Pane2.bmp", 0, 0, 318, 433)
GUISetState()

Global $iX_Cross, $iY_Cross
;$iX_Cross = 151
;$iY_Cross = 115

Global $aPos = WinGetPos($hGUI)
;ConsoleWrite($aPos[0] & " - " & $aPos[1] & @CRLF)

Mark_Cross($aPos[0] + 150, $aPos[1] + 110)

;ConsoleWrite($iX_Cross & " - " & $iY_Cross & @CRLF)

$iX_Cross -= ($aPos[0])
$iY_Cross -= ($aPos[1])

;ConsoleWrite($iX_Cross & " - " & $iY_Cross & @CRLF)

; Coords of zones to check
Global $aX_Coords[9] = [65, 58, 51, 47, 40, 33, 26, 15, 8]
$iY_Coord = $iY_Cross + 3

; Move down line by line
For $iY_Index = 0 To 14

    ; Check colour of background
    $iBackgroundColour = Hex(PixelGetColor($iX_Cross - 1, $iY_Coord + ($iY_Index * 16) + 1, $hGUI), 6)

    ; Zero the number
    $sNumber = ""

    ; Move through the digit/sign spaces from left
    For $iX_Index = 0 To 8

        ; Move through the space
        $sString = ""
        For $y = 0 To 9
            For $x = 0 To 5
                ;$sColour = Hex(PixelGetColor($aX_Coords[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $hGUI), 6)
                $sColour = Hex(PixelGetColor($iX_Cross - $aX_Coords[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $hGUI), 6)
                ; Depending on teh background colour - look for the correct text colout and set the bit
                If $iBackgroundColour = "0000F8" Then
                    If $sColour = "FFFFFF" Then
                        $sString &= "1"
                    Else
                        $sString &= "0"
                    EndIf
                Else
                    If $sColour = "0000F8" Or $sColour = "F80000" Then
                        $sString &= "1"
                    Else
                        $sString &= "0"
                    EndIf
                EndIf
            Next
        Next

        ; Check in the index for a match
        $iIndex = _ArraySearch($aChecks, $sString)

        ; Add the correct digit/sign to the list
        Switch $iIndex
            Case 0 To 9
                $sNumber &= $iIndex
            Case 10
                $sNumber &= "+"
            Case 11
                $sNumber &= "-"
        EndSwitch

        If $iX_Index = 2 Then
            ; If we did not find a digit at the thousands point, check for a sign
            ; If we did,  add a comma
            If $iIndex > 0 Then
                $iX_Index = 3
                $sNumber &= ","
            Else

            EndIf
        EndIf

        ; Add the decimal at the correct point
        If $iX_Index = 6 Then $sNumber &= "."

    Next

    ; Display the list for each line
    ConsoleWrite($sNumber & @CRLF)

Next

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func Mark_Cross($iX_Mark, $iY_Mark)

    Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp
    Local $UserDLL = DllOpen("user32.dll")

    ; Create transparent GUI with Cross cursor
    $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    WinSetTrans($hCross_GUI, "", 8)
    GUISetState(@SW_SHOW, $hCross_GUI)
    GUISetCursor(3, 1, $hCross_GUI)

    MouseMove($iX_Mark, $iY_Mark, 0)

    ; Wait for adjustments
    While 1
        If _IsPressed("25", $UserDLL) Then
            $iX_Mark -= 1
            While _IsPressed("25", $UserDLL)
                Sleep(10)
            WEnd
            MouseMove($iX_Mark, $iY_Mark)
        EndIf
        If _IsPressed("26", $UserDLL) Then
            $iY_Mark -= 1
            While _IsPressed("26", $UserDLL)
                Sleep(10)
            WEnd
            MouseMove($iX_Mark, $iY_Mark)
        EndIf
        If _IsPressed("27", $UserDLL) Then
            While _IsPressed("27", $UserDLL)
                Sleep(10)
            WEnd
            $iX_Mark += 1
            MouseMove($iX_Mark, $iY_Mark)
        EndIf
        If _IsPressed("28", $UserDLL) Then
            While _IsPressed("28", $UserDLL)
                Sleep(10)
            WEnd
            $iY_Mark += 1
            MouseMove($iX_Mark, $iY_Mark)
        EndIf
        If _IsPressed("0D", $UserDLL) Then
            $iX_Cross = $iX_Mark
            $iY_Cross = $iY_Mark
            GUIDelete($hCross_GUI)
            DllClose($UserDLL)
            Return
        EndIf
    WEnd

EndFunc   ;==>Mark_Cross

Press ESC to exit - the [X] on the GUI does not really exist! ;)

I will continue refining the script tomorrow afternoon - I want to work more on the cross positioning section. The forecast is good, so you can guess where I will be in the morning! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hey M23!

This is just a real amazing work you're doing here! Absolutely great stuff.

I did run the script as you mentionned and I'm getting all the numbers correctly. Unbeleavable!

I'm totally impressed of your work here. That's allmost magic!

Maybe an additional quick info from my side. As I have a 3840*1024 Screen resolution, and new popups apearing in the middle of the screen. Somehow it didn't work well. But as I have reduced the resolution to 1280x1024 it worked perfectly.

I'm allready exited about the next steps and happy to learn more about autoit. I hope, this is also interesting for other members here and can be reused by them.

talk to you later!

:(

Jan

Link to comment
Share on other sites

  • Moderators

Jaenchen,

The latest version, which reads the GMT and Amount1 columns into an array:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

; #################################################################################

; Simulate the app by creating a GUI to show an image of the app
$hGUI = GUICreate("Test", 500, 500, 800, 200, $WS_POPUP)
$hPic = GUICtrlCreatePic("M:\Program\Au3 Scripts\Images\Pane2.bmp", 0, 0, 318, 433)
GUISetState()

; #################################################################################

; Set exit strategy
HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

; Array of digit and sign codes
Global $aChecks[12] = [ _
        "011110100001100001100001100001100001100001100001100001011110", _
        "000100001100010100000100000100000100000100000100000100000100", _
        "011110100001000001000001000001000010000100001000010000111111", _
        "011110100001000001000001001110000001000001000001100001011110", _
        "000010000110000110001010001010010010010010111111000010000010", _
        "011111010000010000100000111110100001000001000001100001011110", _
        "011110100001100000100000101110110001100001100001100001011110", _
        "111111000010000010000100000100001000001000010000010000010000", _
        "011110100001100001100001011110100001100001100001100001011110", _
        "011110100001100001100001100011011101000001000001100010011100", _
        "000000000000000100000100000100111111000100000100000100000000", _
        "000000000000000000000000000000000000000111000000000000000000"]

; Array to hold numbers read from app
Global $aArray[15][2]

; Coords of the 2 points user will mark
Global $iX_Cross_1, $iY_Cross_1, $iX_Cross_2, $iY_Cross_2

; Find position of the app window
Global $aPos = WinGetPos($hGUI)

; Get user to mark the points
Mark_Cross()

; Find colon in GMT column
Find_Colon()

; Read the numbers in GMT and Amount1 columns
Read_Numbers()

_ArrayDisplay($aArray)

While 1
    Sleep(10)
WEnd

; ~~~~~ Functions ~~~~~

Func Find_Colon()

    ; Set Y coord
    $iY_Coord = $iY_Cross_1 + 3

    ; Check colour of background
    $iBackgroundColour = Hex(PixelGetColor($iX_Cross_1 - 1, $iY_Coord, $hGUI), 6)

    ; Move across app window to find colon
    For $x = $iX_Cross_1 To $aPos[0] Step -1
        $sString = ""
        For $y = 0 To 9
            $sString &= GMT_Pixel($x, $iY_Coord + $y, $iBackgroundColour)
        Next
        ; Found it
        If $sString = "0001000001" Then ExitLoop
    Next

    ; Reset the coordinate to the colon
    $iX_Cross_1 = $x

EndFunc   ;==>Find_Colon

Func Read_Numbers()

    ; Coords of zones to check for digit/sign
    Local $aX_Coords_1[4] = [-15, -8, 3, 10]
    Local $aX_Coords_2[9] = [65, 58, 51, 47, 40, 33, 26, 15, 8]
    $iY_Coord = $iY_Cross_1 + 3

    ; Move down line by line
    For $iY_Index = 0 To 14

        $iBackgroundColour = Hex(PixelGetColor($iX_Cross_1 - 1, $iY_Coord + ($iY_Index * 16) + 1, $hGUI), 6)

        ; Start in the GMT column

        ; Zero the code
        $sCode = ""

        ; Move through the digit/sign spaces from left
        For $iX_Index = 0 To 3

            ; Move through the space to build the code
            $sString = ""
            For $y = 0 To 9
                For $x = 0 To 5
                    $sString &= GMT_Pixel($iX_Cross_1 + $aX_Coords_1[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $iBackgroundColour)
                Next
            Next

            ; Check in the index for a match
            $iIndex = _ArraySearch($aChecks, $sString)

            ; Add the correct digit/sign to the list
            Switch $iIndex
                Case 0 To 9
                    $sCode &= $iIndex
            EndSwitch

            ; Add colon in correct place
            If $iX_Index = 1 Then $sCode &= ":"

        Next

        ; Store the GMT
        $aArray[$iY_Index][0] = $sCode

        ; Now move on to the Amount1 column

        ; Zero the code
        $sCode = ""

        ; Move through the digit/sign spaces from left
        For $iX_Index = 0 To 8

            ; Move through the space
            $sString = ""
            For $y = 0 To 9
                For $x = 0 To 5
                    $sColour = Hex(PixelGetColor($iX_Cross_2 - $aX_Coords_2[$iX_Index] + $x, $iY_Coord + ($iY_Index * 16) + $y, $hGUI), 6)
                    ; Depending on the background colour - look for the correct text colour and set the code
                    If $iBackgroundColour = "0000F8" Then
                        If $sColour = "FFFFFF" Then
                            $sString &= "1"
                        Else
                            $sString &= "0"
                        EndIf
                    Else
                        If $sColour = "0000F8" Or $sColour = "F80000" Then
                            $sString &= "1"
                        Else
                            $sString &= "0"
                        EndIf
                    EndIf
                Next
            Next

            ; Check in the index for a match
            $iIndex = _ArraySearch($aChecks, $sString)

            ; Add the correct digit/sign to the list
            Switch $iIndex
                Case 0 To 9
                    $sCode &= $iIndex
                Case 10
                    $sCode &= "+"
                Case 11
                    $sCode &= "-"
            EndSwitch

            If $iX_Index = 2 Then
                ; If we did not find a digit at the thousands point, check for a sign
                ; If we did, add a comma
                If $iIndex > 0 Then
                    $iX_Index = 3
                    $sCode &= ","
                EndIf
            EndIf

            ; Add the decimal at the correct point
            If $iX_Index = 6 Then $sCode &= "."

        Next

        ; Store the Amount 1
        $aArray[$iY_Index][1] = $sCode

    Next

EndFunc   ;==>Read_Numbers

Func GMT_Pixel($iX_Pixel, $iY_Pixel, $iBackgroundColour)

    $sColour = Hex(PixelGetColor($iX_Pixel, $iY_Pixel, $hGUI), 6)
    ; Depending on the background colour - look for the correct text colour and set the code
    If $iBackgroundColour = "0000F8" Then
        If $sColour = "FFFFFF" Then
            Return "1"
        Else
            Return "0"
        EndIf
    Else
        If $sColour = "080000" Then
            Return "1"
        Else
            Return "0"
        EndIf
    EndIf

EndFunc   ;==>GMT_Pixel

Func Mark_Cross()

    Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp

    SplashImageOn("Place the cross here", "M:\Program\Au3 Scripts\Images\fxddb_Splash_1.jpg", 165, 41)

    $aRet = Move_Cross($aPos[0] + 50, $aPos[1] + 110)
    $iX_Cross_1 = $aRet[0]
    $iY_Cross_1 = $aRet[1]

    SplashImageOn("Place the cross here", "M:\Program\Au3 Scripts\Images\fxddb_Splash_2.jpg", 165, 41)

    $aRet = Move_Cross($aPos[0] + 150, $aPos[1] + 110)
    $iX_Cross_2 = $aRet[0]
    $iY_Cross_2 = $aRet[1]

    SplashOff()

EndFunc   ;==>Mark_Cross

Func Move_Cross($iX_Mark, $iY_Mark)

    Local $aRet[2]

    Local $UserDLL = DllOpen("user32.dll")

    ; Create transparent GUI with Cross cursor
    $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    WinSetTrans($hCross_GUI, "", 8)
    GUISetState(@SW_SHOW, $hCross_GUI)
    GUISetCursor(3, 1, $hCross_GUI)

    MouseMove($iX_Mark, $iY_Mark, 0)

    ; Wait for adjustments or confirmation
    While 1
        If _IsPressed("25", $UserDLL) Then
            $iX_Mark -= 1
            While _IsPressed("25", $UserDLL)
                Sleep(10)
            WEnd
        EndIf
        If _IsPressed("26", $UserDLL) Then
            $iY_Mark -= 1
            While _IsPressed("26", $UserDLL)
                Sleep(10)
            WEnd
        EndIf
        If _IsPressed("27", $UserDLL) Then
            While _IsPressed("27", $UserDLL)
                Sleep(10)
            WEnd
            $iX_Mark += 1
        EndIf
        If _IsPressed("28", $UserDLL) Then
            While _IsPressed("28", $UserDLL)
                Sleep(10)
            WEnd
            $iY_Mark += 1
        EndIf
        If _IsPressed("0D", $UserDLL) Then
            $aRet[0] = $iX_Mark
            $aRet[1] = $iY_Mark
            GUIDelete($hCross_GUI)
            DllClose($UserDLL)
            Return $aRet
        EndIf

        MouseMove($iX_Mark, $iY_Mark)

    WEnd

EndFunc   ;==>Move_Cross

You will also need these 2 small images which show where to place the "cross" on the GUI.

Now we need to talk about what you want to do with the values we have captured. :( You initially spoke about getting a popup when the amount went over a certain value. Do you wish this value to be user-selectable at any time? Does it matter if the amount is positive or negative? How many changes might you expect per minute (the most I have seen on the images you suppled is 2)? If there is more than one change in a minute (because there seems little point in reading the app window more often) do you want to be advised just the once, or for each event if they all meet the criterion? And I am sure there are many more details that I have not thought of yet - so over to you. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23!

Wonderful! It works perfect! I hope you had a good day and the weather was as perfect for you as your app is for me. :-)

As you correctly assumed, I've forgotten one thing to mention.

We also need to monitor the Curr.1, weather it's XAU, XAG, XPD, XPT because of then we can allocate different Curr.1_LIMITS.

CCY1_LIMITs are stale (not user selectable)

XAU=1000.00

XAG=25000.00

XPD=1000.00

XPT=1000.00

What to do with the values?

a) check if curr1/amount exceeds the CCY1_LIMIT, if exceeds ==> :(

:) if the Amount1 is (+) then the messagebox should say

"YOU BUY {CCY1} {AMOUNT1}"

else

"YOU SELL {CCY1} {AMOUNT1}"

If possible, the msgbox {info} should be

- quite good visible on the screen (big font / color maybe yellow),

- "allways on top",

- possible TITLE: "NEW TRADE"

- absolutely optional but very cool :-) would be a signal beep or whatever.

Oh! I've just realized, we've got the total of trades at the statusbar, in this case it's 31. So maybe you could check every nTime (as many as possible per minute) if this number changed and if it changed, e.g. from 31 to 35 (less or more) then check the lines 1 to x(35-31=4) and popup do the msgbox for each row.

So far that's it! Honestly I feel a bit like as it's Christmas :-) or even better like I'm Aladdin and you're the genius that comes

out of the lamp and say's "Your with will become true".

You are just great!

Have nice Weekend and enjoy!

Of course, there's no rush for the next peace of your super-code.

Thanks!

Jan

PS: I had to remove the path for the pictures (M:\Program\Au3 Scripts\Images\)

post-56750-12690208776993_thumb.gif

Link to comment
Share on other sites

  • Moderators

Jaenchen,

All understood - easy to do everything you want. :) I just hope you do not have any more surprises lurking away in your bottom drawer! ;)

I am not too keen on reading the status bar - it would mean another cross for the user to position if nothing else (I can keep it to 2 crosses even with the new column). What I envisage doing is looking to see if the top line has changed - if it has there is a new trade to examine. From what I can see you do not get the same value trade at the same time - any at exactly the same time look like mirror images with one positive and one negative in value. So I think my plan will work - but as I said before, the acid test will be when we try and read your desktop. :(

But first I need a better definiton picture of the app with the currency column showing to work out the patterns for the letters - and to run tests. Again if you could provide one with all 4 currency options that would be excellent. I am pretty sure that I have got it right from your last attachment - but at full scale it is too blurred to be sure and the letters/numbers will not read correctly. The previous attachments were much clearer - I do not know what you did when you screen-grabbed before, but please do it again! :D

Have nice Weekend

Und Sie auch! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Jaenchen,

A bit of work with Paint has let me work on the script this weekend. Here is the current version which simulates updates as you run it.

Start the script and it runs like this:

1. We simulate a blank app to begin with. The user has to position the 2 crosses - and has nice little hint images alongside to show him/her where to put them. On the first run, the crosses are close(ish) to the correct places - however the script will save the positions set by the user in an ini file so that if the columns are not adjusted the crosses will be only 1 pixel off on subsequent runs to make it less tiresome.

2. A MsgBox tells you that the first simulated update is about to take place and tells you to press "Ctrl-U" when you are ready for the second. On pressing "OK", the simulated update takes place and an alert in generated. The script keeps checking every 10 seconds for updates - but of course there will not be any until you press "Ctrl-U".

3. When you do decide to simulate the second update by pressing "Ctrl-U", you get a further MsgBox confirming this. Again, after pressing "OK", the script checks for any new values and generates the appropriate alerts.

4. Nothing more happens, so exit the script by pressing "ESC" or via the tray menu.

Other changes:

- I already mentioned the ini file to keep track of where the crosses were last positioned so as to save a bit of time when the script is rerun.

- There is a bit of checking done to make sure the crosses are correctly positioned - we can get a lot better at this when we run the script on the real app and can use the actual colours.

- The tray icon menu now offers an Exit option (and an About message).

- A lot of cosmetic stuff on the code and the GUIs.

You will need to unzip this file and run the script with all the files in same folder:

Let me know if you need any changes.

There are a couple of points which still need to be determined before we try the script on the real thing:

1. I would like an image of the "D" letter from the screen to confirm what I believe is the pattern to match,

2. I would like to know the number of pixels between the vertical line at the left of the "Curr.1" column (where we place the first cross) and the leftmost pixel of the third letter in the currency code. You can do this with the Au3 Window Info tool which you find at "C:\Program Files\AutoIt3\Au3Info.exe" with a standard AutoIt install. Select the "Mouse" tab and then move the target into the correct places on the app and read the values shown. You can use the <Options - Magnify> menu item to get a better guide as to where to place the cursor. I am currently using a figure of 20 pixels based on the blurred image you sent. Alternatively, send me a better quality picture!

Once I have those values, we should be ready to test on the real thing. :)

When everything is working well, we can compile the script with the small example images within it so you have only the one executable to load every time - but that is for the future.

M23

P.S. Please read the About box carefully - you get to it via the tray icon menu. :(

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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