#10 messagebox with timeout

Next_Release
open
nobody
5
2012-07-19
2004-03-12
John Nielsen
No

It would be great to have a message box that would
time out after a configurable number of seconds with a
configurable default behavior (either OK or Cancel).

For instance, I'd like to use wizapp in a shutdown script
that prompts the user whether or not to perform a
certain task. If no input is received within a certain
number of seconds, I'd like to go ahead and do the task;
not have the prompt still up there preventing shutdown
until the user comes back.

In case anyone is interested, my current workaround for
this is as follows:

;;;main.bat;;;
rem main batch file
set watitle=title text
set <other stuff="">
...
start /min timeout.bat 25
start /w wizapp.exe MB Q
if errorlevel 1 if not errorlevel 2 goto ok
if errorlevel 0 if not errorlevel 2 goto ok
if errorlevel 3 goto ok
if errorlevel 2 goto end
:ok
<stuff>
:end

;;;timeout.bat;;;
rem timeout batch file
sleep %1
taskkill /F /IM wizapp.exe
exit

This has the desired effect, but it only works in Windows
XP and is a bit of a hack. (the taskkill directive could be
modified to filter based on window title so it wouldn't
clobber other wizapp screens that might follow the first).

Thanks,

JN

Discussion

  • John Nielsen
    John Nielsen
    2004-03-12

    Logged In: YES
    user_id=996686

    I forgot to add a note about the sample batch files above.
    The /f switch is necessary in the taskkill directive because
    without it, the errorlevel from wizapp is 2--the same as if
    cancel were pressed. (This would not be necessary if the
    desired default value were the same as pressing the cancel
    button.)
    JN

     
  • Logged In: NO

    Another temp fix for a timeout message box which works for
    all windows OSs that works with choice.com and kill.exe is:
    <create batch="" file="">
    @echo off
    cls
    set watitle=Timeout Test Program
    set watext=THIS IS AN IMPORTANT QUESTION.~~Did this
    message time out?~~Press OK if you don't want to
    wait.~Press Cancel to close.
    start wizapp mb question
    %winbootdir%\command\choice.com /c:c /t:c,4 /n >nul
    kill /f wizapp.exe
    cls
    set watitle=
    set watext=
    @cls
    <create shortcut="" via="" properties="" and="" run="" minimized="">

    kill.exe is found on ms resource kit CDs and on the net for
    free. Make sure it is mikro$ofts kill.exe and not another kill
    program. You might have to change %winbootdir% to the
    path where choice.com resides. Find the "4" and change it to
    how many seconds you want the delay for (the range is from
    0 -99) whereby 0 is an infinite delay. I hope this helps.
    heck2000@hotmail.com with Wizard's Apprentice somewhere
    in the subject line.

     


Anonymous


Cancel   Add attachments