DH Posted June 19, 2015 Posted June 19, 2015 I use AutoIt to kick off those nasty application installer which has no silent install feature.It's OK to execute only 1 installer. But not always work if I need to execute several installer in sequence. (I use Microsoft MDT to make them execute in sequence)Codes are simple.First,Run("setup.exe")Second,WinWait("The title", "Some text")Third,If WinExists("The title", "Some text") Then WinActivate("The title", "Some text") WinWaitActive("The title", "Some text")Fourth, here do the action such asSend("!n") Send("{ENTER}")The 1st installer always success. The 2nd one sometime. Never make it to the 3rd.The problem is, WinActivate seems can focus to the target window (because I saw the installer icon flash few times at the taskbar), but then stop.Then I manually click on the target window, it start to run the remaining scripts. This indicate that it was waiting for the target window to be activate.
water Posted June 19, 2015 Posted June 19, 2015 (edited) Welcome to AutoIt and the forum!Do it in a While loop. Check the return value of WinWaitActive and exit the loop on success. Edited June 19, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
DH Posted June 19, 2015 Author Posted June 19, 2015 (edited) Hello water,So you think the problem is caused by WinWaitActive, but not WinActivate ?Should I modify like this$status = 1 While $status = 1 If WinWaitActive("Title", "text") <> 0 Then Send("!n") $status = 0 Else WinActivate("Title", text") EndIf WEnd Edited June 19, 2015 by DH
DH Posted June 19, 2015 Author Posted June 19, 2015 Just want to say the above modified code is not work
Developers Jos Posted June 19, 2015 Developers Posted June 19, 2015 That doesn't look right. WinWaitActive() will wait forever since there is no timeout specified, so guess that should be a WinExists()?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
DH Posted June 19, 2015 Author Posted June 19, 2015 Hi Jos,My situation is I got 3 application installer (e.g. abcsetup.exe, defsetup.exe and ghisetup.exe)And I made 3 autoit to execute each of them (e.g. abcauto.exe, defauto.exe and ghi.exe)Then use Microsoft MDT to execute those 3 autoit exe in sequence.The weird thing is the scripts never has problem if I just run a single exe file.But in sequence, the first one never fail. It usually fail start from the 2nd one.
ViciousXUSMC Posted June 19, 2015 Posted June 19, 2015 I have never had an issue with just WinWait() and WinActivate() I never needed to use WinWaitActive()Since your 2nd Script already waited for the window for an infinite amount of time, there is no need to check for it in the 3rd part of the script. So I would just strip it down to this:Run("setup.exe") WinWait("The title", "Some text") WinActivate("The title", "Some text") Send("!n") Send("{ENTER}")If you wanted a conditional so that it loops so many times and exits add a loop with a If WinExists() but a more simple way for this kind of script is to just add a timeout value to your WinWait. Run("setup.exe") ;Look for Window for 10 Seconds if Not Found Exit Scirpt If WinWait("The title", "Some text", 10) = 0 Then Exit WinActivate("The title", "Some text") Send("!n") Send("{ENTER}")
ViciousXUSMC Posted June 19, 2015 Posted June 19, 2015 Hi Jos,My situation is I got 3 application installer (e.g. abcsetup.exe, defsetup.exe and ghisetup.exe)And I made 3 autoit to execute each of them (e.g. abcauto.exe, defauto.exe and ghi.exe)Then use Microsoft MDT to execute those 3 autoit exe in sequence.The weird thing is the scripts never has problem if I just run a single exe file.But in sequence, the first one never fail. It usually fail start from the 2nd one. Sounds like your issue may be with your deployment not your script.What you gave us as an example was just a simple single installer. If you want to install multiple things in a single script you can do it many ways. Using the same code I just posted you could do it like this. ;Multi Installer Program1() Program2() Program3() Func Program1() Run("setup1.exe") ;Look for Window for 10 Seconds if Not Found Goto Next Function If WinWait("The title", "Some text", 10) = 0 Then Return WinActivate("The title", "Some text") Send("!n") Send("{ENTER}") EndFunc Func Program2() Run("setup2.exe") ;Look for Window for 10 Seconds if Not Found Goto Next Function If WinWait("The title", "Some text", 10) = 0 Then Return WinActivate("The title", "Some text") Send("!n") Send("{ENTER}") EndFunc Func Program3() Run("setup3.exe") ;Look for Window for 10 Seconds if Not Found Goto Next Function If WinWait("The title", "Some text", 10) = 0 Then Return WinActivate("The title", "Some text") Send("!n") Send("{ENTER}") EndFunc
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now