Jump to content

GetText Advanced


 Share

Recommended Posts

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

Link to comment
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]

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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.

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