Jump to content

Using Data from Window Info


daashag
 Share

Recommended Posts

  • Moderators

Is it possible to grab data from the WindowInfo specifically data under the Visible Text and pass it to a variable that can be used later in the script. If so how would I do this? Thanks

Look at WinGetText()/ControlGetText() they both have examples of how to do it with a variable.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Look at WinGetText()/ControlGetText() they both have examples of how to do it with a variable.

Thanks for our reply SmOke_N

Having problems getting this to work.

This is what I am doing.

When the window comes up I use WindowInfo tool and highligt the field for the backup destination.

I then take the title and control ID from the windowInfo tool to use in the following code.

The text I want to grab and pass to a variable is a file location ie X:/exact/backup/

It shows up as Visisble Text on the windowInfo tool.

WindowInfo

Press CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Create backup

Class: ThunderRT6FormDC

Size: X: 257 Y: 298 W: 885 H: 453

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 889 Y: 522

Cursor ID: 5

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x000000 Dec: 0

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 191 Y: 190 W: 487 H: 21

Control ID: 17228132

ClassNameNN: FipEdit19

Text:

Style: 0x56000080

ExStyle: 0x00000200

(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

&Cancel

&Back

&Next

F&inish

Progress Bar

001

x:\exactglobe\backups\20061117-scrapbook mate.ebu <--Text I want to grab

TROON

Create backup

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

&Details

&Advanced

X:\ExactGlobe\Backups\

X:\ExactGlobe\Database

20061117-Scrapbook Mate

Create backup

Create backup

Restore backup

;Get name of backupfile
$bkupdst = ControlGetText("Create backup", "", "17228084")
 MsgBox(0, "Example", "My variable is " & $bkupdst)

The 2nd line returns a box that just says "ok"

I know this is pretty basic stuff but I am totally lost. Thanks

Edited by daashag
Link to comment
Share on other sites

;Get name of backupfile
$bkupdst = ControlGetText("Create backup", "", "17228084")
 MsgBox(0, "Example", "My variable is " & $bkupdst)

This little bit just gives me a message box saying My variable is OK

Shouldn't it return the value of the control ID?

I have tried it on different windows and programs all return My variable is OK. Is this right or am I doing something wrong? Thanks

Link to comment
Share on other sites

  • Moderators

$WinText = WinGetText('Some window')
$aArray = _StringBetween($WinText, '001', 'TROON', -1, 1)
If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])

_StringBetween() is in the 3.2.1.12 beta.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The window info you posted shows the control ID as 17228132 but your read is reading 17228084. Check the control ID again, you might have the wrong control.

The control ID is correct in the code. Not sure where the other one came from. Here is the correct window info.

ress CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Create backup
Class:  ThunderRT6FormDC
Size:   X: 114  Y: 152  W: 885  H: 453

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 740  Y: 374
Cursor ID:  5

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0x292C31   Dec: 2698289

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:       X: 191  Y: 190  W: 487  H: 21
Control ID: 17228084
ClassNameNN:    FipEdit19
Text:       
Style:      0x56000080
ExStyle:        0x00000200
(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Cancel
&Back
&Next
F&inish
Progress Bar
001
x:\exactglobe\backups\20061118-scrapbook mate.ebu
TROON
Create backup

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&Details
&Advanced
X:\ExactGlobe\Backups\
X:\ExactGlobe\Database
20061118-Scrapbook Mate
Create backup
Create backup
Restore backup
Copy company
My computer
My computer
Server
001

How do I grab the text containing x:\exactglobe\backups\20061118-scrapbook mate.ebu

I can't hard code it because that text changes each time I run the script.

Thanks

Link to comment
Share on other sites

  • 3 weeks later...

I am able to grab the text as the output of

CODE
$WinText = WinGetText('Create backup')

$aArray = _StringBetween($WinText, '001', 'TROON', -1, 1)

If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])

Gives me " x:\exactglobe\backups\20061118-scrapbook mate.ebu"

But the following code doesn't work. It only works if I hard code the value of $aArray[0], it won't work with just using $aArray

CODE
;Wait for backup to finish

Do

WinWaitNotActive("Create Backup", "")

Until FileExists($aArray[0]) If I use Until FileExist("x:\exactglobe\backups\20061118-scrapbook mate.ebu") it works fine

MsgBox(0, "Example", "My variable is ")

My question is how to I use the $aArray[0] with the FileExist function?

Thanks

Link to comment
Share on other sites

I am able to grab the text as the output of

CODE
$WinText = WinGetText('Create backup')

$aArray = _StringBetween($WinText, '001', 'TROON', -1, 1)

If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])

