Jump to content

Searching a class (editable field) for certain text then setting it as a varible


Go to solution Solved by timmyc,

Recommended Posts

Posted (edited)

Hi all,

I will try to be as clear as possible but let me know if you need any more info.

What i am trying to achieve is:

  • to have my script pull up a window of my choice (winactivate command)
  • Find all text between "cn=" and "," in an editable field which when i use the autoIT info tool it comes up with a class (WFC.EDIT) and instance (24) also has a control id number (1577946) and all of the text in the field is in the "visible text" tab in the autoit info tool
  • set all text between "cn=" and "," as $variable

And i will want to repeat this task for multiple chunks of text and set them all to different variables then i will be pasting these varibles later on.

I know how to do the first task/dot point but don't know how to do the second two.

Thanks heaps for any help.

Tim

Edited by timmyc
Posted

can this do the trick?

#Include <Array.au3>

$text = WinGetText("YOUR WINDOW TITLE")
$text = ControlGetText("YOUR WINDOW TITLE", "", "[CLASS:WFC.EDIT]") ; or only with the control

$aCn = StringRegExp($text, "cn=([^,]+),", 3)

_ArrayDisplay($aCn)

You will have an array, better than different variables...

Posted

can this do the trick?

#Include <Array.au3>

$text = WinGetText("YOUR WINDOW TITLE")
$text = ControlGetText("YOUR WINDOW TITLE", "", "[CLASS:WFC.EDIT]") ; or only with the control

$aCn = StringRegExp($text, "cn=([^,]+),", 3)

_ArrayDisplay($aCn)

You will have an array, better than different variables...

 

Thanks a lot for your help, i am new to arrays so i have a few more questions. I have used the example you gave me which works great to get one sting into an array.

1) The end result i am after is to have all of the variables in the one array, so first question is..how can i tell the _ArrayDisplay command to show me all variables that i have gathered? ie Make the email address be in row 1 and so on

2) Does this "cn=([^,]+)," tell it to get anything between cn= and , and to exclude any commas? If so what does the + do?

3) if i want to exclude any spaces or enters would i add it after the [^ ] section in the stringregexp command?

This is what im working with at the moment: Search service call window for $cn and $email and give it to me in an array

#Include <Array.au3>

$text = WinGetText("Service Call - New")
$text = ControlGetText("Service Call - New", "", 68090)

$Cn = StringRegExp($text, "cn=([^,]+),", 3)
$email = StringRegExp($text, "\Email address : ([^ ,]+)", 3)

_ArrayDisplay($email, $Cn) ;this doesn't work
Posted

Please, give an example of a string contained in the control (cn=.....)

For the regexp, it looks for a string which contains cn=, followed by (something other than a comma one or more time)

cn= : matches cn=

[^,] : something other than a comma

+ : one or more times

Parentheses allow you to extract data (in an array here)

Posted

Thanks for the fast reply mate. Appreciate your help.

Ahhh ok i get  [^,] & + now, thanks for that info. If i wanted it to exclude any spaces could i tell it to exclude commas and spaces? eg [^, ]

And here is two example's of what is in the Control class/id (with what i want it to find in red)

- Email address : Joe_bloggs@hotmail.com

- DN : cn=bloggsj,ou=md,ou=p,ou=bs,ou=sth,o=H

Posted

So the two lines are in the same field ?

Try this :

#Include <Array.au3>

$sString = "- Email address : Joe_bloggs@hotmail.com" & @CRLF & _
           "- DN : cn=bloggsj,ou=md,ou=p,ou=bs,ou=sth,o=H"

$aRes = StringRegExp($sString, "(?is)Email address : (\N+).*cn=([^,]+)", 3)

_ArrayDisplay($aRes)
Posted

Yeah two lines are in the same field. I have been playing around with your script however i can only get it to pull the details from the $sstring command (joe_bloggs@hotmail.com and bloggsj) and not from the wingettext and controlgettext command that should be searching the window i specified

  • Solution
Posted

#Include <Array.au3>

$text = WinGetText("6,267,536 - Service Call - New")
$text = ControlGetText("6,267,536 - Service Call - New", "", "[CLASS:WFC.EDIT; INSTANCE:24]") ; or only with the control

;$sString = "- Email address : example@example" & @CRLF & _
;           "- DN : cn=example,ou=med,ou=p,ou=bs,ou=sth,o=idd"

$aRes = StringRegExp($text, "(?is)Email address : (\N+).*cn=([^,]+)", 3)

_ArrayDisplay($aRes)

Hey Mate, I got rid of the $sstring command and it is working now. I think the last thing i need to know is how to send something in the array for example set the email address (second row in array) to a varible and then send($thatvariable) to notepad or something.

Posted

The bulk of the text in a window so heaps of information...within this info i want to extract 4-5 strings and set them as variables. (I only started with 2 email address and username as if i can figure out how to get two in i can do the rest...well that's the plan anyway)

Sorry i can give you the full chunk of text as it has private information on it but it has probably an a4 sheet of papers worth of text and i want to pick out certain things.

  • 4 months later...
Posted
Hey Mate, I got rid of the $sstring command and it is working now. I think the last thing i need to know is how to send something in the array for example set the email address (second row in array) to a varible and then send($thatvariable) to notepad or something.
$thatvariable = $aRes[0]

Send ( $thatvariable )
;or
Send ( $aRes[0] )

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...