eagle4life69 Posted March 30, 2006 Share Posted March 30, 2006 I am using perl to run some commands and such for my job. it readys a file and looks for the data for me. What I need is a way to do some things for me (I'm lazy) I want to know if it is possible to do these things Read an E-mail (groupwise, I can get groupwise to open) Copy text from e-mail and paste into file (pretty sure I can do this) Here is what I need when my Perl script opens on the screen this is what I see What is Todays Date (MMDDYY) I have it fill this in for me then What Year to Process (YYYY) First one I can get started what comes next on the screen is Are there more years? 1.) Yes | 2.)No Now it can take upto 15 minutes for the first one so I need it to know when it sees this to enter 1 then wait for it again run it 8 times (IE. 1999,2000,2001,2002,2003,2004,2005,2006) So how do you get it to wait until it sees Are there more years? 1.) Yes | 2.)No on the screen Link to comment Share on other sites More sharing options...
greenmachine Posted March 30, 2006 Share Posted March 30, 2006 Does Perl use the command prompt? If so, my suggestion would be to run the perl script from inside AutoIt (make sure to have STD out and in streams selected), and then use ConsoleRead and ConsoleWrite to communicate with the console output. Link to comment Share on other sites More sharing options...
eagle4life69 Posted March 30, 2006 Author Share Posted March 30, 2006 how would I run perl from within Autoit? I use dos now Link to comment Share on other sites More sharing options...
greenmachine Posted March 30, 2006 Share Posted March 30, 2006 Hmm, maybe I shouldn't have spoken, since I don't really know how perl works. However, my thinking was something like: Run (@comspec & " /c start perlscript", @workingdir, @sw_hide, 3) ; last 3 means stdout and std in. Link to comment Share on other sites More sharing options...
Lapo Posted March 30, 2006 Share Posted March 30, 2006 (edited) Read an E-mail (groupwise, I can get groupwise to open)http://www.ahml.info/oml/VBS.htmledit :http://www.ahml.info/oml/vbsgw4.txtsearch for ORI gw4.vbs and wndw it's vbs (or VB)snip :handle = tool.GetHwndFromClass("OFMailView") ''handle = tool.GetHwndFromClass("Notepad") If handle = 0 Then MsgBox "Currently, no Groupwise mail window is open!" Else handle2 = tool.GetHwndFromParentAndWndID( handle, 10008 ) ' 10008 is the _ 'window ID of the Groupwise email reply edit window ''handle2 = tool.GetHwndFromParentAndWndID( handle, 15 ) 'Notepad TextBuff = tool.GetText(handle, handle2) TextBuffLen = Len(TextBuff)if i rember you must create wndw.dllif you are interested ask and I ulopad it for you just compiled Edited March 30, 2006 by Lapo Link to comment Share on other sites More sharing options...
herewasplato Posted March 30, 2006 Share Posted March 30, 2006 http://www.autoitscript.com/forum/index.php?showtopic=19343 might be of interest... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
eagle4life69 Posted March 31, 2006 Author Share Posted March 31, 2006 Here's my code I use now for the process HotKeySet("{F8}", "Quit") $Date = @MON & @MDAY & StringRight(@YEAR,2) $file1 = FileOpen("run.bat", 2) FileWriteLine($file1, "@echo off" & @CRLF) FileWriteLine($file1, "J:" & @CRLF) FileWriteLine($file1, "cd \Duplicate Bills\newdup" & @CRLF) FileWriteLine($file1, "cls" & @CRLF) FileWriteLine($file1, "perl Ndups.pl" & @CRLF) FileWriteLine($file1, "print /D:lpt2 confirm.log" & @CRLF) FileWriteLine($file1, "del confirm.log" & @CRLF) FileClose($file1) Run("run.bat") ProcessWait("CMD.exe") Send($Date) Send("{ENTER}") ProcessWaitClose("CMD.exe") FileDelete("run.bat") How could I do this. This will be my hardest program I have created Link to comment Share on other sites More sharing options...
eagle4life69 Posted April 18, 2006 Author Share Posted April 18, 2006 okay no ideas here just help me know how to do this. I'm running a dos window program is running and I don't want to know whats happening until I see some key words. I'll show my code and I'll give you what I want to do and someone point me in the correct direction. here is a piece of my code I run RunWait("c:\D\TRAM2000\APPS\DOCUCORP\RUNTIME\MSTRRES\W32EXE\GEND1.BAT")[quote] The following in a display of what my screen displays (in dos) and can run for 5-10 min ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006[quote] ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Warning count: 1 ==> Error count: 0 Elapsed Time: 75 seconds --- GenData Completed --- "Failed in GENDATA 1" Check for Error Press any key to continue . . . what I want is when AutoIt sees this on the screen ==> Warning count: 1 ==> Error count: 0 I want it to wait 5 seconds and then continue. if it looks something like this ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 ==> Warning count: 1 ==> Error count: 12 Elapsed Time: 75 seconds --- GenData Completed --- "Failed in GENDATA 1" Check for Error Press any key to continue . . . if this happens I need that line just before the error ==> Processing: xxxxxx-xxxxxx-RIVRSIDE-UTILS--14-APR-2006 actualy I just need the xxxxxx-xxxxxx (which is a customer number) so my error program can run. Well I need help so please Help me out. any questions just ask. Link to comment Share on other sites More sharing options...
herewasplato Posted April 18, 2006 Share Posted April 18, 2006 ...any questions just ask.Have you tried the STD I/O functions in beta?If yes, post your code.If you cannot get the STD I/O functions, you could always try redirecting the output of your DOS window to a file and using AutoIt to read that file. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
eagle4life69 Posted April 18, 2006 Author Share Posted April 18, 2006 Have you tried the STD I/O functions in beta?If yes, post your code.If you cannot get the STD I/O functions, you could always try redirecting the output of your DOS window to a file and using AutoIt to read that file.no I haven't tryed that how would I do that. I could do the output to a file but what If I need human intervention like a prompt Link to comment Share on other sites More sharing options...
herewasplato Posted April 19, 2006 Share Posted April 19, 2006 eagle4life69, The code below is meant as a demo - it is not clean. (It does not do all of the error checking that you might want to include in a normal script):expandcollapse popup;this is a demo of doing things the hard way ;using the STD I/O functions in AutoIt beta would be better AutoItSetOption("WinTitleMatchMode", 2);match substring AutoItSetOption("TrayIconDebug", 1);0-off ;make temp files for demo For $i = 1 To 9 FileOpen(EnvGet("temp") & "\demofile" & $i, 2) FileClose(EnvGet("temp") & "\demofile" & $i) Next ;make a batch file as shown in this thread $file = FileOpen(EnvGet("temp") & "\demo.bat", 2) FileWriteLine($file, "cd\") FileWriteLine($file, "dir %temp%\demofile? /b > %temp%\batout1.txt") FileWriteLine($file, "pause") FileWriteLine($file, "dir %temp%\demofile? /b > %temp%\batout2.txt") FileWriteLine($file, "pause") FileClose($file) Run(EnvGet("temp") & "\demo.bat") WinWaitActive("cmd") ;wait for file to be created Do Sleep(30) Until FileExists(EnvGet("temp") & "\batout1.txt") ;read all of the file into a variable $FileText1 = FileRead(EnvGet("temp") & _ "\batout1.txt", FileGetSize(EnvGet("temp") & _ "\batout1.txt")) ;check to see if the desired info is... ;...ANYWHERE in the variable If StringInStr($FileText1, "demofile6") Then MsgBox(0, "", "Found demofile6") WinActivate("cmd") WinWaitActive("cmd") ;simulate human intervention like a prompt Send("{ENTER}");<<<<<<<<<<<<<<<<<<<<<<<< ;simulate human intervention like a prompt EndIf ;wait for file to be created Do Sleep(30) Until FileExists(EnvGet("temp") & "\batout2.txt") ;read all of the file into a variable $FileText2 = FileRead(EnvGet("temp") & _ "\batout2.txt", FileGetSize(EnvGet("temp") & _ "\batout2.txt")) ;split the variable into an array $FileText2Array = StringSplit($FileText2, @CRLF, 1) ;$FileText2Array[0] = 10 ;$FileText2Array[1] = demofile1 ;$FileText2Array[2] = demofile2 ;$FileText2Array[3] = demofile3 ;..... ;$FileText2Array[1] = demofile9 ;check to see WHERE the desired info is... ;...in the variable For $i = 1 To $FileText2Array[0] ;MsgBox(0,$FileText2Array[0],$FileText2Array[$i]) If StringInStr($FileText2Array[$i], "demofile6") Then MsgBox(0, "", "Found info before demofile6" & @CR & @CR & $FileText2Array[$i - 1]) WinActivate("cmd") WinWaitActive("cmd") ;simulate human intervention like a prompt Send("^c");<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Sleep(1000);could avoid this with I/O Send("Y{ENTER}");<<<<<<<<<<<<<<<<<<<<<<<< ;simulate human intervention like a prompt ExitLoop EndIf Next ;clean up temp demo files FileDelete(EnvGet("temp") & "\batout1.txt") FileDelete(EnvGet("temp") & "\batout2.txt") FileDelete(EnvGet("temp") & "\demo.bat") For $i = 1 To 9 FileDelete(EnvGet("temp") & "\demofile" & $i) NextLet me know what parts you do not understand... or what parts you cannot change to use in your script. Perhaps someone will post a demo like this using the STD I/O functions in the beta release of AutoIt. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
eagle4life69 Posted April 26, 2006 Author Share Posted April 26, 2006 I'll try this. I'm surprised no one has had this issue before. I though something that could read the screen and look for a special var. would be easy Gues not. Link to comment Share on other sites More sharing options...
eagle4life69 Posted May 11, 2006 Author Share Posted May 11, 2006 okay Finally felt like doing this (what was I thinking) Here is my code so far AutoItSetOption("WinTitleMatchMode", 2);match substring AutoItSetOption("TrayIconDebug", 1);0-off FileDelete("batout1.txt") FileDelete("demo.bat") ;make a batch file as shown in this thread $file = FileOpen("demo.bat", 2) FileWriteLine($file, "cd \D\TRAM2000\APPS\DocuCorp\RUNTIME\MSTRRES\W32EXE") FileWriteLine($file, "GEND.BAT > batout1.txt") FileClose($file) Runwait("demo.bat") ;WinWaitActive("cmd") ;wait for file to be created Do Sleep(30) Until FileExists("batout1.txt") ;read all of the file into a variable $FileText1 = FileRead("batout1.txt", FileGetSize("batout1.txt")) ;check to see if the desired info is... ;...ANYWHERE in the variable If StringInStr($FileText1, "==> Error count: 0") Then MsgBox(0, "", "Found No Errors") EndIf ;clean up temp files FileDelete("batout1.txt") FileDelete("demo.bat") this is what the file looks like --- GenData --- --- GenData Completed --- ==> Processing: TransactionId-GroupName1-GroupName2-GroupName3-TransactionType ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 ==> Warning count: 1 ==> Error count: 0 Elapsed Time: 1 seconds "Failed in GENDATA 1"now if I did get an error how can I get the last line ==> Processing: 123456-123456-RIVRSIDE-UTILS--11-APR-2006 I highlighted the part I need My example doesn't show the exact account number, my example shows a small list it normally is about 6000+ lines. Please Help Link to comment Share on other sites More sharing options...
eagle4life69 Posted May 11, 2006 Author Share Posted May 11, 2006 Got it Tell me what you think expandcollapse popup#include <File.au3> $log = "c:\D\TRAM2000\APPS\DocuCorp\RUNTIME\MSTRRES\W32EXE\batout1.txt" $batch = "c:\D\TRAM2000\APPS\DocuCorp\RUNTIME\MSTRRES\W32EXE\run.bat" $bad_acct = "c:\D\TRAM2000\APPS\DocuCorp\RUNTIME\MSTRRES\W32EXE\error.txt" AutoItSetOption("WinTitleMatchMode", 2);match substring AutoItSetOption("TrayIconDebug", 1);0-off FileDelete($log) FileDelete($batch) FileDelete($bad_acct) ;make a batch file as shown in this thread $file = FileOpen($batch, 2) FileWriteLine($file, "cd \D\TRAM2000\APPS\DocuCorp\RUNTIME\MSTRRES\W32EXE") FileWriteLine($file, "GEND.BAT > batout1.txt") FileClose($file) Runwait($batch) ;wait for file to be created Do Sleep(30) Until FileExists($log) ;read all of the file into a variable $FileText1 = FileRead($log, FileGetSize($log)) ;check to see if the desired info is... ;...ANYWHERE in the variable If StringInStr($FileText1, "==> Error count: 0") Then MsgBox(0, "", "Found No Errors") Else MsgBox(0, "", "Found Errors") $Lines = _FileCountLines( $log ) $math = ($Lines-"6") $line = FileReadLine($log,$math) $file2 = FileOpen($bad_acct, 2) FileWriteLine($file2, $line) FileClose($file2) InetGet($bad_acct) $contents = FileRead($bad_acct,filegetsize($bad_acct)) $playing=StringReplace($contents,"="," ") $playing=StringReplace($contents,"-"," ") $playing=StringSplit($playing," ") MsgBox(64, "Bad Customer File", $playing[3] & "-" & $playing[4]) EndIf ;clean up temp files FileDelete($log) FileDelete($batch) FileDelete($bad_acct) I am done. Thanks to everyone who helped. Link to comment Share on other sites More sharing options...
herewasplato Posted May 12, 2006 Share Posted May 12, 2006 ...Tell me what you think...Great. Glad you got it to work... but like I said above the demo code that I posted above: "(It does not do all of the error checking that you might want to include in a normal script):" Little things like you might want to follow this line: $file = FileOpen($batch, 2) what some error checking: (from the help file)If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf And this line: ($Lines - "6") should be ($Lines - 6) 6 as a number "6" as a string (text) It works for you in this script, but it will not always do so. [size="1"][font="Arial"].[u].[/u][/font][/size] 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