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.

<< < (3/5) > >>

4wd:
v0.0.1.32 <- Link

* Change: Reverts to timeout value if a handle to the process can't be obtained.
* Added:  Set focus to program window, (if it has one), before exiting.
* Added:  Simple usage directions, (run it without any arguments).
* Change: Compiled as a CLI program, it produces no GUI, all errors go to the CLI.
* Change: Slightly better args parsing, (not much better but it is an improvement).
* Added:  Checks for executable existence, (full path not required if executable is in same folder as BlankIt).
[Pre-update silly remarks below]

Nice.-mouser (March 22, 2014, 08:00 PM)
--- End quote ---

Thanks, although I expect a much more polished version from you ;)

Will the new window get focus, or might that be a feature to add?
--- End quote ---

Feature? ... to add?

I'll look at bringing the program window to the front before exit, although usually it'd get focus anyway wouldn't it?

That's how Windows usually works, run a program and it forces itself in front of everything else unless told otherwise.

I'll also change it so that if it can't get a handle to the process it'll drop back to timeout instead of throwing up a requester.

Just a note, I'm on a slow convict ship back to the UK in just over a week - I'll be incommunicado for 6 weeks ... yes, I know, much cause for celebration on the forum  :P

cranioscopical:
Just a note, I'm on a slow convict ship back to the UK in just over a week - I'll be incommunicado for 6 weeks
-4wd (March 22, 2014, 08:45 PM)
--- End quote ---
I'm not sure I buy your story — I'm unable to find Communicado on Google maps  >:(
 

4wd:
It's vacant these days: http://goo.gl/maps/G4rth

4wd:
V0.0.1.x is up there.

This is version 0.0.2.x:
Added:    At great expense I had a custom icon designed just for this program ... I'm not sure the graphic artist entered into the spirit of the request  :-\
             (Then again, since it's a CLI only program did I waste my money?)
Added:    Can set optional text to display, limited to 30 characters.
Added:    Can set background colour.
Changed: It now takes one command line argument which is a config file.


Usage: Main difference with this version is it just takes a config file as the argument, eg. BlankIt.exe test.ini

This means, for example, you no longer need a number of long lines in a batch file.  You can have any number of config files and just call the one you want.

If you run the program without any arguments, a example config file called BlankIt.ini will be created - you can then edit it, rename it, or use it as is if you want Notepad.exe to open, (BlankIt.exe BlankIt.ini).

Here's the contents of the example:

--- Code: Text ---[Settings]Program="C:\Windows\System32\notepad.exe"Timeout=10Colour=000000Text=Wait for it!
Program is the program to run, full path required unless it's in the same directory as BlankIt.exe.

Timeout is the maximum time in seconds the blank screen will be displayed if the Process.WaitForIdleInput fails or the program has no GUI.  Maximum value is 180 seconds, if it's more than that or the equivalent of 0 then the default will be 15.

Colour is a RGB hex value, here's a list.  If it's input incorrectly, (ie. not a valid hex value), then it will default to black, (000000).  The text colour will be white for all values 7FFFFF and below, and black for all values 800000 and above.

Text can be left empty, ie. no text will be displayed.  The limit is 30 characters which fits in the width of a 1680 pixel screen, and honestly if you need to display more than 30 characters, chances are there might not be enough time to read them all.


