colombeen Posted September 9, 2014 Share Posted September 9, 2014 Hi guys Have bit of a problem. I use the ShellExecute function to start some driver setups but the time it takes for some drivers to give you some setup screen takes a long time and i'm wondering if someone knows a good way how to show in a gui that the user has to wait a bit until the setup starts. Like a loading screen or something. Any ideas? Thx Link to comment Share on other sites More sharing options...
saudumm Posted September 9, 2014 Share Posted September 9, 2014 Hi try something like this #include <AutoItConstants.au3> #include <FontConstants.au3> Local $splash = SplashTextOn('Setup', 'Loading Setup. Please wait.', 350, 100, -1, -1, $DLG_NOTONTOP + $DLG_MOVEABLE + $DLG_TEXTVCENTER, '', 16, $FW_EXTRABOLD) ;~ ShellExecute your setup WinWait('Title of your Setup screen') SplashOff() Link to comment Share on other sites More sharing options...
colombeen Posted September 9, 2014 Author Share Posted September 9, 2014 (edited) The problem is that the tool now has 300+ drivers... I can't really use that for every driver :-p does anyone know if it is possible to show a SplashTextOn and make it disapper when it loses focus? Edited September 9, 2014 by colombeen Link to comment Share on other sites More sharing options...
saudumm Posted September 9, 2014 Share Posted September 9, 2014 (edited) This would be one way, but then the splash disappears the moment it loses focus (for examle: the user clicks on something else). Maybe somebody else knows a better way to do this^^ #include <AutoItConstants.au3> #include <FontConstants.au3> Local $splash = SplashTextOn('Setup Splash', 'Loading Setup. Please wait.', 350, 100, -1, -1, $DLG_NOTONTOP + $DLG_MOVEABLE + $DLG_TEXTVCENTER, '', 16, $FW_EXTRABOLD) WinActivate('Setup Splash') ; Otherwise it's not focussed!? ;~ ShellExecute your setup While 1 If Not WinActive('Setup Splash') Then ExitLoop Sleep(100) WEnd SplashOff() Edited September 9, 2014 by saudumm Link to comment Share on other sites More sharing options...
jguinch Posted September 9, 2014 Share Posted September 9, 2014 You can wait for a window associated with the setup process. For example : expandcollapse popupLocal $splash = SplashTextOn('Setup Splash', 'Loading Setup. Please wait.', 350, 50, -1, -1) $iPid = ShellExecute("\\server\share\driver\setup.exe") _WinWaitPID($iPid) SplashOff() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinWaitPID ; Description ...: Pauses execution of the script until a window associated with the specifed PID exists ; Syntax ........: _WinWaitPID($iPid[, $iFlagActive = 0[, $iTimeout = 0]]) ; Parameters ....: $iPid - Process ID (PID). ; $iFlagActive - [optional] . 0 = (default) Returns as soons as the window appears. ; 1 = Waits for the window to be active. ; $iTimeout - Timeout in seconds if the window does not exist. Default is 0 (no timeout). ; Return values .: Success = a handle to the window. ; Failure = 0 if timeout occured ; Author ........: jguinch ; =============================================================================================================================== Func _WinWaitPID($iProcessID, $iFlagActive = 0, $iTimeout = 0) Local $hTimer = TimerInit() $iTimeout = $iTimeout * 1000 While 1 If $iTimeout AND $hTimer >= $iTimeout Then Return 0 Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then If WinGetProcess($aWinList[$i][1]) = $iProcessID Then If $iFlagActive Then If WinActive($aWinList[$i][1]) Then Return $aWinList[$i][1] Else Return $aWinList[$i][1] EndIf EndIf EndIf Next Sleep(10) WEnd EndFunc ; ===> _WinWaitPID Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
colombeen Posted September 9, 2014 Author Share Posted September 9, 2014 (edited) It's isn't neccesairy anymore. With the SplashTextOn, it was easy. Just put the code to hide the splashtexton after the shellexecute and when the notification pops up to allow the installation, and you accept, it just dissapears :-) so it's fixed. Thx everybody :-) the only thing that would have been better is that i could show how much has been loaded... but i don't think that's something thats easily doable. Edited September 9, 2014 by colombeen Link to comment Share on other sites More sharing options...
jguinch Posted September 9, 2014 Share Posted September 9, 2014 So, if the user clicks somewhere, the Splash will loose the focus and will disapear... If it suits you, great. It is much simpler. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Solution colombeen Posted September 9, 2014 Author Solution Share Posted September 9, 2014 (edited) No I didn't need the focus part anymore. I did : -> show splash -> shellexecute -> hide splash hiding the splash gets called right after you get the "do you want to install"-notification from the driver setup. this because the script just waits for the notification to popup, and continues after that but maybe i could change it to copy the file to %temp% with a progress bar and then execute it. EDIT : now I found this piece of code on the forum : _FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp") Func _FileCopy($fromFile,$tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES) EndFunc only 1 problem... the script just continues while the copy is still going. anyone who knows how to change this function into a "wait until completed before going any further"-function? EDIT AGAIN : I found a solution : _FileCopy ($serverLocation & "\" & $file, @TempDir) While 1 If FileExists (@TempDir & "\" & $file) Then If FileGetSize (@TempDir & "\" & $file) = FileGetSize ($serverLocation & "\" & $file) Then ExitLoop EndIf EndIf Sleep (1000) WEnd ShellExecute (@TempDir & "\" & $file) Edited September 9, 2014 by colombeen Link to comment Share on other sites More sharing options...
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