Gives me " x:\exactglobe\backups\20061118-scrapbook mate.ebu"

But the following code doesn't work. It only works if I hard code the value of $aArray[0], it won't work with just using $aArray

CODE
;Wait for backup to finish

Do

WinWaitNotActive("Create Backup", "")

Until FileExists($aArray[0]) If I use Until FileExist("x:\exactglobe\backups\20061118-scrapbook mate.ebu") it works fine

MsgBox(0, "Example", "My variable is ")

My question is how to I use the $aArray[0] with the FileExist function?

Thanks

There is a space in front of x. If there is a space before it, it messes up the whole file path.

Local $s_path = StringStripWS ($aArray[0],1)

Do
    WinWaitNotActive("Create Backup", "")
Until FileExists($s_path)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

There is a space in front of x. If there is a space before it, it messes up the whole file path.

Local $s_path = StringStripWS ($aArray[0],1)

Do
    WinWaitNotActive("Create Backup", "")
Until FileExists($s_path)
Thanks for your response Kandie, Actually the space before the x is just a cut and paste thing. Sorry about that. I tried your code and it passes the value of $aArray to $s_path but FileExist function still does not work unless I explicitly give the path of "x:\exactglobe\backups\20061117-scrapbook mate.ebu"

Thanks

Link to comment
Share on other sites

The code that SmOke_N posted gives me this output:

x:\exactglobe\backups\20061118-scrapbook mate.ebu

FileExist will require quotes around that path because it has a space between scrapbook and mate.

Or maybe I'm not understanding something here.

Please post the code that you used to "explicitly give the path of"...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

The code that SmOke_N posted gives me this output:

x:\exactglobe\backups\20061118-scrapbook mate.ebu

FileExist will require quotes around that path because it has a space between scrapbook and mate.

Or maybe I'm not understanding something here.

Please post the code that you used to "explicitly give the path of"...

Thanks for the reply. Heres the code that will work. But I can't explicitly give the path because the path changes everyday.

;Wait for backup to finish
Do
    WinWaitNotActive("Create Backup", "")
Until FileExists("x:\exactglobe\backups\20061208-scrapbook mate.ebu")
MsgBox(0, "Example", "Found file")
Link to comment
Share on other sites

this fails for me also

#include <String.au3>
$WinText = "Progress Bar" & @CR & _
        "001" & @CR & _
        "C:\Program Files\AutoIt3\Au3Info.exe" & @CR & _
        "TROON"
$aArray = _StringBetween($WinText, '001', 'TROON', -1, 1)
If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])
MsgBox(0, "FileExists Array", FileExists($aArray[0]))
MsgBox(0, "FileExists", FileExists("C:\Program Files\AutoIt3\Au3Info.exe"))
Edit: I see no reason for it to fail.

Maybe someone else can see why it fails.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Ok not exactly sure what you were doing there. So if you search for a file with a variable it fails but if you search for a file with a path it finds it. So are you thinking this is some kind of limitation in the FileExist function?

Thanks

Link to comment
Share on other sites

I was just making a test string to feed the code that your are using.

You may have a real non-printable character in front of your path string.

That is what has caused the sample code that I posted to fail.

If you use this little code after my sample code you will "see" that the first character is "blank".

$temp = StringSplit($aArray[0], "")
For $i = 1 To $temp[0]
    MsgBox(0, "", $temp[$i])
Next
If you add that to your code, you may find the same thing.

Edit: I could not spell character - even though I've been told that I am one.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

This sample works now

#include <String.au3>
$WinText = "Progress Bar" & @CR & _
        "001" & @CR & _
        "C:\Program Files\AutoIt3\Au3Info.exe" & @CR & _
        "TROON"
$aArray = _StringBetween($WinText, '001', 'TROON', -1, 1)
If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])

MsgBox(0, "", FileExists(StringStripWS($aArray[0], 3)))oÝ÷ Ù'­×hzÇè¯*.r^Ø­bØ^®¯zÚ,¶¸©¶jºÚzÛ«Çë¢m7é +­¬´¢·!jx­ʭéh¢H§·­Áç§jëh×6#include <String.au3>
$WinText = "Progress Bar" & @CR & _
        "001" & @CR & _
        "C:\Program Files\AutoIt3\Au3Info.exe" & @CR & _
        "TROON"
$aArray = _StringBetween($WinText, '001' & @CR, @CR & 'TROON', -1, 1)
If IsArray($aArray) Then MsgBox(64, 'Info', $aArray[0])

MsgBox(0, "", FileExists($aArray[0]))
You are better off using the first method with StringStripWS

Edit2:at least that is what it took in my sample code. I'm not sure what your application may be putting in $aArray[0]

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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