Jump to content

Are you more clever than Au3Info and ControlViewer ?


Exit
 Share

Recommended Posts

I want to get information of a "WipeDisk" window.
 
post-45639-0-06332500-1397252573_thumb.j
 
The information is in a groupbox control. 
Au3Info and Controlviewer show only the progressbar  control, but no other controls with the text below the progressbar.
I need the sectorcount.
 
post-45639-0-78618700-1397253640_thumb.j
 
How to get the sectorcount text?
 
Here my first try.

;~ WipeDisk+

Exit _Main()

Func _Main()
    $handleW = WinGetHandle("WipeDisk")
    $handleG = ControlGetHandle($handleW, "", "TGroupBox3")
    $text = ControlGetText($handleG, "", "")
    MsgBox(262144, "Debug " & @ScriptName, "@Error: " & @error & @LF & "@Extended: " & @extended & @LF & $text, 0)
EndFunc   ;==>_Main

You might help me in testing it yourself.

Just download "WipeDisk" from http://www.gaijin.at/en/dlwipedisk.php

Extract the RAR archive and click "WipeDisk.exe"

There is the following startup panel.

post-45639-0-17028800-1397483465_thumb.j

Are you able to extract the text "0 %" ?

Please show me your solution.

Thanks in advance
Exit

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

You can try with the UI Automation framework.

Download the two UDFs in bottom of first post, and download and run the code in the "Simple spy demo" codebox in the middle of first post.

To verify that a control can be identified place the mouse cursor over the control and press Ctrl+w. You can see an example here.

Note that the framework is based on COM interface objects (created with ObjCreateInterface), so it's not just as easy to use as most built-in commands.

Link to comment
Share on other sites

Try this:

Var_GetAllWindowsControls2("WipeDisk")
Func Var_GetAllWindowsControls2($hCallersWindow)
    ; Get all list of controls
    $sClassList = WinGetClassList($hCallersWindow)
    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)
    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    Local $iCurrentClass = "", $iCurrentCount = 1, $iTotalCounter = 1

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        If IsArray($aPos) Then
            ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf
        If Not WinExists($hCallersWindow) Then ExitLoop
        $iTotalCounter += 1
    Next
EndFunc   ;==>Var_GetAllWindowsControls
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

You can try with the UI Automation framework.

Download the two UDFs in bottom of first post, and download and run the code in the "Simple spy demo" codebox in the middle of first post.

To verify that a control can be identified place the mouse cursor over the control and press Ctrl+w. You can see an example here.

Note that the framework is based on COM interface objects (created with ObjCreateInterface), so it's not just as easy to use as most built-in commands.

 

Thanks for the pointer. But the "simple spy demo" does not show the required control/text.  :thumbsdown:

 

 

Try this:

