Jump to content
Sign in to follow this  
tpirog

Basic Auto-It introductory lessons

Recommended Posts

tpirog

I have been creating installation scripts for my programs, and am stuck doing "install_flash_player.exe". On the last screen I need a tab and a space. It isn't happening. My first issue is that I don't want to bother you guys with my trivial stuff, but I can't find a good basic tutorial that will tell me what all the BASIC parameters are. For example, using the tutorial for Winzip, I see "WinWaitActive("WinZip® 9.0 SR-1 Setup", "&Setup")". I can't find any documentation telling me what the parameter ("&Setup") represents, and I suspect it is crucial to understand that in depth. So far I have been lucky and have gotten several scripts to work, but this flash player one has me stumped.

Here is my current script:

Run("install_flash_player.exe")

WinWaitActive("Install Adobe Flash Player")

Send("{TAB}")

Send("{SPACE}")

Send("{TAB}")

Send("{TAB}")

Send("{SPACE}")

WinWaitActive("Install Adobe Flash Player", "&DONE")

Send("{TAB}")

Send("{SPACE}")

When it reaches the final screen nothing happens. Anyone have any suggestions?

I will post a screen scrape but I have to exit my browser to do that. Will be back.

Thanks a lot.

Tony

Share this post


Link to post
Share on other sites
AJStevens

Hi Tony

Make sure you're using SciTE (download on the main AutoIT website), and press F1 while you have a function selected, or alternatively, go to the index tab and type it in eg. WinWaitActive

It'll tell you what the params are, and usually give an example code you can open and test.

WinWaitActive is waiting for a Window to become Active... and to find what window it's waiting to be active you specify the window name "WinZip® 9.0 SR-1 Setup", however this will always match, a problem when you're waiting for say a particular screen to be visible (most installers have several "screens" right? So the second param looks inside for some text, in this case "&Setup" which is the text label of a button, and only appears on the first page of the installer.

As for your script, sending space is all well and good for ticking a tick box, but not for activating buttons, try a Send("{ENTER}") instead of the last Send("{SPACE}") I'd also change WinWaitActive("Install Adobe Flash Player", "&DONE") to WinWaitActive("Install Adobe Flash Player", "Installation Complete") so then it'll match when the installer shows "Installation Complete" although, not sure you want WinWaitActive, since this means it must be the "Active" window, WinWait might be better.

Another useful tool is AutoIt Window Info, which you should find in your autoit start menu, it can select windows and tell you what information you can pull from it, hopefully it'll show the text inside as "Installation Complete" when it gets to that stage.

Edited by AJStevens

Share this post


Link to post
Share on other sites
tpirog

Thank you AJ.

I can't seem to get "AutoIt Window Info" to give me any info. Are there instructions for this anywhere?

Anyway, I used your suggesiton and it still does nothing on the "installation complete" page. Here's the latest script (it needs a tab before the "Enter"):

Run("install_flash_player.exe")

WinWaitActive("Install Adobe Flash Player")

Send("{TAB}")

Send("{SPACE}")

Send("{TAB}")

Send("{TAB}")

Send("{SPACE}")

WinWait("Install Adobe Flash Player", "Installation complete.")

Send("{TAB}")

Send("{ENTER}")

Share this post


Link to post
Share on other sites
tpirog

I've tried all kinds of variations, and none work. Is there something specific that you see? Like based on what you see here, what would your final Winwait command look like?

Thanks.

Tony

Share this post


Link to post
Share on other sites
JohnOne

I imagine that window pops up and becames the active one.

If so you could

$hDone = WinGetHandle("[ACTIVE]","")
ControlClick($hDone,"","[CLASS:Button; INSTANC:3]")

Assuming the info above is for that window.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
tpirog

Please assume I am a beginner. I didn't understand what that last post meant but I did the following and it made no difference:

Run("install_flash_player.exe")

WinWaitActive("Install Adobe Flash Player")

Send("{TAB}")

Send("{SPACE}")

Send("{TAB}")

Send("{TAB}")

Send("{SPACE}")

$hDone = WinGetHandle("[ACTIVE]","")

ControlClick($hDone,"","[CLASS:Button; INSTANC:3]")

Send("{TAB}")

Send("{ENTER}")

BTW: The "AutoIt Windows Info" app is awesome! My next install went super easy with its help. Thanks a lot. (Note: Still can't get flash to finish.)

Share this post


Link to post
Share on other sites
JohnOne

How many windows pop up during intallation?

Do they all have the same title?

Try this

Run("install_flash_player.exe")
$hwnd = WinWaitActive("Install Adobe Flash Player")
Send("{TAB}")
Send("{SPACE}")
Send("{TAB}")
Send("{TAB}")
Send("{SPACE}")
While 1
$hDone = WinGetHandle("[ACTIVE]","")
Sleep(100)
If $hDone <> $hwnd Then
Send("{TAB}")
Send("{ENTER}") 
EndIf
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
tpirog

2 screens and yes they both have the same title.

The script with the loop doesn't work either.

I really appreciate you time and trying to help by the way.

Share this post


Link to post
Share on other sites
AJStevens

Hmm.. it has no visible or hidden text to work with... so I've opted for a Pixel Colour based check, the "Done" button becomes active once installation is complete, so I've done that since trying to check if it was enabled or not just always said it was enabled... trust Adobe not to use a normal dialog box.

What we do, is an infinite loop until the pixel is the colour of the button enabled, but not highlighted at the end of the install. You might want to add a timeout to this using Timer init.

Opt("PixelCoordMode", 2)

$fPID = Run("install_flash_player.exe")
$fHND = WinWait("Install Adobe Flash Player","This program will install")
ControlSend($fHND,"","","{TAB}")
ControlSend($fHND,"","","{SPACE}")
ControlSend($fHND,"","","{TAB}")
ControlSend($fHND,"","","{TAB}")
ControlSend($fHND,"","","{SPACE}")

While 1
    If PixelGetColor(423, 123, $fHND) = 5987163 Then ExitLoop
    Sleep(100)
WEnd
ControlSend($fHND,"","","{TAB}")
ControlSend($fHND,"","","{ENTER}")
Exit

This version saves the Tabing and just goes straight for the controls.

Opt("PixelCoordMode", 2)

$fPID = Run("install_flash_player.exe")
$fHND = WinWait("Install Adobe Flash Player","This program will install")
ControlSend($fHND,"","[CLASS:Button;INSTANCE:4]","{SPACE}")
ControlSend($fHND,"","[CLASS:Button;INSTANCE:3]","{SPACE}")

While 1
    If PixelGetColor(423, 123, $fHND) = 5987163 Then ExitLoop
    Sleep(100)
WEnd
ControlSend($fHND,"","[CLASS:Button;INSTANCE:3]","{SPACE}")
Exit
Edited by AJStevens

Share this post


Link to post
Share on other sites
AJStevens

Also, if Safari, Opera or Firefox are open, the Installer pauses indefinately. So I've added this to quit if it's unable to install at that time.

Opt("PixelCoordMode", 2)

$fPID = Run("install_flash_player.exe")
$fHND = WinWait("Install Adobe Flash Player","This program will install")
ControlSend($fHND,"","[CLASS:Button;INSTANCE:4]","{SPACE}")
ControlSend($fHND,"","[CLASS:Button;INSTANCE:3]","{SPACE}")

While 1
    If PixelGetColor(423, 123, $fHND) = 5987163 Then ExitLoop
    If WinExists("Install Adobe Flash Player","The installer will automatically continue when ") Then ; Installer is paused waiting to close
    ControlSend($fHND,"","[CLASS:Button;INSTANCE:1]","{SPACE}") ; Quits the Install
    EndIf
    Sleep(100)
WEnd
ControlSend($fHND,"","[CLASS:Button;INSTANCE:3]","{SPACE}")

Exit

Or, have it kill the browsers, they should save their current status and open restore it automatically again after it restarts them, maybe overkill though.

Opt("PixelCoordMode", 2)

$fPID = Run("install_flash_player.exe")
$fHND = WinWait("Install Adobe Flash Player", "This program will install")
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:4]", "{SPACE}")
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:3]", "{SPACE}")