--- Code: AutoIt ---#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_Icon=BlankIt.ico#AutoIt3Wrapper_Outfile=BlankIt.exe#AutoIt3Wrapper_Change2CUI=y#AutoIt3Wrapper_Res_Fileversion=0.0.2.30#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****#cs ----------------------------------------------------------------------------         AutoIt Version: 3.3.10.2        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/        Yashied's WinAPIEx UDF:           http://www.autoitscript.com/forum/topic/98712-winapiex-udf/ #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WinAPIEx.au3>#include <WindowsConstants.au3>#include "[includes]\_ProcessFunctions.au3" Opt('MustDeclareVars', 1) Const $iAccess = 0x00001000 If $CmdLine[0] = 0 Then _Usage() Local $sIniFile = $CmdLine[1]If Not FileExists($sIniFile) Then        _Usage()Else        _GetINI($sIniFile)EndIf #Region ### START Koda GUI section ### Form=GUICreate("Blank", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)#forcedef $iTextCol, $iColour, $sTextGUICtrlSetDefColor($iTextCol)GUISetFont(48, 600)GUICtrlCreateLabel($sText, 10, Int(@DesktopHeight/2 - 34), @DesktopWidth - 20, 68, BitOR($SS_CENTER, $SS_CENTERIMAGE))GUISetBkColor($iColour)#EndRegion ### END Koda GUI section ### _Main()_Exit() Func _GetINI($sFile)        Global $sProgram, $sPath, $iTimeout, $iColour, $sText, $iTextCol        $sProgram = IniRead($sFile, "Settings", "Program", "")        If Not FileExists($sProgram) Then                ConsoleWrite("Error: Executable does not exist!" & @CRLF & "       Check configuration file" & @CRLF)                _Exit()        Else                If StringInStr($sProgram, "\") > 0 Then                        $sPath = StringLeft($sProgram, StringInStr($sProgram, "\", 0, -1))                Else                        $sPath = @ScriptDir & "\"                        $sProgram = $sPath & $sProgram                EndIf        EndIf        $iTimeout = IniRead($sFile, "Settings", "Timeout", "15")        If $iTimeout < 1 Or $iTimeout > 180 Then $iTimeout = 15        $iTimeout *= 1000        $iColour = "0x" & IniRead($sFile, "Settings", "Colour", "000000")        If IsNumber(Dec($iColour)) Then                If Dec($iColour) >= 0 And Dec($iColour) <= 0xFFFFFF Then                        $iColour = "0x" & Hex($iColour, 6)                EndIf        Else                $iColour = "0x000000"        EndIf        If $iColour > 0x7FFFFF Then                $iTextCol = 0x000000        Else                $iTextCol = 0xFFFFFF        EndIf        $sText = StringLeft(IniRead($sFile, "Settings", "Text", ""), 30)EndFunc   ;==>_GetINI Func _Main()        Local $iPID = Run($sProgram, $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(150)                GUISetState(@SW_HIDE)                Local $Data = _WinAPI_EnumProcessWindows($iPID)                If IsArray($Data) Then                        If $Data[0][0] > 0 Then                                _WinAPI_SetFocus($Data[1][0])                        EndIf                EndIf        EndIfEndFunc   ;==>_Main Func _Usage()        Local $aDemo[4][2] = [["Program", '"C:\Windows\System32\notepad.exe"'],["Timeout", 10],["Colour", "000000"],["Text", "Wait for it!"]]        ConsoleWrite("Usage: BlankIt.exe <config file>" & @CRLF & @CRLF)        ConsoleWrite("Where: <config file> = .ini containing command parameters" & @CRLF & @CRLF)        ConsoleWrite("       An example config file called BlankIt.ini has been" & @CRLF)        ConsoleWrite("       generated." & @CRLF)        IniWriteSection("BlankIt.ini", "Settings", $aDemo, 0)        _Exit()EndFunc   ;==>_Usage Func _Exit()        ExitEndFunc   ;==>_Exit
And that's pretty much it until someone says something.

famewolf:
Wow..you folks are amazing.  I apologize for the late (6 months!) reply but for some reason I stopped receiving notices of posts to this thread so I assumed interest had been lost after mouser's comment about it being an interesting task.  I come back to find a full fledged program that has had multiple revisions.

To recap I use a plugin in mediaportal called multishortcut that can run up to 3 apps from a menu item.  I use it to call media center and when media center closes I am back in mediaportal.   I repeat this information because it appears relevant to the scenario listed below.

1) I modified multishortcut to call blankit and pass an argument of "7mc.ini" which was basically the default one except I changed the wording to "Loading MCE...".
2) 7mc.ini was setup to call c:\windows\ehome\ehshell.exe.
3) I ran mediaportal and clicked on the 7mc menu item.
4) A dos shell opened running Blankit.exe  (is there a way to hide the shell?)
5) Loading MCE... displays for 1 second or less. (the ini specifies 10 seconds)
6) Blankit.exe dos shell is visable again and then closes.
7) Screen is "blank" for what feels like about 10 seconds.
8) MCE is running but only displays for less than a second.
9) Loading MCE... displays for less than 1 second.
10) Screen returns to displaying MCE again.
11)  As soon as any key on the keyboard is touched I am bounced back into mediaportal.
12) After exiting mediaportal I found that MCE was still running in memory and had not closed.

I ran it multiple times to ensure I documented each step.  I've reverted back to calling ehshell directly again for the time being.  I think at least part of the issue is mediaportal see's blankit close and thinks the task is complete.  For my scenario it would probably have to continue running until the task it calls dies.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version