Var_GetAllWindowsControls2("WipeDisk")
Func Var_GetAllWindowsControls2($hCallersWindow)
    ; Get all list of controls
    $sClassList = WinGetClassList($hCallersWindow)
    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)
    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    Local $iCurrentClass = "", $iCurrentCount = 1, $iTotalCounter = 1

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        If IsArray($aPos) Then
            ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite("Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf
        If Not WinExists($hCallersWindow) Then ExitLoop
        $iTotalCounter += 1
    Next
EndFunc   ;==>Var_GetAllWindowsControls

 

This did the trick neither. :(

See the panel and the console output.

post-45639-0-88944800-1397491071_thumb.j

Any more ideas ?

TIA Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

You would send a screenshot, rather than the output (and cut-off, mind you)?

Looks like you can parse out the total, vs the current, to calculate the percentage.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

UI Automation works for me. If you hilite the progressbar you will get the text to the left in this variable:

UIA_LegacyIAccessibleValuePropertyId :=0%

If you start the program, you will get the progress percent in this variable. I have tested that on a USB memory stick.

Link to comment
Share on other sites

I've noticed that controls sometimes get hidden by their container, and AuInfo can't find them. Not sure why. However, all controls are named in predictable ways, e.g. "Edit1", "ListBox2" etc. These instance names are just strings, so they are easily constructed. I wrote a simple script that visits the first 50 (or whatever) control instance names and writing out the text. You can then usually match up the text in the control with the text printed out by the script.

Link to comment
Share on other sites

Yes, clicked, that is what the script I provided does.

Exit, it's possible that some of the controls you output can have child controls...but I cannot tell, since your output screenshot does not include the classnn.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

UI Automation works for me. If you hilite the progressbar you will get the text to the left in this variable:

UIA_LegacyIAccessibleValuePropertyId :=0%

If you start the program, you will get the progress percent in this variable. I have tested that on a USB memory stick.

 

The "0 %" on the initial screen was only a try to get more information about controls in a group-control.

I need the text below the progressbar. I need to monitor the change of the sectorcount, since my drive seems to pause sometimes for some seconds to some minutes. I want to prove this case and make a statistic of longer outages on certain sectors.  

There seems to be a hardware problem (recovery?) on the drive.

But as long as I can't access those sectorcount values, I am lost. :

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

Try this one, it will attempt to get child objects also

Func Var_GetAllWindowsControls2($hCallersWindow)
    If Not IsDeclared($iIndent) Then $iIndent=0
    ; Get all list of controls
    $sClassList = WinGetClassList($hCallersWindow)
    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)
    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    Local $iCurrentClass = "", $iCurrentCount = 1, $iTotalCounter = 1

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        If IsArray($aPos) Then
            ConsoleWrite( StringFormat("%" & $iIndent*2 & "s","") & "Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite( StringFormat("%" & $iIndent*2 & "s","") & "Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf
        If Not WinExists($hCallersWindow) Then ExitLoop

        $iIndent+=1
        Var_GetAllWindowsControls2($hControl)
        $iIndent-=1

        $iTotalCounter += 1
    Next
EndFunc   ;==>Var_GetAllWindowsControls

Please post out the console output, and not a screen shot.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Your code was not complete. Includes and a Global was missing.

Here my amended code.

#include <array.au3>
#include <winapiex.au3>
Global $iIndent =2

Exit Var_GetAllWindowsControls2("WipeDisk")

Func Var_GetAllWindowsControls2($hCallersWindow)
    If Not IsDeclared($iIndent) Then $iIndent = 0
    ; Get all list of controls
    $sClassList = WinGetClassList($hCallersWindow)
    ; Create array
    $aClassList = StringSplit($sClassList, @CRLF, 2)
    ; Sort array
    _ArraySort($aClassList)
    _ArrayDelete($aClassList, 0)

    ; Loop
    Local $iCurrentClass = "", $iCurrentCount = 1, $iTotalCounter = 1

    For $i = 0 To UBound($aClassList) - 1
        If $aClassList[$i] = $iCurrentClass Then
            $iCurrentCount += 1
        Else
            $iCurrentClass = $aClassList[$i]
            $iCurrentCount = 1
        EndIf

        $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
        $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
        $aPos = ControlGetPos($hCallersWindow, "", $hControl)
        $sControlID = _WinAPI_GetDlgCtrlID($hControl)
        If IsArray($aPos) Then
            ConsoleWrite(StringFormat("%" & $iIndent * 2 & "s", "") & "Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] Text=[" & $text & "]." & @CRLF)
        Else
            ConsoleWrite(StringFormat("%" & $iIndent * 2 & "s", "") & "Func=[Var_GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
        EndIf
        If Not WinExists($hCallersWindow) Then ExitLoop

        $iIndent += 1
        Var_GetAllWindowsControls2($hControl)
        $iIndent -= 1

        $iTotalCounter += 1
    Next
EndFunc   ;==>Var_GetAllWindowsControls2

And here the console output.

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Hubertus\Data\Autoit\try96.au3" /UserParams    
+>20:28:37 Starting AutoIt3Wrapper v.2.2.0.0 SciTE v.3.4.1.0   Keyboard:00000407  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0407)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Hubertus\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Hubertus\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Hubertus\Data\Autoit\try96.au3
+>20:28:38 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Hubertus\Data\Autoit\try96.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Func=[Var_GetAllWindowsControls]: ControlCounter=[  1] ControlID=[1181182] Handle=[0x001205FE] ClassNN=[           TButton1] XPos=[ 396] YPos=[  27] Width=[ 106] Height=[  46] Text=[Datenträger{@CRLF}{@CRLF}auswählen].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  2] ControlID=[2556642] Handle=[0x002702E2] ClassNN=[           TButton2] XPos=[ 381] YPos=[ 249] Width=[ 130] Height=[  25] Text=[Beenden].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  3] ControlID=[3539214] Handle=[0x0036010E] ClassNN=[           TButton3] XPos=[ 144] YPos=[ 249] Width=[ 130] Height=[  25] Text=[Stopp].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  4] ControlID=[2098182] Handle=[0x00200406] ClassNN=[           TButton4] XPos=[   9] YPos=[ 249] Width=[ 130] Height=[  25] Text=[Wipen].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  5] ControlID=[985048] Handle=[0x000F07D8] ClassNN=[         TCheckBox1] XPos=[   9] YPos=[ 153] Width=[ 502] Height=[  17] Text=[Protokollierung aktivieren].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  6] ControlID=[2230016] Handle=[0x00220700] ClassNN=[         TComboBox1] XPos=[ 111] YPos=[ 111] Width=[ 220] Height=[  21] Text=[Zero (1x)].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  7] ControlID=[854402] Handle=[0x000D0982] ClassNN=[         TGroupBox1] XPos=[   9] YPos=[   9] Width=[ 502] Height=[  76] Text=[Ausgewählter Datenträger].
Func=[Var_GetAllWindowsControls]: ControlCounter=[  1] ControlID=[1181182] Handle=[0x001205FE] ClassNN=[           TButton1] XPos=[ 396] YPos=[  27] Width=[ 106] Height=[  46] Text=[Datenträger{@CRLF}{@CRLF}auswählen].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[  2] ControlID=[8192896] Handle=[0x007D0380] ClassNN=[             TMemo1] XPos=[  18] YPos=[  27] Width=[ 376] Height=[  46] Text=[Physikalischer Datenträger 6{@CRLF}{@CRLF}Sektoren: 62.750.720 (512 Bytes/Sektor), Größe: 29,9 GB{@CRLF}{@CRLF}Removal Media].
    Func=[Var_GetAllWindowsControls]: ControlCounter=[  8] ControlID=[3278896] Handle=[0x00320830] ClassNN=[         TGroupBox2] XPos=[   9] YPos=[  93] Width=[ 502] Height=[  52] Text=[Löschmethode].
