Sign in to follow this  
Followers 0
MuffinMan

Title text match with spaces

2 posts in this topic

#1 ·  Posted (edited)

I am trying to rebuild an old single signon script that has been giving us a bit of trouble lately.  I didn't write it and it was written in another script language.  If the target program is already open it will have the current user's last name as part of the window text, which I am trying to compare against the user name to see if I should just WinActivate or Process Close and start the program over.  I will be provided the username like "jones", or "smith" and the title check works fine for last names (with no spaces), but if the last name DOES contains spaces, say "Nom De Plume", then all I will be given as a username is "nomdeplume".  Is there any way (via a regex maybe) that I can still check the text on the screen and somehow ?  I have been reading about the Advanced (4) mode of WinTitleMatchMode, but it is over my head.  Any help is appreciated.  Here is a small reproducer script:

Opt("WinTitleMatchMode", -1)

Run("Notepad")
WinWait("[CLASS:Notepad]", "", 10)
Send ("Smith" & @CRLF & "Jones" & @CRLF & "Nom De Plume" & @CRLF)

If WinExists("[CLASS:Notepad]", "jones") Then
    MsgBox(0,"FOUND","Found Jones")
EndIf

If WinExists("[CLASS:Notepad]", "nomdeplume") Then
    MsgBox(0,"FOUND","Found Nom De Plume")
EndIf

 

Edited by MuffinMan

Share this post


Link to post
Share on other sites



Well, I have something now that certainly seems to work, I'll start testing and see how this holds up; still interested if anyone has any better solutions.

Opt("WinTitleMatchMode", -1)

Run("Notepad")
WinWait("[CLASS:Notepad]", "", 10)
Send ("Smith" & @CRLF & "Jones" & @CRLF & "Nom De Plume" & @CRLF)

$WinText = StringStripWS(WinGetText("[CLASS:Notepad]"),8)

If StringInStr($WinText, "jones") <> 0 Then
    MsgBox(0,"FOUND","Found jones")
EndIf

If StringInStr($WinText, "nomdeplume") <> 0 Then
    MsgBox(0,"FOUND","Found Nom De Plume")
EndIf

 

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

  • Similar Content

    • DavidLago
      By DavidLago
      Hello. 
      I need to list only the folders that has a name composed of numbers only.
      How do I do this?
      OBS: I just posted the relevant content to the folder.
      Global $path = "G:\jobs\" For $i = 1 To $aArray[0] Local $search = FileFindFirstFile($path & $aArray[$i] & "\[0-9]" ) I tried with "\*.*" and it returns me the expected result, but the other doesn't.
    • harvester2001
      By harvester2001
      Hi
      I need your help I need create broadcast text message/notification to multiple lan clients. I can install listener program on pc its not a problem.
      But I don`t know how to start, could somebody write me example script how broadcast script and client who listen non stop for message should look like.
      I try to find example on forum but I have problem to understand those scripts.
      Many thx for help.
    • ur
      By ur
      I have a text file whose data will be as below.
      win10x64 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (32-bit)_2500.exe" SilentInstall.exe win10x64clone1 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (64-bit)_2500.exe" DM64.exe win10x64clone2 ~\erwin Notallowed1! "erwin Mart Server r9.7 (32-bit).exe" SilentInstall.exe win10x64clone3 ~\erwin Notallowed1! "erwin License Server r9.7 (32-bit).exe" SilentInstall.exe Each line will have multiple values separated by space.
      If a value contains space in it, the value is surrounded by quotes.
      My task is to check how many values are there in each line.
      If the line contains 5 values, I need to replace the 4th value with the string contained in a variable.
      If it contains 4 values then also  I need to replace the 4th value followed by appending 5 th value to it as SilentInstall.exe
      If the value I am replacing contains spaces then I need to surround the new value with quotes.
       
      Any one can suggest how to do this,??
    • nikink
      By nikink
      Hi all, it's been a while since I last used regular expressions and I find myself out of time to experiment with this particular issue, so I throw myself upon your mercy and expertise.
      I am looking to create a function that will say whether or not a supplied string is a valid UUID or not.
      Local $sTestF = '4C4C4544-004A-4C10-8054-B7C04F46343' Local $sTestT = '4C4C4544-004A-4C10-8054-B7C04F463432' ConsoleWrite('False = ' & _IsValidUUID($sTestF) & @CRLF) ConsoleWrite('True = ' & _IsValidUUID($sTestT) & @CRLF) Func _IsValidUUID($sUUID) ;[\p{XDigit}]{8}-[\p{XDigit}]{4}-[34][\p{XDigit}]{3}-[89ab][\p{XDigit}]{3}-[\p{XDigit}]{12} ; Test UUID = '4C4C4544-004A-4C10-8054-B7C04F463432' Local $sRegExp = '([:xdigit:]){8}\-([:xdigit:]){4}\-([34])([:xdigit:]){3}\-([89ab])([:xdigit:]){3}\-([:xdigit:]){12}' ConsoleWrite(StringRegExp($sUUID, $sRegExp) & @CRLF) Local $Result = StringRegExp($sUUID, $sRegExp) ConsoleWrite($Result & @CRLF) If @error Then ConsoleWrite('Error: [' & @error & ']' & @CRLF) Return 'False' Else ConsoleWrite('Error2: [' & @error & ']' & @CRLF) Return 'True' EndIf EndFunc In the line under the Function call, you'll see the regex I found to do this from a google search. That was my starting point, and I'm trying to get it to work in Au3 and failing miserably.
      $sTestF is a known invalid String
      $sTestT is a known valid String
      Everything I've tried so far has produced the same results for both.
      Any help you could provide me is greatly appreciated. Thanks for your time!
    • AnonymousX
      By AnonymousX
      Hi,
      I'm trying to create a program where the user can input a material number into a GUI and the script will search out and find the respected material folder. I've been able to piece together the file mapping part so that the correct folder is stored within a variable. However I can not seem to get the Run function to work as the directory contains commas. Could I please get assistance with this?
      Here is some test code I've experimented with
      $filepath = "C:\Users\annoymousx\Documents\" ; Variable Works ;$filepath = "C:\Users\annoymousx\Documents\Test with Spaces\"; Works with folder spacing $filepath = $filepath & "Test with Spaces\"; Works with using a prior directory history $filepath = $filepath & "Folder with ()"; Works if brackets are used ;$filepath = $filepath & "\Folder with ," ;Does not Work if comma is used in file directory $filepath = $filepath & "\Folder with " & ""","""; Works if triple brackets are used Run("explorer.exe " & $filepath)  
      So I've learnt if you put triple quotations around a comma it will work correctly. The challenge is, in the actual script i'm not manually entering in text.
      Example:
      $filepath = $filepath & $Materialclass[$classnum] & "\"  
      Which is put into a loop, then at the end of the script I have the correct file path saved to the variable but it may contain many commas. 
      How would I take this variable with the correct file path and open windows explore to it?
      Say if the variable contained the value: C:\Users\anonymousx\Documents\This folder has a ,\comma, (comma, comma,)\And more , here
      Thanks for any suggestions,