While 1
    If PixelGetColor(423, 123, $fHND) = 5987163 Then ExitLoop
    If WinExists("Install Adobe Flash Player", "The installer will automatically continue when ") Then ; Installer is paused waiting to close
        If ProcessExists("firefox.exe") Then
            $fRestartFirefox = True
            ProcessClose("firefox.exe")
        EndIf
        If ProcessExists("opera.exe") Then
            $fRestartOpera = True
            ProcessClose("opera.exe")
        EndIf
        If ProcessExists("safari.exe") Then
            $fRestartSafari = True
            ProcessClose("safari.exe")
        EndIf
    EndIf
    Sleep(100)
WEnd
ControlSend($fHND, "", "[CLASS:Button;INSTANCE:3]", "{SPACE}")

; Restart any closed Browsers
If $fRestartFirefox Then
$FireFoxVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\","CurrentVersion")
$FireFoxEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\" & $FireFoxVer & "\Main\","PathToEXE")
$ffPID = Run($FireFoxEXE)
$ffHND = WinWait("Restore Session - Mozilla Firefox", "")
ControlSend($ffHND, "", "", "R")
EndIf
If $fRestartOpera Then
$OperaEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Opera Software\","Last CommandLine")
$oPID = Run($OperaEXE)
$oHND = WinWait("Welcome to Opera", "")
ControlSend($oHND, "", "", "{ENTER}")
EndIf
If $fRestartSafari Then
$SafariEXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\Safari\","BrowserExe")
Run($SafariEXE)
EndIf

Exit
Edited by AJStevens

Share this post


Link to post
Share on other sites
tpirog

Hmmm, On my win 7 32 machine, the window wont accept any controlclicks, controlsends, or sends.

So it's not just me. Whew. (I'm on Win 7 64.)

I think I'll just have to install the flash explicitly after I've done everything else.

Edited by tpirog

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.