Func=[Var_GetAllWindowsControls]: ControlCounter=[  1] ControlID=[2230016] Handle=[0x00220700] ClassNN=[         TComboBox1] XPos=[ 111] YPos=[ 111] Width=[ 220] Height=[  21] Text=[Zero (1x)].
    Func=[Var_GetAllWindowsControls]: ControlCounter=[  9] ControlID=[3408838] Handle=[0x003403C6] ClassNN=[         TGroupBox3] XPos=[   9] YPos=[ 177] Width=[ 502] Height=[  64] Text=[Fortschritt].
Func=[Var_GetAllWindowsControls]: ControlCounter=[  1] ControlID=[853858] Handle=[0x000D0762] ClassNN=[      TProgressBar1] XPos=[  63] YPos=[ 197] Width=[ 439] Height=[  16] Text=[].
    Func=[Var_GetAllWindowsControls]: ControlCounter=[ 10] ControlID=[8192896] Handle=[0x007D0380] ClassNN=[             TMemo1] XPos=[  18] YPos=[  27] Width=[ 376] Height=[  46] Text=[Physikalischer Datenträger 6{@CRLF}{@CRLF}Sektoren: 62.750.720 (512 Bytes/Sektor), Größe: 29,9 GB{@CRLF}{@CRLF}Removal Media].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[ 11] ControlID=[853858] Handle=[0x000D0762] ClassNN=[      TProgressBar1] XPos=[  63] YPos=[ 197] Width=[ 439] Height=[  16] Text=[].
  Func=[Var_GetAllWindowsControls]: ControlCounter=[ 12] ControlID=[1378130] Handle=[0x00150752] ClassNN=[        TStatusBar1] XPos=[   0] YPos=[ 280] Width=[ 520] Height=[  19] Text=[Wipe Datenträger...].
+>20:28:38 AutoIt3.exe ended.rc:0
+>20:28:38 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.493

As you can see, the text below the progressbar is missing.

Here a screenshoot of the window again.

post-45639-0-42702600-1397500669_thumb.j

I need the text "8.374.912".

TIA Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

ah, the syntax was incorrect on the isdecalred...should be passed in as a string representing the variable name.

If Not IsDeclared("iIndent") Then Global $iIndent=0

You'll need to work with the UIAutomation.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Since there is no solution in grabbing the text, I think about grabbing the textimage with

_ScreenCapture_CaptureWnd() in a timed manner and then compare the two images if they have changed.

My problem is now:

How to compare those images?

_ScreenCapture_CaptureWnd() gives me a handle to a HBITMAP.

Can you please point me to the functions to use for this compare task?

Or a reference to some further readings.

TIA Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

I installed wipedisk and also unable to get the textline you are looking for. Somehow you cannot get into the childs of the TGroupbox.

However you can analyse that specific area with function(s) in 

'?do=embed' frameborder='0' data-embedContent>>

or search forum for

_GDIPlus_BitmapLockBits

As you need to analyse a small area you probably can make your own special Optical Character Recognition

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