Sign in to follow this  
Followers 0
Dobs78

AutoIt3 Newbie Help

8 posts in this topic

Before the flames hit, I've spent the better part of 2 days trying to find the information I'm about to request, I did make a valid effort in attempting to utilize old forum posts, archived posts, the Help File, etc. etc.

Preface: I'm trying to automate the installation of several .exe files. These .exe files are created by Setup Factory 7.0 and 8.0. The company I work for has a couple hundred clients that each utilize a completely unique program for their information. What this means for me, is I need to automate installations for upwards of 200 .exe files so that I can ditch the manual process of having to run CD's or running each executable manually.

Problem: I have successfully automated one install, however .. my problem is when I start adding additional installers. Install #1 will fire off just fine and dandy, Install #2 starts, but doesn't hit the "Finish" button 75% of the time, but Install #3 fires anyways.

All I'm looking for is the easiest way to run multiple installs back to back (ie. one install ends, the next starts, so on and so forth). Unfortunately, the scripts I've seen/found are far too advanced for my current level of knowledge with AutoIt and am looking for the utmost cavemanish script I can get to be able to run these installs.

This is what I've got so far:

; Run Install 1

Run("C:\Install1.exe")

WinWaitActive("Title", "Next")

Send("!n")

WinWaitActive("Title1", "Installation Successful", 1)

ControlClick("Title1", "", "[iD:100]", "left")

ProcessWaitClose("Install1.exe")

; Run Install 2

Run("C:\Install2.exe")

WinWaitActive("Title2", "Next")

Send("!n")

WinWaitActive("Title2", "Installation Successful", 5)

ControlClick("Title2", "", "[iD:100]", "left")

processWaitClose("install2.exe")

; Run Install 3

Run("C:\Install3.exe")

WinWaitActive("Title3", "Next")

Send("!n")

WinWaitActive("Title3", "Installation Successful", 5)

ControlClick("Title3", "", "[iD:100]", "left")

processWaitClose("Install3.exe")

Now, as I said above, my installs do start and "finish" but for some reason, and this happens 75% of the time, on the ControlClick, sometimes it hits finish, sometimes it doesn't. And when Finish isn't hit, the process shouldn't terminate, but Install 3 will start anyways. If anyone has a more barbaric and simplistic way for me to achieve what I'm trying to do or can help me with what I've already got, many thanks in advance. If you can, break it down Barney style for me. I'd rather have 100 separate "Run" commands than deal with variables and if/then statements, at least until I start learning more about AutoIt that is. Upon request, I can upload screenshots of the Control values obtained by the AutoIt Window Info Tool if you think that may be an issue. If more information is needed, I'll do my best to provide it. Again, thanks in advance.

Share this post


Link to post
Share on other sites



Instead of using a send command, you should definately use controlclick(). This will allow more versatility. For the ControlClick()s that you have, you can replace the "[iD:100]" with 100, you don't need any quotes or anything. The thing that might be causing the problem is the winwaitactive() functions. Right now, you have the functions exit after only a few seconds. The script is probably exiting before the screen can appear. To fix this problem, take out the number of seconds to wait or just change the number to something like 15. Hope this helps.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

; Run Install 1
$Run = Run("C:\Install1.exe")
While ProcessExists($Run)
    If WinActive("Title", "Next") Then Send("!n")
    If WinActive("Title1", "Installation Successful", 1) Then
        ControlClick("Title1", "", "[ID:100]")
        ProcessWaitClose($Run)
    EndIf
    Sleep(100);; Save CPU cycles
WEnd


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

1. First, are you sure there isn't a "quiet" switch, like "/qn", for the installer that keeps you from having to deal with a GUI at all? That is always the preferred method -- avoid the GUI in the first place.

2. Next, when you Run() something the PID of the process is returned. Use that to test if it's still running.

3. Always use ControlSend() instead of Send().

4. Put anything you do over and over in a loop.

5. If you wait for a window with a timeout, make sure you leave time for worst-case execution time.

6. Demo of principles 2 thru 5:

Global $avInstalls[3] = ["C:\Install1.exe", "C:\Install2.exe", "C:\Install3.exe"]
Global $avTitles[3] = ["Install One", "Install Two", "Install Three"]
Global $iPID

For $n = 0 to UBound($avInstalls) - 1
    $iPID = Run($avInstalls[$n])
    If @error Then
        MsgBox(16, "Error", "Failed to launch " & $avInstalls[$n], 30)
        Exit
    EndIf
    
    WinWait($avTitles[$n], "Next")
    ControlSend($avTitles[$n], "Next", "", "!n")
    WinWaitActive($avTitles[$n], "Installation Successful", 30)
    ControlClick($avTitles[$n], "Installation Successful", "[ID:100]", "left")
    ProcessWaitClose($iPID)
Next

Hope that helps.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you for the responses. I'll give each of them a try and go from there. Again, thank you for the assistance, it is greatly appreciated.

Share this post


Link to post
Share on other sites

Not that anyone would care, but I got my script working using a smidge of each of your suggestions and also had a question. My script now looks like this:

; Run Install 1

;Run("C:\Install1.exe")

;WinWaitActive("Title", "Next")

;ControlSend("Title", "Next", "", "!n")

;WinWaitActive("Title", "&Finish")

;ControlClick("Title", "", "[iD:100]", "left")

;ProcessWaitClose("Install1.exe")

Used the ControlSend and got rid of the wait, but I was still having a couple of script pauses every so often. Now my question, in the Window Info Tool, there was visible text and hidden text. You'll note that on my original script, I had "Installation Successful", but that text did not show up on the visible text tab of the Window Info Tool. Is the text found on the visible text tab the only text you can use to identify the window when the Title remains the same throughout the install?

Share this post


Link to post
Share on other sites

Not that anyone would care, but I got my script working using a smidge of each of your suggestions and also had a question. My script now looks like this:

; Run Install 1

;Run("C:\Install1.exe")

;WinWaitActive("Title", "Next")

;ControlSend("Title", "Next", "", "!n")

;WinWaitActive("Title", "&Finish")

;ControlClick("Title", "", "[iD:100]", "left")

;ProcessWaitClose("Install1.exe")

Used the ControlSend and got rid of the wait, but I was still having a couple of script pauses every so often. Now my question, in the Window Info Tool, there was visible text and hidden text. You'll note that on my original script, I had "Installation Successful", but that text did not show up on the visible text tab of the Window Info Tool. Is the text found on the visible text tab the only text you can use to identify the window when the Title remains the same throughout the install?

It should have shown up as the text of a control, probably a label, so check the control itself.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Is the text found on the visible text tab the only text you can use to identify the window when the Title remains the same throughout the install?

By default, only visible text is used. You can change that with:
Opt(WinDetectHiddenText, 1)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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