Sign in to follow this  
Followers 0
SSJoco

GetText Advanced

13 posts in this topic

I need a text from a statusbar, however Autoit can't see any text in the bar. (nor gettext, neither statusbargettext) Window Info show this text in the Visible text, but I don't know how I can use it.

Any Idea?

Share this post


Link to post
Share on other sites



HP ServiceDesk Search Windows. The results is in the Statusbar ex. 741 Item(s)

I need that number.

Share this post


Link to post
Share on other sites

Use WinGetText() and parse given string by StringRegExp() to get your number from it.

Thnx, but How can I parse it?

The text:

x Item(s) (x 1-3 digits)

Share this post


Link to post
Share on other sites

$s = "1 Item(s)"ConsoleWrite(GetNumber($s) & @CRLF)
$s = "12 Item(s)"
ConsoleWrite(GetNumber($s) & @CRLF)
$s = "123 Item(s)"
ConsoleWrite(GetNumber($s) & @CRLF)

Func GetNumber($string)
 $string = StringSplit($string, ' Item(s)', 1)
 Return $string[1]
EndFunc
It's not working.

I have more line inthe input:

Look for

Configuration Item

...

xxx Item(s)

I tried this, but It's not working every time (If there is other 'Item' lines)

$text = WinGetText("Advanced Find", "")

$t=StringRegexp($text, "\d*? Item", 3)

$tt=StringSplit($t[0], " ")

$number = $tt[1]

Share this post


Link to post
Share on other sites

$s = "1 Item(s)"ConsoleWrite(GetNumber($s) & @CRLF)
$s = "12 Item(s)"
ConsoleWrite(GetNumber($s) & @CRLF)
$s = "123 Item(s)"
ConsoleWrite(GetNumber($s) & @CRLF)

Func GetNumber($string)
 $string = StringSplit($string, ' Item(s)', 1)
 Return $string[1]
EndFunc
It's not working.

I have more line inthe input:

Look for

Configuration Item

...

xxx Item(s)

I tried this, but It's not working every time (If there is other 'Item' lines)

$text = WinGetText("Advanced Find", "")

$t=StringRegexp($text, "\d*? Item", 3)

$tt=StringSplit($t[0], " ")

$number = $tt[1]

Share this post


Link to post
Share on other sites

Post full example of your window content.

My given example was made for content you provided!

I search in a program and this is the result page. I need the number of Items. I can get this text only with WinGetText() command which has the following result:

Look for

Configuration Item

Configuration Item

Advanced Search

Find

Search

OK

Cancel

174 Item(s)

How can I extract only the 174 Item(s) line?

Share this post


Link to post
Share on other sites

Try something like this:

#Include <String.au3>

$s =  ...
ConsoleWrite($s & @CRLF)
ConsoleWrite(_StringBetween($s, '\r\n', " Item(s)", -1, 1) & @CRLF)
_StringBetween() returns an array.

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.

Share this post


Link to post
Share on other sites

I have found the solution:

$text = WinGetText("Advanced Find", "")

$t=StringRegexp($text, "\d*?" & " Item...", 3)

$tt=StringSplit($t[0], " ")

$tt[1] contain the number

Share this post


Link to post
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
Sign in to follow this  
Followers 0