Jump to content

Recommended Posts

Posted

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?

Posted

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)

Posted

$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]

Posted

$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]

Posted

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?

  • Moderators
Posted

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.

Posted

I have found the solution:

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

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

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

$tt[1] contain the number

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
×
×
  • Create New...