Jump to content

How to find text within Visible Window Text


Recommended Posts

I'd like to know how to wait for text in a window and perform an operation if it finds the text.

The program I am trying to get the test from is AboutTime.

The window may look like this:

ControlTime Client

Set Time

Cancel

Hide

Exit

Connecting to NIST using SNTP.

Resolved address for NIST (192.43.244 .18).

timed out waiting for NIS.

Connecting to NASA using SNTP .

Looking up address for n.arc.nasa.gov .

Resolved address for NASA 128 .102.16 2 ).

timed out waiting for NAS.

Connecting to U.S.Naval Observatory using SNTP .

Looking up address for ti.usno navy .mi.

Resolved address for U.S.Naval Observatory (192 5 41 .40).

Received time ping 100 ms ), erro-126133524 ms.

New time: Saturday, March 10 ,2007 12 :34:10.

---Activity Lo---

Log to File

If the text "New time:" shows in the window I can Exit

If the text "No time servers available." I need to ControlClick('AboutTime 4.8', '--- Activity Log ---', 'Button1') and go in a loop to keep checking the text.

My problem is the AutoIt Window Info tool doesn't show a constant controlID so I could use $var = ControlGetText("AboutTime 4.8", "No time servers available.", "?")

And I don't know how to identify when $text = WinGetText("AboutTime 4.8", "")

shows the text I am looking for. I'm guessing I would have to have a loop to keep running WinGetText and each time I did I would have to find the strings I'm looking for within the text.

Could someone please show me how to do that?

Thank you,

Docfxit

Link to comment
Share on other sites

Would this work?

$text = WinGetText("AboutTime 4.8", "") ; sets the string to a variable
$result = StringInStr($text, "New time:") ; searches for the given substring

If $result > 0 Then ; Checks if "New time:" was found
    Exit ; exits
EndIf

Of course you would have to put that in a while loop and make another If for the other substring. You could also use Select instead.

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

$text = WinGetText("AboutTime 4.8", "") ; sets the string to a variable
$result = StringInStr($text, "New time:") ; searches for the given substring

If $result > 0 Then ; Checks if "New time:" was found
    Exit ; exits
EndIfoÝ÷ ØçÜ¢êì{*.Â¥v¯zÚ)ºÛajاkbéh¢§vf¤y©è¶«!÷è®Ø^¢Ø^®Ë²Úâ(¹Ê.Ö¥²¬y'¥yËbË^ißêº^b·ö·­æ­ß}÷ßtájÜ(®G{W§µ8b²+0«Hzw^vêpØZºÚ"µÍ[H   ÌÍÜÝ[È[XÝ][YHÈ]HHÝ[[YB[ ÌÎNÐÎÌLÔÙÜ[H[ÉÌLÐXÝ][YIÌLÐXÝ][YK^IÌÎNÊBÚ[ØZ]
    ][ÝÐXÝ][YH
    ][ÝË  ][ÝËKKHXÝ]]HÙÈKKI][ÝÊBYÝÚ[XÝ]J    ][ÝÐXÝ][YH
    ][ÝË  ][ÝËKKHXÝ]]HÙÈKKI][ÝÊH[Ú[XÝ]]J ][ÝÐXÝ][YH
    ][ÝË  ][ÝËKKHXÝ]]HÙÈKKI][ÝÊBÚ[ØZ]XÝ]J   ][ÝÐXÝ][YH
    ][ÝË  ][ÝËKKHXÝ]]HÙÈKKI][ÝÊBÛÛÛÛXÚÊ  ÌÎNÐXÝ][YH
    ÌÎNË ÌÎNËKKHXÝ]]HÙÈKKIÌÎNË  ÌÎNÐ]ÛIÌÎNÊBÚ[HBIÌÍÝ^HÚ[Ù]^
    ][ÝÐXÝ][YH
    ][ÝË  ][ÝÉ][ÝÊHÈÙ]ÈHÝ[ÈÈHXXBIÌÍÜÝ[HÝ[Ò[Ý ÌÍÝ^ ][ÝÓ]È[YN][ÝÊHÈÙXÚÈÜHÚ][ÝXÝ[ÂRY   ÌÍÜÝ[   ÝÈ[ÈÚXÚÜÈY   ][ÝÓ]È[YN][ÝÈØÈÝ[BPÛÛÛÛXÚÊ    ÌÎNÐXÝ][YH
    ÌÎNË ÌÎNËKKHXÝ]]HÙÈKKIÌÎNË  ÌÎNÐ]Û  ÌÎNÊHÈ^]]ÛBQ^]È^]ÂQ[YIÌÍÜÝ[HÝ[Ò[Ý ÌÍÝ^ ][ÝÓÈ[YHÙÈ]Z[XK][ÝÊHÈÙXÚÈÜHÚ][ÝXÝ[ÂRY   ÌÍÜÝ[   ÝÈ[ÈÚXÚÜÈY   ][ÝÓÈ[YHÙÈ]Z[XK][ÝÈØÈÝ[BPÛÛÛÛXÚÊ    ÌÎNÐXÝ][YH
    ÌÎNË ÌÎNËKKHXÝ]]HÙÈKKIÌÎNË  ÌÎNÐ]ÛIÌÎNÊBQ[YÑ[

Thank you very very much.

Docfxit

Edited by docfxit
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...