Sign in to follow this  
Followers 0
ScriptingNewb

Software Install Script Issues

7 posts in this topic

Hi folks!

Just started using AutoIT yesterday and I've done some very basic scripting of some of our software installs. My issue is that the behavior of the ClickControls and such doesn't seem to be consistent each time the script is run. Sometimes it does all the proper clicks, sometimes it will just sit there and I'm not sure how to debug that.

Here's what I have, and recall that I just started yesteday and I have no prior scripting experience =)

$visio2003=IniRead("Software Install Location\locations.ini", "Visio2003", "Visio2003", "")
$LICENSE1="XXXXX"
$LICENSE2="XXXXX"
$LICENSE3="XXXXX"
$LICENSE4="XXXXX"
$LICENSE5="XXXXX"

; Prompt the user to run the script - use a Yes/No prompt 
$answer = MsgBox(4, "Visio 2003 Install", "This will install Visio 2003, continue?")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Visio 2003 Install", "Visio 2003 Installation Cancelled")
    Exit
EndIf

Run($visio2003)

; License input screen
WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "In the boxes below, type your 25-character Product Key")
SEND($LICENSE1)
SEND($LICENSE2)
SEND($LICENSE3)
SEND($LICENSE4)
SEND($LICENSE5)
ControlClick("Microsoft Office Visio Professional 2003 Setup", "In the boxes below, type your 25-character Product Key", 2683)

; Clicking next
WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "Microsoft Office Visio Professional 2003")
ControlClick("Microsoft Office Visio Professional 2003 Setup", "&Next >", 2683)

; Clicking "I agree"
WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "&Next >")
ControlClick("Microsoft Office Visio Professional 2003 Setup", "&Next >", 299)
ControlClick("Microsoft Office Visio Professional 2003 Setup", "&Next >", 2683)

; Choosing install choice
WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "&Custom Install")
ControlClick("Microsoft Office Visio Professional 2003 Setup", "&Custom Install", 7168)
ControlClick("Microsoft Office Visio Professional 2003 Setup", "&Custom Install", 2683)

; Clicking Install
WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "Setup is ready to begin installing and will perform the following tasks:")
ControlClick("Microsoft Office Visio Professional 2003 Setup", "Setup is ready to begin installing and will perform the following tasks:", 2697)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I believe MS office products have built in ability for unattended installation via text configuration files.

Anyways, Maybe try a sleep after each command?

This seemed to work reliably for me:

Also I used "ControlSetText" to enter the key.

opt("TrayIconDebug",1)
Run($visio)

WinWait("Microsoft Office Visio","In the boxes below, type your 25-character Product Key")
$whnd=WinGetHandle("Microsoft Office Visio","In the boxes below, type your 25-character Product Key")
ControlSetText($whnd,"","Edit1",$LICENSE1)
ControlSetText($whnd,"","Edit2",$LICENSE2)
ControlSetText($whnd,"","Edit3",$LICENSE3)
ControlSetText($whnd,"","Edit4",$LICENSE4)
ControlSetText($whnd,"","Edit5",$LICENSE5)
ControlClick($whnd, "",2683)    ;Next

WinWait("Microsoft Office Visio","User Information")
$whnd=WinGetHandle("Microsoft Office Visio","")
ControlClick($whnd, "",2683)    ;Next

WinWait("Microsoft Office Visio","End-User")
$whnd=WinGetHandle("Microsoft Office Visio","")
ControlCommand($whnd,"",299,"check"); Accept Eula checkbox
ControlClick($whnd, "",2683)    ;Next

WinWait("Microsoft Office Visio","Type of Installation")
$whnd=WinGetHandle("Microsoft Office Visio","")

ControlCommand($whnd,"",23579,"check") ;Custom install
Controlclick($whnd, "",2683)    ;Next

WinWait("Microsoft Office Visio","Choose installation options")
$whnd=WinGetHandle("Microsoft Office Visio","")

Edit: cleaner code

Edited by TurionAltec

Share this post


Link to post
Share on other sites

Looking at your code, this line:

WinWaitActive("Microsoft Office Visio Professional 2003 Setup", "&Next >")

May cause problems as every window will contain "&Next >" so it may keep continuing on without waiting for the new window. Use more unique text

WinWait("Microsoft Office Visio","End-User")

Also to help with debugging, put this in the beggining of your script:

opt("TrayIconDebug",1)

This will display the current line of execution if you hover your mouse over the AutoIT tray icon.

Share this post


Link to post
Share on other sites

Thanks for the reply!

I know that I can use the answer files provided by MS for automation, but I like seeing a process work, rather than waiting for the actual process to be done in Task Manager. Also, it gets me a good feel for how AutoIT can work for us! =)

I noticed that you changed WinWaitActive to WinWait. Should there be only one "Active" command, for when the install dialog first pops up and then all subsequent commands are to be WinWait's? Thanks again!

Share this post


Link to post
Share on other sites

Since we're not directly automating the installation via "Send()" or "mouseclick()" we don't need to worry about the window being active, as controlclick() can work on a background window.

Share this post


Link to post
Share on other sites

Fantastic, I understand now!

In your code, you have it going to the custom install screen. Not that I want to do this, but when I did try to code it that way, I get into some issues.

When I get to the actual custom place, the control ID for the buttons are all the same. I assume I can just use the ControlClick coords to hit the top level install option, but once I do that, there's no more window information for the options "Run from my computer, Run all from my computer, etc). How do I tell it to choose those options without having to to use a Send() of keyboard commands?

Thanks again for the help =)

Share this post


Link to post
Share on other sites

Try to use ControlCommand() function with Check command.

It should work with clicking the button.

And use the Advanced Class name from the AutoIt Window info.

Sample with XP's Disk Defragmenter:

ControlCommand("Computer Management", "", "[CLASS:Button; INSTANCE:1]", "Check", "")

[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]

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  
Followers 0