Jump to content
Sign in to follow this  
Nuro

Sciprt Pause Problem

Recommended Posts

Nuro

I have an automation set up for our company reports. I've been using it for nearly 2 years without any probelms. It take a total of about 2 hours for this whole thing to complete. I use Autoit to run and test 100's of queries and then at the end, it starts a VBA application in excel, which in turns takes the data from all those queries an puts it into the reports.

Recently I've been ask to create a new report but I don't want the new report to interfere with the old reports. The older ones are far more important. So my thought was to have autoit run the queries for the second reports and start their VBA code after the other stuff has completed. The problem is that the script never picks back up. It stay's paused..Nothing gets run on the second part. The time it takes Excel to run its stuff, is about 15 minutes. Before the new portion, the autoit script ended once it opened excel. Now I just want it to wait until excel closes and then start the second half. I can't get it to work. I've tried using the variable name for the excel file, "Microsoft Excel", etc but it never starts up again.

When I test it by manually opening the excel file, starting the new portion of the script, and then manually closing the excel file, it works but when everything is lumped into one big script, with the VBA code closing the excel file, it never starts back up. Does anyone have any ideas?

The code below is the last part of the original script where it starts the excel application. This is where it orriginally ended. It's followed by the new portion. (again, the excel application closes excel once everything is completed.)

;Close out the Test Reconciliation File and open the Reports Automation Excel Application and run it.
_ExcelBookClose($oExcel)

;Open the Daily Updates Excel Application.
$oExcel = _ExcelBookOpen($sTestFileDir & "Daily Updates Application.xls")
$oExcel.Application.Run("DailyAutomation")





;Now begins the second part of the automation for later reports.




WinWaitClose ($oExcel)
Sleep (15000)

;Open the CPE queries and run the test queries.
Run ("C:\Program Files\CA\Forest & Trees\650\Ftw.exe " & $sQueryDir & "Daily CPE Metrics.ftv")
WinWaitActive ("Forest & Trees", "Run Tests")
Sleep(5000)
MouseClick ("Left", 894 , 605, 1)
WinWaitActive ("Forest & Trees", "CPE test files have been saved")
Send ("{Enter}")


;Open the test reconciliation file and update the links to test that the CPE query data is valid.
$oExcel = _ExcelBookOpen($sTestFileDir & "Test Reconciliation.xls")
Sleep(5000)
Global $sProceed = _ExcelReadCell($oExcel, "D2")

    
    If $sProceed = "DWH" Then
    ;Close out the Test Reconciliation File and open the Reports Automation Excel Application and run it.
        _ExcelBookClose($oExcel)

    ;Open the Daily Updates Excel Application and send the Test Failure e-mail.
        $oExcel = _ExcelBookOpen($sTestFileDir & "Daily Updates Application.xls")
        $oExcel.Application.Run("CpeDwhFailedEmail")
        Sleep(5000)
        WinActivate ("Forest & Trees", "Daily CPE")
        WinClose ("Forest & Trees", "Daily CPE")
        WinWaitActive ("Forest & Trees", "Should unsaved changes be written to")
        Send ("{Enter}")
        Sleep(3000)
        WinWaitClose ("Forest & Trees")
        Exit
    ElseIf $sProceed = "Decode" Then
    ;Close out the Test Reconciliation File and open the Reports Automation Excel Application and run it.
        _ExcelBookClose($oExcel)

    ;Open the Daily Updates Excel Application and send the Test Failure e-mail.
        $oExcel = _ExcelBookOpen($sTestFileDir & "Daily Updates Application.xls")
        $oExcel.Application.Run("CpeDecodeFailedEmail")
        Sleep(5000)
        WinActivate ("Forest & Trees", "Daily CPE")
        WinClose ("Forest & Trees", "Daily CPE")
        WinWaitActive ("Forest & Trees", "Should unsaved changes be written to")
        Send ("{Enter}")
        Sleep(3000)
        WinWaitClose ("Forest & Trees")
    ElseIf $sProceed = "Both" Then
    ;Close out the Test Reconciliation File and open the Reports Automation Excel Application and run it.
        _ExcelBookClose($oExcel)

    ;Open the Daily Updates Excel Application and send the Test Failure e-mail.
        $oExcel = _ExcelBookOpen($sTestFileDir & "Daily Updates Application.xls")
        $oExcel.Application.Run("CpeBothFailedEmail")
        Sleep(5000)
        WinActivate ("Forest & Trees", "Daily CPE")
        WinClose ("Forest & Trees", "Daily CPE")
        WinWaitActive ("Forest & Trees", "Should unsaved changes be written to")
        Send ("{Enter}")
        Sleep(3000)
        WinWaitClose ("Forest & Trees")
    Else
    EndIf

;Close out the Test Reconciliation File and open the Reports Automation Excel Application and run the CPE Automation.
_ExcelBookClose($oExcel)

Sleep (15000)

;If we are go for automation, run the Daily CPE Metrics Queries
WinActivate ("Forest & Trees", "Daily CPE")
WinWaitActive ("Forest & Trees", "Daily CPE")
    MouseClick("Left", 894, 672, 1)

;Now wait until the queries have finished running and then the F&T file.

;Close the Daily CPE Queries
WinWait ("Forest & Trees", "CPE Routine Complete")
WinActivate ("Forest & Trees", "CPE Routine Complete")
Send ("{Enter}")
Sleep(3000)
WinActivate ("Forest & Trees", "Daily CPE")
WinClose ("Forest & Trees", "Daily CPE")
WinWaitActive ("Forest & Trees", "Should unsaved changes be written to")
Send ("{Enter}")
Sleep(3000)

WinWaitClose ("Forest & Trees")


Exit
Edited by Nuro

Share this post


Link to post
Share on other sites
spudw2k

i think the prob may be with WinWaitClose ($oExcel)

WinWaitClose() is expecting a string with the text of the window title, $oExcel appears to be an object.

Share this post


Link to post
Share on other sites
Nuro

i think the prob may be with WinWaitClose ($oExcel)

WinWaitClose() is expecting a string with the text of the window title, $oExcel appears to be an object.

I also tried WinWaitClose("Microsoft Excel") but I'll try the full name of the title.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.