Pimmetje Posted February 10, 2009 Posted February 10, 2009 (edited) Hi i am trying to make a script i can kind of reuse. I want it to be able to hide a running setup. Here is what i have. (It's for installing a old version demontools) expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: Pimmetje Script Function: Installs any kind of software if the buttons are add #ce ---------------------------------------------------------------------------- Global $hide = true Global $setwindelay = False Global $blockinpit = False Global $programpid ; Stores the program processid after start Global $currenttitle ; Store the wizard title Global $windowstext ; Store some text to recinise the window Global $programexe = "dt346.exe" ; Stores how the program needs to be start ; Try to block user if wanted block(1) ; Run script if($hide) Then $programpid = run($programexe, @ScriptDir, @SW_HIDE) Else $programpid = run($programexe, @ScriptDir) EndIf ; Wait for install to show $currenttitle = "DAEMON Tools Setup" $windowstext = "DAEMON Tools End User License Agreement" waitforwindow() ; Click Accept cbuttun(1) $currenttitle = "DAEMON Tools 3.46.0" $windowstext = "Welcome to the DAEMON Tools Setup Wizard" ; Wait for the installer window waitforwindow() ; Click next cbuttun(845) $windowstext = "The installer will install DAEMON Tools with default options specified below." ; Wait for next window waitforwindow() ; Click next cbuttun(845) $windowstext = 'Click "Next" to start the installation.' ; Wait for a new licencing windows waitforwindow() ; Click the next button cbuttun(845) $windowstext= "has been successfully installed." ; Wait for the finish window waitforwindow(120) ; Wait 2 minutes for installer to give time out ; Click Close cbuttun(957) $windowstext ="You must restart your system for the configuration changes made to DAEMON Tools to take effect. Click Yes to restart now or No if you plan to manually restart later." ; We do not want to restart wait for restart question waitforwindow() ; Select no cbuttun(8) ; Run demontools afterwards run(@ProgramFilesDir&"\D-Tools\daemon.exe") block(0) Exit ;########################################################################################### ;================================Functions down here======================================== ; Wait for a window else if timeout error will be executed ; Uses Global vars func waitforwindow($timeout = 60) dim $end = False while (not $end) if(not WinWait($currenttitle, $windowstext, $timeout)) Then error() Else sleep(1000) ExitLoop EndIf WEnd EndFunc ; Error if timeout occurs func error() block(0) ; Unblock input if needed dim $return = MsgBox(21, "Timeout", "installer has timed out Abbort?", 10) ; Type 5 & 16 (Retry and Cancel in error window) if($return == 4) Then block(1) ; Retry block it again Else ; User not clicked retry / timeout occurs ; Exit installer ProcessClose($programpid) ; Close the install Exit EndIf Exit EndFunc ; Click button for current windows / Text func cbuttun($id) return ControlClick($currenttitle, $windowstext, $id) EndFunc ; Block input if needed Func block($bool) if($blockinpit) then BlockInput ($bool) EndIf EndFunc If i set Hide to false, scripts runs fine. But when i set hide to true it will start the setup but wait forever because it can't find the window. I think the mistake i minor, i hope the code is useful for someone else. It's just my idea of making a installer. Hope some1 sees my problem, Thanks for reading Pimmetje Edited February 10, 2009 by Pimmetje
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