#include #include ;wait 10 seconds to start processing Sleep(10000) ;set sleep length Local $hSleep=2000 ;set file save path and name Local $hFilePath="V:\Purchasing\MPR CSVs\MPR.csv" ; Script Start - Add your code below here Global $logging = true ; Set to True to write a log-file, False to not write a log-file ; Write the Opening Log Entry _log("Starting MRP report download") ;minimize all open windows Send ("#d") Sleep($hSleep) ; Open the Material Planning Window RUN ("K:\638\vmfg\VMPLNWIN.EXE -D VMFG1 -U SYSADM -P J7001") Sleep (10000) ; Wait 10 Seconds Local $hMPW = WinActivate ("[Centura:MDIFrame]","") ;MsgBox($MB_OK, "Step Check", $hMPW) _log("WinActivate result" + $hMPW); Write the winactivate result Sleep ($hSleep) ; Wait Send ("!F") ; Alt-F Sleep ($hSleep) ; Wait Send ("n") ; Send n Sleep ($hSleep) ; Wait Func _log($message) If $logging Then ; If $logging is set to true on the first line, output the Log File FileWriteLine(@ScriptDir & '\autoMRP.log', @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " --> " & $message) EndIf EndFunc ;_log("ALT TAB sent"); Log entry ;Send ("!{TAB}") ;Sleep($hSleep)