Jump to content

How to make one long script


Sorian
 Share

Recommended Posts

Is there a way to write one continuous script instead of several small scripts?

Example:

CODE
Run("AdbeRdr80_en_US.exe")

WinWait("Adobe Reader 8 - Setup")

If WinActive("Adobe Reader 8 - Setup","Setup will allow you to repair or remove Adobe Reader 8. To continue, click Next.")Then

Send("!C")

Winactive("Adobe Reader 8 - Setup","Are you sure you want to cancel Adobe Reader 8 installation?")

Send("!Y")

Winactive("Adobe Reader 8 - Setup","Your system has not been modified.")

Send("!F")

Exit

EndIf

WinWait("Adobe Reader 8 - Setup","Destination Folder")

Send("!N")

WinWait("Adobe Reader 8 - Setup","Ready to Install the Program")

Send("!I")

WinWait("Adobe Reader 8 - Setup","Setup Completed")

Send("{tab}")

Send("{space}")

Send("!F")

WinWait("setup","Setup needs to restart your system to complete the installation.")

Send("!N")

Exit

In this script I have it so if Adobe Reader 8 is installed, it will close; otherwise it will install

CODE
Run("QuickTimeInstaller.exe")

If WinWaitActive("QuickTime for Windows","Repair or remove QuickTime")Then

Send("{tab 2}")

Send("{enter}")

WinActive("QuickTime for Windows","Are you sure you want to cancel QuickTime installation?")

Send("!Y")

WinActive("QuickTime for Windows","The installer was interrupted before the requested operations for QuickTime could be completed.")

Send("!F")

Exit

EndIf

WinWaitActive("QuickTime for Windows","Welcome to the QuickTime 7 Installer")

Send("!N")

WinActive("QuickTime for Windows","License Agreement")

Send("!Y")

WinActive("QuickTime for Windows","Destination Folder")

Send("!I")

WinActive("QuickTime for Windows","QuickTime Installer Completed")

Send("!F")

WinActive("QuickTime for Windows","QTProBanner.bmp")

Send("{tab}")

Send("{enter}")

Exit

This is for Quicktime, same setup as for the Adobe install. (if its installed, it will close; otherwise it will install)

I need to replace the Exit with something so it will continue the script to the next point.

I could make each install their own script and put Run("insert next install script.exe") but I was hoping for just one script file.

Would look something like this:

CODE

;Install Adobe Reader 8

Run("AdbeRdr80_en_US.exe")

WinWait("Adobe Reader 8 - Setup")

If WinActive("Adobe Reader 8 - Setup","Setup will allow you to repair or remove Adobe Reader 8. To continue, click Next.")Then

Send("!C")

Winactive("Adobe Reader 8 - Setup","Are you sure you want to cancel Adobe Reader 8 installation?")

Send("!Y")

Winactive("Adobe Reader 8 - Setup","Your system has not been modified.")

Send("!F")

Starts the QuickTime installer section in script

EndIf

WinWait("Adobe Reader 8 - Setup","Destination Folder")

Send("!N")

WinWait("Adobe Reader 8 - Setup","Ready to Install the Program")

Send("!I")

WinWait("Adobe Reader 8 - Setup","Setup Completed")

Send("{tab}")

Send("{space}")

Send("!F")

WinWait("setup","Setup needs to restart your system to complete the installation.")

Send("!N")

;Install Quicktime

Run("QuickTimeInstaller.exe")

If WinWaitActive("QuickTime for Windows","Repair or remove QuickTime")Then

Send("{tab 2}")

Send("{enter}")

WinActive("QuickTime for Windows","Are you sure you want to cancel QuickTime installation?")

Send("!Y")

WinActive("QuickTime for Windows","The installer was interrupted before the requested operations for QuickTime could be completed.")

Send("!F")

Starts the next installer in script

EndIf

WinWaitActive("QuickTime for Windows","Welcome to the QuickTime 7 Installer")

Send("!N")

WinActive("QuickTime for Windows","License Agreement")

Send("!Y")

WinActive("QuickTime for Windows","Destination Folder")

Send("!I")

WinActive("QuickTime for Windows","QuickTime Installer Completed")

Send("!F")

WinActive("QuickTime for Windows","QTProBanner.bmp")

Send("{tab}")

Send("{enter}")

;Install ...

Run("next install.exe")

Edited by Sorian
Link to comment
Share on other sites

There are several options. You could always do an If ($expression) Then Run($otherscript). Or perhaps you could just #include the other script and call a function from it. Or, you could put the whole second script in the first script, and adjust the code accordingly. Hopefully that gives you some ideas.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

InstallAdobeReader()

Func InstallAdobeReader()
    ;Install Adobe Reader 8

    Run("AdbeRdr80_en_US.exe")

    WinWait("Adobe Reader 8 - Setup")

    If WinActive("Adobe Reader 8 - Setup","Setup will allow you to repair or remove Adobe Reader 8. To continue, click Next.")Then
        Send("!C")
        Winactive("Adobe Reader 8 - Setup","Are you sure you want to cancel Adobe Reader 8 installation?")
        Send("!Y")
        Winactive("Adobe Reader 8 - Setup","Your system has not been modified.")
        Send("!F")
        InstallQuickTime()
    EndIf

    WinWait("Adobe Reader 8 - Setup","Destination Folder")
    Send("!N")
    WinWait("Adobe Reader 8 - Setup","Ready to Install the Program")
    Send("!I")
    WinWait("Adobe Reader 8 - Setup","Setup Completed")
    Send("{tab}")
    Send("{space}")
    Send("!F")
    WinWait("setup","Setup needs to restart your system to complete the installation.")
    Send("!N")
EndFunc

Func InstallQuickTime()
    ;Install Quicktime

    Run("QuickTimeInstaller.exe")

    If WinWaitActive("QuickTime for Windows","Repair or remove QuickTime")Then
        Send("{tab 2}")
        Send("{enter}")
        WinActive("QuickTime for Windows","Are you sure you want to cancel QuickTime installation?")
        Send("!Y")
        WinActive("QuickTime for Windows","The installer was interrupted before the requested operations for QuickTime could be completed.")
        Send("!F")
        InstallNextProgram()
    EndIf

    WinWaitActive("QuickTime for Windows","Welcome to the QuickTime 7 Installer")
    Send("!N")
    WinActive("QuickTime for Windows","License Agreement")
    Send("!Y")
    WinActive("QuickTime for Windows","Destination Folder")
    Send("!I")
    WinActive("QuickTime for Windows","QuickTime Installer Completed")
    Send("!F")
    WinActive("QuickTime for Windows","QTProBanner.bmp")
    Send("{tab}")
    Send("{enter}")
EndFunc

Use the functions, grasshopper.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to comment
Share on other sites

If i were you i would use silent switches for installators instead of automating GUI for those apps. 90% of apps can be installed with some silent switch like setup.exe /s or so and it will install automagically without all this code :P As for your installer..

Use functions:

; To run Adobe installer... in silent mode
InstallAdobe()
; to run office installer .. etc
InstallOffice()

Func InstallAdobe()
    Run("AdbeRdr80_en_US.exe /sAll /rs")
EndFunc

Func InstallOffice()

EndFunc

My little company: Evotec (PL version: Evotec)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...