Vikramjeet Posted August 17, 2018 Author Share Posted August 17, 2018 3 hours ago, caramen said: #include <MsgBoxConstants.au3> #include <String.au3> #include <Array.au3> WinActivate("My Application") WinWaitActive("My Application") $file = "C:\Users\Charlie\Desktop\t.txt" ;$file = @ScriptDir &"\T.txt" $File1 = FileRead($File) $aSplit = StringSplit($File1, @CRLF, 3) _ArrayDisplay ($aSplit) $sString = StringLeft($aSplit[20], 3) ; Retrieve 3 characters from the left of the string. MsgBox($MB_SYSTEMMODAL, "", "The 3 leftmost characters are: " & $sString) $sStringBeta= StringReplace ($sString, " ", "" ) Local $a = 0 ;Loop counter variable Do $a += 1 ;Adds 1 to the loop counter Send("INSTANCE " & $a & "{ENTER}") Sleep(1000) ;Waits Until $a = $sStringBeta ;How many times to loop Thank you for your help. Much appreciated Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 17, 2018 Author Share Posted August 17, 2018 #include <MsgBoxConstants.au3> ;$file = "C:\Users\Charlie\Desktop\t.txt" $file = @ScriptDir & "\T.log" ;This is the log file which is read in real time ; The following Reg Exp finds ; the last occurrence of a line (".*" is greedy by default) ; beginning with spaces (if they exist) ("^\h*") ; followed by 1 to 3 digits ("\d{1,3}"). ; Those 1 to 3 digits are captured ("(\d{1,3})"). ; See AutoIt help file for explanations of "(?s)" and "(?m)" PCRE patterns. Explains how "." and "^" are affected. $iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0] ConsoleWrite($iNum & @CRLF) WinActivate("My Application") Local $hWnd = WinWaitActive("My Application", "", 5) If $hWnd Then For $i = 1 To $iNum Send("DISPLAY LIST") Sleep(2000) Send("{ENTER}") Sleep(5000) Send("INSTANCE " & $i & "{ENTER}") Sleep(1000) ;Waits Next Else MsgBox(0, "", '"My Application" window not found.') EndIf I have run into a snag. Data to the logfile is added after the Send("DISPLAY LIST"). The number of times to loop is unknown till Send("DISPLAY LIST") is sent. How can we first perform Send("DISPLAY LIST"), which generates the log file and then use the loop counter from the log file for the following formats Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now