ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

REQ: HTPC Util - Hide Desktop for x seconds while program is being executed.

<< < (2/5) > >>

Stoic Joker:
More useful yes, simpler? Getting it to close consistently when the application that is opening doesn't know it's supposed to tell it to exit just strikes me as a bit problematic - But then again perhaps I've just been traumatized by my previous foolish attempts at getting a return value from ShellExec(...). So I figure to avoid the whole message loop peek-A-boo bit just leave it running.

*Shrug* Just a Thought man :D

mouser:
I would just let it take a delay value, and exit itself after X seconds.

If you wanted to get fancy, let it take on the commandline the secondary application to execute, and then exit after that program has launched and opened a window (and then switch to that window on exit).

4wd:
I haven't used/seen MCE but if it has a GUI couldn't you use Process.WaitForInputIdle to detect when the MCE interface comes up?

You could always have a timeout option to fall back to.

4wd:
Proof of concept: BlankIt

Usage: BlankIt.exe "full\path\to\executable" [timeout]

Where [timeout] is an integer, (no limit, in seconds), if a value isn't given, (or 0), then the default is 15 seconds.

What it does:
Screen goes black until the called programs GUI is ready for input.  The timeout will kick in if the GUI doesn't open in time or the program has no GUI.

I've only done limited testing with a few programs but it didn't seem to format my HDD.

Executes the program argument, then displays a topmost, borderless black window.  The PID from the Run command is used to execute a Process.WaitForInputIdle call.  If it's received or the timeout occurs, the window is hidden and BlankIt exits.  (Not really necessary to hide the window since BlankIt exits immediately after but wth ...)

NOTE: VERY minimal error checking is done in the program, (doesn't even check for existence of argument program).  Now it does.

Also note, if the program you want to run normally requires Admin privileges, then BlankIt will need to be run from a CLI with Admin privileges to avoid the UAC requester, (unless UAC is disabled).


--- Code: AutoIt ---#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_UseUpx=n#AutoIt3Wrapper_Change2CUI=y#AutoIt3Wrapper_Res_Fileversion=0.0.1.32#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****#cs ----------------------------------------------------------------------------  AutoIt Version: 3.3.8.1 Name:           BlankIt.au3 Author:         4wd  Script Function:        Blanks screen until called programs GUI opens and is ready for input.  Requires:        Ascend4nt's Process Function UDF: http://www.autoitscript.com/forum/topic/115352-process-thread-dll-functions-udfs/ #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3>#Include <WinAPIEx.au3>#include <WindowsConstants.au3>#include "[includes]\_ProcessFunctions.au3" Opt('MustDeclareVars', 1) Const $iAccess=0x00001000Local $iTimeout = 15, $sCommand, $sPath #Region ### START Koda GUI section ### Form=Global $Blank = GUICreate("Blank", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)GUISetBkColor(0x000000)#EndRegion ### END Koda GUI section ### If $CmdLine[0] = 0 Then _Usage()For $i = 1 To $CmdLine[0]        Switch StringRegExp($CmdLine[$i], "(?i)[a-z]+", 0)                Case 0                        If $CmdLine[$i] > 0 Then $iTimeout = $CmdLine[$i]                Case 1                        If StringInStr($CmdLine[$i], "\") > 0 Then                                $sCommand = $CmdLine[$i]                                $sPath = StringLeft($sCommand, StringInStr($sCommand, "\", 0,-1))                        Else                                $sPath = @ScriptDir & "\"                                $sCommand = $sPath & $CmdLine[$i]                        EndIf                Case Else        EndSwitchNext If $sCommand = "" Or Not FileExists($sCommand) Then        ConsoleWrite("Error: Executable does not exist!" & @CRLF & @CRLF)        _Usage()EndIf$iTimeout *= 1000 Local $iPID = Run($sCommand, $sPath)If $iPID <> 0 Then        GUISetState(@SW_SHOW)        Local $hProcess = _ProcessOpen($iPID, $iAccess)        If $hProcess <> 0 Then                _ProcessWaitForInputIdle($hProcess, $iTimeout)                _ProcessCloseHandle($hProcess)        Else                Sleep($iTimeout)        EndIf        Sleep(250)        GUISetState(@SW_HIDE)        Local $Data = _WinAPI_EnumProcessWindows($iPID)        If IsArray($Data) Then                If $Data[0][0] > 0 Then                        _WinAPI_SetFocus($Data[1][0])                EndIf        EndIfEndIf _Exit() Func _Usage()        ConsoleWrite("Usage: BlankIt.exe <executable> [timeout]" & @CRLF & @CRLF)        ConsoleWrite("Where: <executable> = full path to executable, (include quotes if required)" & @CRLF)        ConsoleWrite("       [timeout]    = optional time to wait for program interface in seconds" & @CRLF)        ConsoleWrite("                      Default = 15" & @CRLF)        _Exit()EndFunc Func _Exit()        ExitEndFunc

mouser:
Nice.  Will the new window get focus, or might that be a feature to add?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version