Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

[VBScript] MsgBox with auto select countdown and Batch Script input.

- - - - -

  • Please log in to reply
18 replies to this topic

#1
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
HI :)

I need help to make a VBScript that i can call with a Batch Script file and schould show then a MsgBox with a Yes/No option and a 30 seconds countdown. If a user has not selected a option and the time is up then the VBScript should automatically select the option Yes and also go to the Batch Script line XY1 and if No is selected then it should go to the Batch Script line XY2.

I google for over 3 hours but i could finde only a simple Yes/No MsgBox VBScript and only one that had also a countdown option but this script was bugy and had also not the Batch Script GoTo line XY option. :(

Hope someone can help me. :hello:

Edited by Outbreaker, 15 October 2009 - 03:31 AM.



How to remove advertisement from MSFN

#2
Scr1ptW1zard

Scr1ptW1zard

    Junior

  • Member
  • Pip
  • 67 posts
  • Joined 05-July 07
Something like this?

Batch file:
 
@echo off

:: batch code

::Prompt here
cscript //nologo question.vbs

if errorlevel 1 goto XY2
goto XY1

:XY1
echo You have chosen yes.
goto :eof

:XY2
echo You have chosen no.
goto :eof


VBScript file:
 
Option Explicit
Dim oShell, retCode
Set oShell = WScript.CreateObject("WScript.Shell")

retCode = oShell.Popup("Place your question here?", 30, "Title", 4 + 32)

Select Case retCode
case 6, -1
WScript.quit(0) 'Yes or time-out was chosen
case 7
WScript.quit(1) 'No was chosen
End Select


This assumes both files are located in the same directory.
Change the text you want displayed to the user.
The vb script uses the quit method of wscript to provide an exit code that the batch
file can use with an errorlevel check to determine what was chosen.
--== Scr1ptW1zard ==--

#3
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
Yes that's it now only a countdown to show that if the user is not selecting a option then the script will auto select the option Yes in X seconds.

#4
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
This will do what you want it to do, but the box flashes as it count down


Option Explicit
 Dim A1, oShell, retCode
  Set oShell = WScript.CreateObject("WScript.Shell")

  A1 = 30

  Do Until A1 = 0
   A1 = A1 - 1
	retCode = oShell.Popup("Place your question here?" & _
						  vbCrlf & "Time Left : " & A1, 1, "Title", 4 + 32)
  Loop 

  Select Case retCode
	case 6, -1
		WScript.quit(0) 'Yes or time-out was chosen

	case 7
		WScript.quit(1) 'No was chosen
   End Select


Another way to do this would be a HTA, this HTA will close in 30 seconds and show the yes diplay text before closing.
There are 2 buttons a Yes and a No button press either one to see how the script works.

Save as DemoMsgBox.hta

<Title>My Demo Message Box</Title>
  <HTA:APPLICATION ID="MainApplication" 
   SCROLL="No"		   
   SCROLLFLAT ="No"  
   SingleInstance="Yes"   
   ShowInTaskbar="Yes"		   
   SysMenu="Yes"		  
   MaximizeButton="No"		
   MinimizeButton="No"	
   Border="Thin" 
   BORDERSTYLE ="complex" 
   INNERBORDER ="No"  
   Caption="Yes"		  
   WindowState="Normal" 
   APPLICATIONNAME="MainApp"
   Icon="%SystemRoot%\explorer.exe">
<STYLE type="text/css">
  BODY
   {
	Font-Size:8.25pt;
	Font-Weight:Bold;
	Font-Family:helvetica,verdana,arial;
	Color:#008040;
	BackGround-Color:Transparent;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E2E2E2',EndColorStr='#6e6e6e);
	Margin-Top:5;
	Margin-Bottom:5;
	Margin-Left:5;
	Margin-Right:5;
	Padding-Top:3;
	Padding-Bottom:3;
	Padding-Left:5;
	Padding-Right:5;
	Text-Align:Left;
	Vertical-Align:Top;
   }
  TD.Type1
   {
   Margin-Left:21;
   Padding-Left:15;
   }
  BUTTON
   { 
	Height:18pt;  
	width:61pt;
	Cursor:Hand;
	Font:8.05pt;
	Font-weight:bold;
	Font-family:helvetica,verdana,arial;
	Color:#404040;
	Text-Align:Center;
	Vertical-Align:Middle;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D');
	Margin:1;
	Padding:2;
	Border-Left: 1px Transparent;  
	Border-Right: 2px Transparent;
	Border-Top: 1px Transparent;   
	Border-Bottom: 2px Transparent;
   }
</STYLE>
 <script Language='VBSCRIPT'>
'-> Resize And Move Window
  Dim Wth :Wth = int(425)
  Dim Hht :Hht = int(175)
  window.ResizeTo Wth, Hht
  MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))
'-> Text Display Varible
  Dim F1 :F1 = "<FONT STYLE='Font:8.25pt;Color:#002060;Font-Weight:Bold;'>"
'-> Count Down Display Varibles
  Dim idTimer
  Dim C1 :C1 = 10
  Dim D1 :D1 = 1
'-> Yes Varibles
  Dim Y_DoIt
'-> OnLoad Action
   Function Window_OnLoad()
	Counter()
	txt1.innerHTML = F1 & "Ask Your Question About What You Want Done</FONT>"
	txt2.innerHTML = F1 & "Here Is Some More Text Space For You If Needed</FONT>"
   End Function
'-> Count Down Function
   Function Counter()
	Do
	 D1 = D1 -1 
	 C1 = C1 -1 
	 document.focus()
	' Makes 1 Threw 9 Look like 01, 02 ETC
	If Len(C1) = 1 Then C1 = "0" & C1
	If Len(C1) = 2 Then C1 = C1
	 txt3.innerHTML = F1 & "Remaining Time Before Auto Select Yes    " & C1 & "</FONT>"
	Loop Until D1 = 0
	 D1 = 1
	If C1 = 0 Then 
	 Y_DoIt = True
	 HtaExit()
	 Exit Function
	End if
	idTimer = window.setTimeout("Counter", 1000, "VBScript")
	If Y_DoIt = True Then
	 Yes_Work()
	End If	 
   End Function
'-> No Button Action
   Function No_Action()
	txt3.innerHTML = Replace(F1,"002060","AD0101") & "No Was Selected Cancel All Operation</FONT>"
	window.clearTimeout(idTimer)
	idTimer = window.setTimeout("MyTimer2", 5000, "VBScript")
   Exit Function
   End Function
'-> Yes Button Action
   Function Yes_Action()
	Y_DoIt = True
   Exit Function
   End Function
'-> Yes Button Worker
   Function Yes_Work()
	 txt3.innerHTML = Replace(F1,"002060","006020") & "Processing Yes Selection</FONT>"
	 'Scripted Action Here
	 window.clearTimeout(idTimer)
	 idTimer = window.setTimeout("MyTimer1", 3000, "VBScript")
   Exit Function
   End Function
'-> Close The HTA Window
   Function HtaExit() 
	window.clearTimeout(idTimer)
	If Y_DoIt = True Then
	 Yes_Work()
	End If  
   End Function
'-> Timer1
   Function MyTimer1()
	txt3.innerHTML = ""
	window.close()
	window.clearTimeout(idTimer)
   Exit Function
   End Function
'-> Timer2
   Function MyTimer2()
	txt3.innerHTML = ""
	window.close()
	window.clearTimeout(idTimer)
   Exit Function
   End Function
 </SCRIPT>
 <BODY Scroll='No'>
<!-- txt1 Display -->
 <Table><TD Class='Type1'><Span ID='txt1'></Span></TD></Table>
<!-- txt2 Display -->
 <Table><TD Class='Type1'><Span ID='txt2'></Span></TD></Table>
<!-- txt3 Display -->
 <Table><TD Class='Type1'><Span ID='txt3'></Span></TD></Table>
<!-- Button Display -->
 <Table Style='Margin-Top:7pt;' Align='Center'>
<!-- Button 01 -->
  <TD><BUTTON ID='Bttn_N' OnClick='No_Action()'>No</BUTTON></TD>
<!-- Button 02 -->
  <TD><BUTTON ID='Bttn_Y' OnClick='Yes_Action()'>Yes</BUTTON></TD>
 </Table>
 </BODY>




GunSmokingMan



#5
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
Nice :w00t: MsgBox popup never heard about this HTA before.
But would this also work with the Batch file like with the VBScript ?
Like if the DemoMsgBox.hta is started by the Batch file and the option Yes is selected then got to Batch Script line XY1 and if the option No is selected then go to Batch Script line XY2.

If this would works this would be the best Yes/No prompt Script for a Batch file. :)

Edited by Outbreaker, 15 October 2009 - 12:59 PM.


#6
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
You would not need to have any batch files around, you could run the cmd directly from the HTA either yes or no button.
Could you post the cmds you need to run for yes and no button reply, I will add them to the HTA for you.


GunSmokingMan



#7
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
Oh to put the batch script in the HTA file would be not so good it's a big Batch file and i have also separat all Script languag for each other like that it is not so confusion because the whole Scripts config files that i use to configure Windows are like 200KB together.
If this is not working like in the VBScript then i could also make 2 more Batch files so if Yes is then selected it will Start the Batch file XY1 and if No it will Start the Batch file XY2.

Edited by Outbreaker, 15 October 2009 - 09:49 PM.


#8
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,540 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

I'd suggest you take a look at a GUI scripting tool such as AutoIt for this task.

In the meantime I suppose I could take a shot at creating a YES | NO box with 30 second countdown specifically for this task. You'd probably end up running it as an executable from the batch and have it return the result back to the batch. It'd be no real use for anything else hence my reason for not doing so unless it's required.

Also if it is required, then you'll need to let me know exactly what data you'd want it to return.
i.e. I was thinking 1 for YES, 2 for NO; meaning that your batch could probably use the return data as:
GOTO XY<RETURNED DATA>


#9
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
I like the idee to use Scripts that i can open with the text edtor and edit it without a program if the next step will not work then AutoIt would be the only way.

So it looks like the HTA could not be used like the VBScript to output a command to the Batch file.
But what if i would select Yes and the HTA Script would make a Batch file in the Temp folder with the text "Yes" in it and then the main Batch file would then call the Batch file in the Temp folder and look if "Yes" or "No" is written in it and if like "Yes" is written in then the main Batch file gose to the line XY1 and if "No" is written it will go to the Batch line XY2.

Im sure it would work but i don't no how to write the code for that :}

Edited by Outbreaker, 16 October 2009 - 12:26 PM.


#10
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Here is a updated HTA, it produces a MyReturn.cmd in the users temp folder

Cmd I used to see read the varibles

@Echo Off
CLS
Mode 69,9
Color F9
Title Test Return

Set Cmd1="%Temp%\MyReturn.cmd"


If Exist %Cmd1% GoTO Work1
If Not Exist %Cmd1% GoTO Ops1


:Work1
call %Cmd1%
CLS
Echo.
Echo  %Reply%
Del %Cmd1%
pause
Exit


:Ops1
Color F5
CLS
Echo.
Echo  Missing %Cmd1%
Echo  Contact The System Admin For More Information!
pause
Exit



Updated HTA code

<Title>My Demo Message Box</Title>
  <HTA:APPLICATION ID="MyMessageBox" 
   SCROLL="No"		   
   SCROLLFLAT ="No"  
   SingleInstance="Yes"   
   ShowInTaskbar="Yes"		   
   SysMenu="Yes"		  
   MaximizeButton="No"		
   MinimizeButton="No"	
   Border="Thin" 
   BORDERSTYLE ="complex" 
   INNERBORDER ="No"  
   Caption="Yes"		  
   WindowState="Normal" 
   APPLICATIONNAME="MainApp"
   Icon="%SystemRoot%\explorer.exe">
<STYLE type="text/css">
  BODY
   {
	Font-Size:8.25pt;
	Font-Weight:Bold;
	Font-Family:helvetica,verdana,arial;
	Color:#008040;
	BackGround-Color:Transparent;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E2E2E2',EndColorStr='#6e6e6e);
	Margin-Top:5;
	Margin-Bottom:5;
	Margin-Left:5;
	Margin-Right:5;
	Padding-Top:3;
	Padding-Bottom:3;
	Padding-Left:5;
	Padding-Right:5;
	Text-Align:Left;
	Vertical-Align:Top;
   }
  TD.Type1
   {
   Margin-Left:21;
   Padding-Left:15;
   }
  BUTTON
   { 
	Height:18pt;  
	width:61pt;
	Cursor:Hand;
	Font:8.05pt;
	Font-weight:bold;
	Font-family:helvetica,verdana,arial;
	Color:#404040;
	Text-Align:Center;
	Vertical-Align:Middle;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D');
	Margin:1;
	Padding:2;
	Border-Left: 1px Transparent;  
	Border-Right: 2px Transparent;
	Border-Top: 1px Transparent;   
	Border-Bottom: 2px Transparent;
   }
</STYLE>
 <script Language='VBSCRIPT'>
'-> Scripting Objects 
  Dim Act :Set Act = CreateObject("Wscript.Shell")
  Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
  Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%Temp%") & "\MyReturn.cmd"
'-> Varibles
  Dim Ts
'-> Resize And Move Window
  Dim Wth :Wth = int(425)
  Dim Hht :Hht = int(175)
  window.ResizeTo Wth, Hht
  MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))
'-> Text Display Varible
  Dim F1 :F1 = "<FONT STYLE='Font:8.25pt;Color:#002060;Font-Weight:Bold;'>"
'-> Count Down Display Varibles
  Dim idTimer
  Dim C1 :C1 = 30
  Dim D1 :D1 = 1
'-> Yes Varibles
  Dim Y_DoIt
'-> OnLoad Action
   Function Window_OnLoad()
	Counter()
	txt1.innerHTML = F1 & "Ask Your Question About What You Want Done</FONT>"
	txt2.innerHTML = F1 & "Here Is Some More Text Space For You If Needed</FONT>"
   End Function
'-> Count Down Function
   Function Counter()
	Do
	 D1 = D1 -1 
	 C1 = C1 -1 
	 document.focus()
	' Makes 1 Threw 9 Look like 01, 02 ETC
	If Len(C1) = 1 Then C1 = "0" & C1
	If Len(C1) = 2 Then C1 = C1
	 txt3.innerHTML = F1 & "Remaining Time Before Auto Select Yes    " & C1 & "</FONT>"
	Loop Until D1 = 0
	 D1 = 1
	If C1 = 0 Then 
	 Y_DoIt = True
	 HtaExit()
	 Exit Function
	End if
	idTimer = window.setTimeout("Counter", 1000, "VBScript")
	If Y_DoIt = True Then
	 Yes_Work()
	End If	 
   End Function
'-> No Button Action
   Function No_Action()
	Bttn_Y.disabled = True
	txt3.innerHTML = Replace(F1,"002060","AD0101") & "No Was Selected Cancel All Operation</FONT>"
	 '-> Create The Temp Cmd File For Yes
	  Set Ts = Fso.CreateTextFile(Cmd)
	   Ts.WriteLine "@Echo && CLS && MODE 55,5 && COLOR F9"
	   Ts.WriteLine "Set Reply=No"
	   Ts.Close
	window.clearTimeout(idTimer)
	idTimer = window.setTimeout("MyTimer2", 5000, "VBScript")
   Exit Function
   End Function
'-> Yes Button Action
   Function Yes_Action()
	Y_DoIt = True
   Exit Function
   End Function
'-> Yes Button Worker
   Function Yes_Work()
	 Bttn_N.disabled = True
	 txt3.innerHTML = Replace(F1,"002060","006020") & "Processing Yes Selection</FONT>"
	 '-> Create The Temp Cmd File For Yes
	  Set Ts = Fso.CreateTextFile(Cmd)
	   Ts.WriteLine "@Echo && CLS && MODE 55,5 && COLOR F9"
	   Ts.WriteLine "Set Reply=Yes"
	   Ts.Close
	 window.clearTimeout(idTimer)
	 idTimer = window.setTimeout("MyTimer1", 3000, "VBScript")
   Exit Function
   End Function
'-> Close The HTA Window
   Function HtaExit() 
	window.clearTimeout(idTimer)
	If Y_DoIt = True Then
	 Yes_Work()
	End If  
   End Function
'-> Timer1
   Function MyTimer1()
	txt3.innerHTML = ""
	window.close()
	window.clearTimeout(idTimer)
   Exit Function
   End Function
'-> Timer2
   Function MyTimer2()
	txt3.innerHTML = ""
	window.close()
	window.clearTimeout(idTimer)
   Exit Function
   End Function
 </SCRIPT>
 <BODY Scroll='No'>
<!-- txt1 Display -->
 <Table><TD Class='Type1'><Span ID='txt1'></Span></TD></Table>
<!-- txt2 Display -->
 <Table><TD Class='Type1'><Span ID='txt2'></Span></TD></Table>
<!-- txt3 Display -->
 <Table><TD Class='Type1'><Span ID='txt3'></Span></TD></Table>
<!-- Button Display -->
 <Table Style='Margin-Top:7pt;' Align='Center'>
<!-- Button 01 -->
  <TD><BUTTON ID='Bttn_N' OnClick='No_Action()'>No</BUTTON></TD>
<!-- Button 02 -->
  <TD><BUTTON ID='Bttn_Y' OnClick='Yes_Action()'>Yes</BUTTON></TD>
 </Table>
 </BODY>




GunSmokingMan



#11
Outbreaker

Outbreaker

    Member

  • Member
  • PipPip
  • 298 posts
  • Joined 08-August 07
  • OS:Windows 7 x86
  • Country: Country Flag
Perfect this works excellent THX. :w00t:

You saver me a lot of needed sleep time. :boring:

Edited by Outbreaker, 16 October 2009 - 03:26 PM.


#12
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Your welcome, glad I could help.


GunSmokingMan



#13
Rigatoni

Rigatoni
  • Member
  • 1 posts
  • Joined 31-August 11
  • OS:Windows 7 x64
  • Country: Country Flag
I am trying to do a simular job and i like what you have put together. I have one request if you are able to help it would be appreciated. Thanks
Is it possible for the cmd to read the results of the hta and if reply = yes lauch a specific .cmd (lets say c:\test.cmd) and if reply = no do nothing.

#14
DefaultScript

DefaultScript
  • Member
  • 2 posts
  • Joined 31-December 11
  • OS:Vista Ultimate x86
  • Country: Country Flag
Gunsmokingman, Thank You immensley for this script as it has done almost everything i needed....
However (of course lol) i am having trouble with the location of the output file... i need it to be generated within the script folder that is calling it... i have tried changing line 65 location from %temp% to

Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%cd%") & "\BannerResult.cmd"
it errors and states "PATH NOT FOUND"
however when i use ...
Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%userprofile%\desktop") & "\BannerResult.cmd"
it runs fine however it puts the file to the users desktop then i have another script that deletes the generated file once it reads the reply answer. what am i missing with getting it to generate within the called script folder.

Any takers on this question, i would be forever greatful. been smacking my head on the table for days trying to figure it out, i must have reloded this script about 500 times.... :realmad: lol Great Script though overall :thumbup

thanks in advance for anyone that is looking it over. attached below is the window script modified from what Gunsmoking man originally wrote.

Also i changed it so the script closes automatically at the timer "0" generating no file. Only Generates output file if yes button is clicked.

This is the (Edited for Public) Check Banner Result Script (Batch File)
@Echo Off 
CLS 
Mode 69,9 
Color F9 
Title Check Banner Result

Set Cmd1="%userprofile%\desktop\BannerResult.cmd" 
 
 
If Exist %Cmd1% GoTO BannerAccepted 
If Not Exist %Cmd1% GoTO BannerDenied 
 
 
:BannerAccepted
call %Cmd1% 
CLS 
Echo. 
Echo  PROCESSING
Echo Did User Accept Banner:  %reply%
pause
Del %Cmd1% 
if not exist %cmd1% goto end
if exist %cmd1% echo Cannot Delete Banner Result File from Desktop...
pause 
Exit 
 
 
:BannerDenied
Color F5 
CLS 
Echo. 
Echo  Timed Out or User Selected NO. Operation Cancelled
Echo. 
Echo. 
Echo. 
pause
goto end

:end
exit



This is the Banner Script (HTA File)
<Title>DOD BANNER</Title> 
  <HTA:APPLICATION
  APPLICATIONNAME="MainApp"
  ID="BannerBox"
  BORDER="thin"
  BORDERSTYLE="complex"
  INNERBORDER="no"
  MAXIMIZEBUTTON="no"
  MINIMIZEBUTTON="no"
  ICON="%SystemRoot%\explorer.exe"
  SCROLL="no"
  SINGLEINSTANCE="yes"
  SHOWINTASKBAR="no"
  CONTEXTMENU="no"
  SELECTION="no"/> 
<STYLE type="text/css"> 
  BODY 
   { 
        Font-Size:8.25pt; 
        Font-Weight:Bold; 
        Font-Family:helvetica,verdana,arial; 
        Color:#008040; 
        BackGround-Color:Transparent; 
        filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#6e6e6e',EndColorStr='#011111); 
        Margin-Top:5; 
        Margin-Bottom:5; 
        Margin-Left:5; 
        Margin-Right:5; 
        Padding-Top:3; 
        Padding-Bottom:3; 
        Padding-Left:5; 
        Padding-Right:5; 
        Text-Align:Center; 
        Vertical-Align:Top; 
   } 
  TD.Type1 
   { 
   Margin-Left:21; 
   Padding-Left:15; 
   } 
  BUTTON 
   {  
        Height:18pt;   
        width:61pt; 
        Cursor:Hand; 
        Font:8.05pt; 
        Font-weight:bold; 
        Font-family:helvetica,verdana,arial; 
        Color:#404040; 
        Text-Align:Center; 
        Vertical-Align:Middle; 
        filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D'); 
        Margin:1; 
        Padding:2; 
        Border-Left: 1px Transparent;   
        Border-Right: 2px Transparent; 
        Border-Top: 1px Transparent;    
        Border-Bottom: 2px Transparent; 
   } 
</STYLE> 
 <script Language='VBSCRIPT'> 
'-> Scripting Objects  
  Dim Act :Set Act = CreateObject("Wscript.Shell") 
  Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") 
  Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%userprofile%\desktop") & "\BannerResult.cmd" 
'-> Varibles 
  Dim Ts 
'-> Resize And Move Window 
  Dim Wth :Wth = int(625) 
  Dim Hht :Hht = int(675) 
  window.ResizeTo Wth, Hht 
  MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2)) 
'-> Text Display Varible 
  Dim F1 :F1 = "<FONT STYLE='Font:8.25pt;Color:#099099;Font-Weight:Bold;'>" 
  Dim F2 :F2 = "<FONT STYLE='Font:10.25pt;Color:#FFFFF9;Font-Weight:Bold;'>" 
  Dim F3 :F3 = "<FONT STYLE='Font:14.25pt;Color:#FFFF00;Font-Weight:Bold;'>" 
'-> Count Down Display Varibles 
  Dim idTimer 
  Dim C1 :C1 = 62 
  Dim D1 :D1 = 1 
'-> Yes Varibles 
  Dim Y_DoIt 
'-> OnLoad Action 
   Function Window_OnLoad() 
        Counter() 
        txt1.innerHTML = F3 & "DOD NOTICE AND CONSENT BANNER</FONT>" 
        txt2.innerHTML = F2 & "You are accessing a U.S. Government (USG) Information System (IS)</FONT>"
        txt3.innerHTML = F2 & "that is provided for USG-authorized use only. </FONT>"
        txt4.innerHTML = F1 & "</FONT>"
        txt5.innerHTML = F1 & "By using this IS(which includes any device attached to this IS),</FONT>"
        txt6.innerHTML = F1 & "you consent to the following conditions: </FONT>"
        txt7.innerHTML = F1 & "</FONT>"
        txt8.innerHTML = F1 & "-The USG routinely intercepts and monitors communications on this IS</FONT>"
        txt9.innerHTML = F1 & " for purposes including, but not limited to, penetration testing, COMSEC</FONT>"
        txt10.innerHTML = F1 & " monitoring, network operations and defense, personnel misconduct (PM),</FONT>"
        txt11.innerHTML = F1 & " law enforcement (LE), and counterintelligence investigations (CI).  </FONT>"
        txt12.innerHTML = F1 & "-At any time, the USG may inspect and seize data stored on this IS.  </FONT>"
        txt13.innerHTML = F1 & "-Communications using, or data stored on, this IS are not private, are</FONT>"
        txt14.innerHTML = F1 & " subject to routine monitoring, interception and search, and may be disclosed</FONT>"
        txt15.innerHTML = F1 & " or used for any USG-authorized purpose.  </FONT>"
        txt16.innerHTML = F1 & "-This IS includes security measures (e.g., authentication and access controls)</FONT>"
        txt17.innerHTML = F1 & " to protect USG interests--not for your personal benefit or privacy.</FONT>"
        txt18.innerHTML = F1 & "-Notwithstanding the above, using this IS does not constitute consent to PM, LE,</FONT>"
        txt19.innerHTML = F1 & " or CI investigative searching or monitoring of the content of privileged</FONT>"
        txt20.innerHTML = F1 & " communications, or work product, related to personal representation or services</FONT>"
        txt21.innerHTML = F1 & " by attorneys, psychotherapists, or clergy, and their assistants. Such communication</FONT>"
        txt22.innerHTML = F1 & " and work product are private and confidential.  See User Agreement for details.</FONT>"
        txt23.innerHTML = F1 & "</FONT>"
        txt24.innerHTML = F2 & "I have read and consent to the terms of the IS User Agreement</FONT>"
        txt25.innerHTML = F1 & "</FONT>"
   End Function 
'-> Count Down Function 
   Function Counter() 
        Do 
         D1 = D1 -1  
         C1 = C1 -1  
         document.focus() 
        ' Makes 1 Threw 9 Look like 01, 02 ETC 
        If Len(C1) = 1 Then C1 = "0" & C1 
        If Len(C1) = 2 Then C1 = C1 
         txt25.innerHTML = F3 & "Remaining Time Before Auto Select NO    " & C1 & "</FONT>" 
        Loop Until D1 = 0 
         D1 = 1 
        If C1 = 0 Then  
         Y_DoIt = True 
         No_Action() 
         Exit Function 
        End if 
        idTimer = window.setTimeout("Counter", 1000, "VBScript") 
        If Y_DoIt = True Then 
         No_Action() 
        End If    
   End Function 
'-> No Button Action 
   Function No_Action() 
        Bttn_Y.disabled = True 
        txt25.innerHTML = Replace(F3,"002060","AD0101") & "No Was Selected Cancel Operation</FONT>" 
        window.clearTimeout(idTimer) 
        idTimer = window.setTimeout("MyTimer2", 1000, "VBScript") 
   Exit Function 
   End Function 
'-> Yes Button Action 
   Function Yes_Action() 
        Y_DoIt = True 
        HtaExit()
   Exit Function 
   End Function 
'-> Yes Button Worker 
   Function Yes_Work() 
         Bttn_N.disabled = True 
         txt25.innerHTML = Replace(F3,"002060","006020") & "Processing Yes Selection</FONT>" 
         '-> Create The Temp Cmd File For Yes 
          Set Ts = Fso.CreateTextFile(Cmd) 
           Ts.WriteLine "@Echo && CLS && MODE 55,5 && COLOR F9" 
           Ts.WriteLine "Set Reply=Yes" 
           Ts.Close 
         window.clearTimeout(idTimer) 
         idTimer = window.setTimeout("MyTimer1", 1000, "VBScript") 
   Exit Function 
   End Function 
'-> Close The HTA Window 
   Function HtaExit()  
        window.clearTimeout(idTimer) 
        If Y_DoIt = True Then 
         Yes_Work() 
        End If   
   End Function 
'-> Timer1 
   Function MyTimer1() 
        txt25.innerHTML = "" 
        window.close() 
        window.clearTimeout(idTimer) 
   Exit Function 
   End Function 
'-> Timer2 
   Function MyTimer2() 
        txt25.innerHTML = "" 
        window.close() 
        window.clearTimeout(idTimer) 
   Exit Function 
   End Function 
 </SCRIPT>
 <BODY Scroll='No'> 
<!-- txt1 Display --> 
 <Table><TD Class='Type1'><Span ID='txt1'></Span></TD></Table> 
<!-- txt2 Display --> 
 <Table><TD Class='Type1'><Span ID='txt2'></Span></TD></Table> 
<!-- txt3 Display --> 
 <Table><TD Class='Type1'><Span ID='txt3'></Span></TD></Table> 
<!-- txt4 Display --> 
 <Table><TD Class='Type1'><Span ID='txt4'></Span></TD></Table> 
<!-- txt5 Display --> 
 <Table><TD Class='Type1'><Span ID='txt5'></Span></TD></Table> 
<!-- txt6 Display --> 
 <Table><TD Class='Type1'><Span ID='txt6'></Span></TD></Table> 
<!-- txt7 Display --> 
 <Table><TD Class='Type1'><Span ID='txt7'></Span></TD></Table> 
<!-- txt8 Display --> 
 <Table><TD Class='Type1'><Span ID='txt8'></Span></TD></Table> 
<!-- txt9 Display --> 
 <Table><TD Class='Type1'><Span ID='txt9'></Span></TD></Table> 
<!-- txt10 Display --> 
 <Table><TD Class='Type1'><Span ID='txt10'></Span></TD></Table> 
<!-- txt11 Display --> 
 <Table><TD Class='Type1'><Span ID='txt11'></Span></TD></Table> 
<!-- txt12 Display --> 
 <Table><TD Class='Type1'><Span ID='txt12'></Span></TD></Table> 
<!-- txt13 Display --> 
 <Table><TD Class='Type1'><Span ID='txt13'></Span></TD></Table> 
<!-- txt14 Display --> 
 <Table><TD Class='Type1'><Span ID='txt14'></Span></TD></Table> 
<!-- txt15 Display --> 
 <Table><TD Class='Type1'><Span ID='txt15'></Span></TD></Table> 
<!-- txt16 Display --> 
 <Table><TD Class='Type1'><Span ID='txt16'></Span></TD></Table> 
<!-- txt17 Display --> 
 <Table><TD Class='Type1'><Span ID='txt17'></Span></TD></Table> 
<!-- txt18 Display --> 
 <Table><TD Class='Type1'><Span ID='txt18'></Span></TD></Table> 
<!-- txt19 Display --> 
 <Table><TD Class='Type1'><Span ID='txt19'></Span></TD></Table> 
<!-- txt20 Display --> 
 <Table><TD Class='Type1'><Span ID='txt20'></Span></TD></Table> 
<!-- txt21 Display --> 
 <Table><TD Class='Type1'><Span ID='txt21'></Span></TD></Table> 
<!-- txt22 Display --> 
 <Table><TD Class='Type1'><Span ID='txt22'></Span></TD></Table> 
<!-- txt23 Display --> 
 <Table><TD Class='Type1'><Span ID='txt23'></Span></TD></Table> 
<!-- txt24 Display --> 
 <Table><TD Class='Type1'><Span ID='txt24'></Span></TD></Table> 
<!-- txt25 Display --> 
 <Table><TD Class='Type1'><Span ID='txt25'></Span></TD></Table> 

<!-- Button Display --> 
 <Table Style='Margin-Top:7pt;' Align='Center'> 
<!-- Button 01 --> 
  <TD><BUTTON ID='Bttn_N' OnClick='No_Action()'>No</BUTTON></TD> 
<!-- Button 02 --> 
  <TD><BUTTON ID='Bttn_Y' OnClick='Yes_Action()'>Yes</BUTTON></TD> 
 </Table> 
 </BODY>

Edited by DefaultScript, 31 December 2011 - 09:26 PM.


#15
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Change This
Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%userprofile%\desktop") & "\BannerResult.cmd"

To this to get the output in the Current Directory
Dim Cmd :Cmd = Act.CurrentDirectory & "\BannerResult.cmd"



GunSmokingMan



#16
DefaultScript

DefaultScript
  • Member
  • 2 posts
  • Joined 31-December 11
  • OS:Vista Ultimate x86
  • Country: Country Flag

Change This

Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%userprofile%\desktop") & "\BannerResult.cmd"

To this to get the output in the Current Directory
Dim Cmd :Cmd = Act.CurrentDirectory & "\BannerResult.cmd"

Thanks very much.... after looking at what you had above i figured it out lol. i did try the Act.CurrentDirectory however it wasn't generating the output to the folder. :sneaky: it was actually placing the output in the next higher folder and renaming the file appending the lower directory name as a prefix on the filename, hence not being able to find it caus it no longer carried the requested filename. :sneaky:

this was all because of the darn \ before the filename. in my code i had not put the \ before the filename and same with using your original script , i needed to remove the env variable. :ph34r:

now....i have read more on this act.currentdirectory and feel a bit more "trained" lol, thanks again oh and also my original script was fine as well once i removed the \ and just placed the filename itself in the line as such


use this as the output into same directory as calling scripts... Just Remove the ("%userprofile%\desktop") & from the line....
Dim Cmd :Cmd = Act.ExpandEnvironmentStrings ("BannerResult.cmd")

that created the file in the same folder as the called script.

#17
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,798 posts
  • Joined 12-May 07
  • OS:none specified
  • Country: Country Flag
Sorry for the noob questions, but...

I've never played with HTA files before so I'm confused how they are used/called. I put DefaultScript's Check Banner Result Script (Batch File) [named CheckBannerResult.cmd] and the Banner Script (HTA File) [named BannerScript.hta], with the fix from the last post, in their own folder with nothing else in there. Now what? being a noob I have no idea how to invoke the hta and get it to "work". I like this concept, if I understand it, but I'm afraid I'm very confused. Maybe someone can point me to a "HTA files for Dummies" tutorial?

Cheers and Regards

Posted Image


#18
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • Joined 01-January 08
  • OS:XP Pro x86
  • Country: Country Flag
A happy 2012 new year to all coders here! :)

Thanks to gunsmokingman's HTA script which inspire me to try to code in autoit.
I was very interested to see what code would be like if using autoit and also to experience
'GUI scripting' as Yzöwl mentioned earlier as I am not familiar with it. So I try to script it using autoit.
Took me days to come up the script... and 2 parts of the script were extracted from the autoit forum.
They are
1) Create only "Close" buton on the main GUI Source
2) Timer countdown logic Source
With that, autoit code which mimic what HTA script does
Code with autoit v3.3.6.1. Also works with v3.3.8.0
Note that the timer will beep on last 10 secs countdown
Timer font also changed during this period.

opt("TrayIconDebug",1)
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1);1=enable, Enable/disable OnEvent functions notifications.
Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell
#NoTrayIcon ; No system tray icon while running

#include <WindowsConstants.au3> ; $GUI_SS_DEFAULT_GUI
#include <GUIConstantsEx.au3> 	; GUISetBkColor, $GUI_EVENT_CLOSE
#include <ButtonConstants.au3>	; $BS_DEFPUSHBUTTON
#include <StaticConstants.au3>	; $SS_CENTER
#Include <Misc.au3>; _Singleton
_Singleton(@ScriptName, 0); Single instant
Global $TimeLabel, $sMsg, $hMainwindow, $NoLaunch,$YesSelect,$NoSelect,$YESB
Global $s2ndlabel, $s3rdlabel,$s4thlabel, $s5thlabel, $s6thlabel, $s7thlabel, $s8thlabel, $i6thid
Global $TimeTicks, $begin, $_CompteArebour = 60000,  $_Minutes, $_Seconds
Const $cGUIWid=620, $cGUIHt=650, $cHalfGUIWid=$cGUIWid/2

$hMainwindow= GUICreate("DOD BANNER", $cGUIWid, $cGUIHt, -1,-1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
GUISetIcon (@WindowsDir&"\explorer.exe",0)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetBkColor (0x3E4545)	; dark grey
GUICtrlCreateLabel ( "DOD NOTICE AND CONSENT BANNER", 40,10,550,20, $SS_CENTER)
GUICtrlSetFont (-1, 16, 440, 16, "helvetica" )
GUICtrlSetColor(-1, 0xFFFF00); Yellow font

$s2ndlabel="You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only."
GUICtrlCreateLabel ($s2ndlabel, 40,35,570,45, $SS_CENTER)
GUICtrlSetFont (-1, 14, 380, 16, "helvetica" )
GUICtrlSetColor(-1, 0xFFFFF9); White font

$s3rdlabel="By using this IS(which includes any device attached to this IS), you consent to the following conditions:"
GUICtrlCreateLabel ($s3rdlabel, 40, 90, 550, 50, $SS_CENTER)
GUICtrlSetFont (-1, 11, 380, 16, "helvetica" )
GUICtrlSetColor(-1, 0x099099); Dark Green font

$s4thlabel="-The USG routinely intercepts and monitors communications on this IS "& _
			 "for purposes including, but not limited to, penetration testing, COMSEC"& _
			 " monitoring, network operations and defense, personnel misconduct (PM),"& _
			 " law enforcement (LE), and counterintelligence investigations (CI)."&@Lf&@Lf& _
			 "-At any time, the USG may inspect and seize data stored on this IS."&@Lf&@Lf& _
			 "-Communications using, or data stored on, this IS are not private, are"& _
			 " subject to routine monitoring, interception and search, and may be disclosed"& _
			 " or used for any USG-authorized purpose."&@Lf&@Lf& _
			 "-This IS includes security measures (e.g., authentication and access controls)"&@Lf&@Lf& _
			 "to protect USG interests--not for your personal benefit or privacy."& _
			 "-Notwithstanding the above, using this IS does not constitute consent to PM, LE,"&@Lf&@Lf& _
			 "or CI investigative searching or monitoring of the content of privileged"& _
			 "communications, or work product, related to personal representation or services"& _
			 "by attorneys, psychotherapists, or clergy, and their assistants. Such communication"& _
			 "and work product are private and confidential.  See User Agreement for details."
GUICtrlCreateLabel ($s4thlabel, 40, 140, 550,250, $SS_CENTER)
GUICtrlSetFont (-1, 11, 380, 1, "helvetica" )
GUICtrlSetColor(-1, 0x099099); Dark Green font

$s5thlabel="I have read and consent to the terms of the IS User Agreement"
GUICtrlCreateLabel ($s5thlabel, 40, 400, 550,25, $SS_CENTER, $WS_EX_OVERLAPPEDWINDOW)
GUICtrlSetFont (-1, 12, 380, 16, "helvetica" )
GUICtrlSetColor(-1, 0xFFFFF9); White font

$s6thlabel="Remaining Time Before Auto Select NO "
$i6thid=GUICtrlCreateLabel ($s6thlabel, 100, 470, 550,25)
GUICtrlSetFont (-1, 15, 380, 16, "helvetica" )
GUICtrlSetColor(-1, 0xFFFF00); Yellow font

$TimeLabel = GUICtrlCreateLabel ( "", 460, 468, 50, 20 )
GUICtrlSetFont (-1, 15, 380, 16, "helvetica" )
GUICtrlSetColor(-1, 0xFFFF00)

$NoLaunch = GUICtrlCreateButton("NO", 250, 525, 60,-1,$BS_DEFPUSHBUTTON)
$YesSelect= GUICtrlCreateButton("YES", 330, 525, 60)

GUICtrlSetOnEvent($NoLaunch, "NoSelect")
GUICtrlSetOnEvent($YesSelect, "YESFunc")
GUISetState(@SW_SHOW)

$TimeTicks= TimerInit()

While 1
	$sMsg = GUIGetMsg()
	_Check ( )
	Sleep(100) ; Just idle around
WEnd

Func NoSelect()
	GUICtrlDelete ( $i6thid )
	GUICtrlDelete ( $TimeLabel)
	$s7thlabel="No Was Selected Cancel Operation"
	GUICtrlCreateLabel ($s7thlabel, 40, 470, 550,25,$SS_CENTER)
	GUICtrlSetFont (-1, 15, 380, 16, "helvetica" )
	GUICtrlSetColor(-1, 0xFFFF00); Yellow font
	sleep (1000)
	Exit
EndFunc; EndFunc of NoSelect

Func YESFunc()
	GUICtrlDelete ( $i6thid )
	GUICtrlDelete ( $TimeLabel)
	GUICtrlSetState ( $NoLaunch,$GUI_DISABLE )
	$s8thlabel="Processing Yes Selection"
	GUICtrlCreateLabel ($s8thlabel, 40, 470, 550,25,$SS_CENTER)
	GUICtrlSetFont (-1, 15, 380, 16, "helvetica" )
	GUICtrlSetColor(-1, 0xFFFF00); Yellow font
	if FileExists (@scriptdir&"\BannerResult.cmd") then FileDelete (@scriptdir&"\BannerResult.cmd")
	;Create The Temp Cmd File For Yes
	FileWrite (@scriptdir&"\BannerResult.cmd","@Echo && CLS && MODE 55,5 && COLOR F9"&@crlf&"Set Reply=Yes"&@crlf)
	Runwait (@scriptdir&"\BannerResult.cmd")
	sleep (1000)
	Exit
EndFunc

Func _Check ( )
    $_CompteArebour -= TimerDiff ( $TimeTicks)
    $TimeTicks = TimerInit ( )
    Local $_MinCalc = Int ( $_CompteArebour / ( 60 * 1000 ) ), $_SecCalc = $_CompteArebour - ( $_MinCalc * 60 * 1000 )
    $_SecCalc = Int ( $_SecCalc / 1000 )
    If $_MinCalc <= 0 And $_SecCalc <= 0 Then
        Exit
    Else
        If $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then
            $_Minutes = $_MinCalc
            $_Seconds = $_SecCalc
            GUICtrlSetData ( $TimeLabel, StringFormat ( "%02u" & ":" & "%02u", $_Minutes, $_Seconds ) )
            If $_Minutes = 0 And $_Seconds <= 10 Then
                Beep ( 1200, 100 )
                GUICtrlSetColor (  $TimeLabel , 0xE70656); pink-red color
            EndIf
        EndIf
    EndIf
EndFunc ;==> _Check ( )

Func CLOSEClicked()
	Exit
EndFunc
I notice while HTA was running and clicking Start button, the start menu will disappear.
This does not happen using autoit.

Simple comparsion :
HTA in post 14 : 244 lines - 14 comment line =230 lines
Autoit: 134 lines - 1 comment line = 133 lines

Thanks again for the inspiration.

Screenshot: countdown >10 sec
Posted Image

Last 10 sec ...
Posted Image

#19
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Here is a updated version at with 137 lines of code and can can be edit by something as simple as notepad.
<Title>My Demo Message Box</Title>
  <HTA:APPLICATION ID="MyMessageBox" 
   SCROLL="No"		   
   SCROLLFLAT ="No"  
   SingleInstance="Yes"   
   ShowInTaskbar="Yes"		   
   SysMenu="Yes"		  
   MaximizeButton="No"		
   MinimizeButton="No"	
   Border="Thin" 
   BORDERSTYLE ="complex" 
   INNERBORDER ="No"  
   Caption="Yes"		  
   WindowState="Normal" 
   APPLICATIONNAME="MainApp"
   Icon="%SystemRoot%\explorer.exe">
<STYLE type="text/css">
 BODY{
	Font-Size:8.25pt;
	Font-Weight:Bold;
	Font-Family:helvetica,verdana,arial;
	Color:#008040;
	BackGround-Color:Transparent;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E2E2E2',EndColorStr='#6e6e6e);
	Margin-Top:5;
	Margin-Bottom:5;
	Margin-Left:5;
	Margin-Right:5;
	Padding-Top:3;
	Padding-Bottom:3;
	Padding-Left:5;
	Padding-Right:5;
	Text-Align:Left;
	Vertical-Align:Top;
 }
 TD.Type1{
  Margin-Left:21;
  Padding-Left:15;
 }
 BUTTON{ 
	Height:18pt;  
	width:61pt;
	Cursor:Hand;
	Font:8.05pt;
	Font-weight:bold;
	Font-family:helvetica,verdana,arial;
	Color:#404040;
	Text-Align:Center;
	Vertical-Align:Middle;
	filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D');
	Margin:1;
	Padding:2;
	Border-Left: 1px Transparent;  
	Border-Right: 2px Transparent;
	Border-Top: 1px Transparent;   
	Border-Bottom: 2px Transparent;
 }
</STYLE>
 <script Language='VBSCRIPT'>
  Dim Act :Set Act = CreateObject("Wscript.Shell")
  Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
  Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%Temp%") & "\MyReturn.cmd"
  Dim Wth, Hht :Wth = int(425) :Hht = int(175)
   window.ResizeTo Wth, Hht
   MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))
  Dim F1 :F1 = "<FONT STYLE='Font:8.25pt;Color:#002060;Font-Weight:Bold;'>"
  Dim idTimer, Y_DoIt
  Dim C1, D1 :C1 = 30 :D1 = 1
   Function Window_OnLoad()
	  Counter()
	  txt1.innerHTML = F1 & "Ask Your Question About What You Want Done</FONT>"
	  txt2.innerHTML = F1 & "Here Is Some More Text Space For You If Needed</FONT>"
	 End Function
   Function Counter()
	  Do
	   D1 = D1 -1 :C1 = C1 -1 :document.focus()
	  If Len(C1) = 1 Then C1 = "0" & C1
	  If Len(C1) = 2 Then C1 = C1
	 txt3.innerHTML = F1 & "Remaining Time Before Auto Select Yes    " & C1 & "</FONT>"
	  Loop Until D1 = 0
	  D1 = 1
	  If C1 = 0 Then 
	   Y_DoIt = True
	   HtaExit()
	   Exit Function
	  End if
	   idTimer = window.setTimeout("Counter", 1000, "VBScript")
	  If Y_DoIt = True Then Yes_Work()
   End Function
   Function No_Action()
	  Bttn_Y.disabled = True
	  txt3.innerHTML = Replace(F1,"002060","AD0101") & "No Was Selected Cancel All Operation</FONT>"
	  MkCmd("No")
	  window.clearTimeout(idTimer)
	  idTimer = window.setTimeout("MyTimer2", 5000, "VBScript")
   Exit Function
   End Function
   Function Yes_Action()
	  Y_DoIt = True
   End Function
   Function Yes_Work()
	  Bttn_N.disabled = True
	  txt3.innerHTML = Replace(F1,"002060","006020") & "Processing Yes Selection</FONT>"
	  MkCmd("Yes")
	  window.clearTimeout(idTimer)
	  idTimer = window.setTimeout("MyTimer1", 3000, "VBScript")
   End Function
   Function HtaExit() 
	  window.clearTimeout(idTimer)
	  If Y_DoIt = True Then Yes_Work()
   End Function
   Function MyTimer1()
	  txt3.innerHTML = ""
	  window.close()
	  window.clearTimeout(idTimer)
   End Function
   Function MyTimer2()
	  txt3.innerHTML = ""
	  window.close()
	  window.clearTimeout(idTimer)
   End Function
   Function MkCmd(T)
    Dim Ts :	Set Ts = Fso.CreateTextFile(Cmd)
	  Ts.WriteLine "@Echo && CLS && MODE 55,5 && COLOR F9"
	  Ts.WriteLine "Set Reply=" & T
	  Ts.Close
   End Function
 </SCRIPT>
 <BODY Scroll='No'>
 <Table><TD Class='Type1'><Span ID='txt1'></Span></TD></Table>
 <Table><TD Class='Type1'><Span ID='txt2'></Span></TD></Table>
 <Table><TD Class='Type1'><Span ID='txt3'></Span></TD></Table>
 <Table Style='Margin-Top:7pt;' Align='Center'>
  <TD><BUTTON ID='Bttn_N' OnClick='No_Action()'>No</BUTTON></TD>
  <TD><BUTTON ID='Bttn_Y' OnClick='Yes_Action()'>Yes</BUTTON></TD>
 </Table>
 </BODY>

Attached File  HtaYesNo.png   108.16KB   10 downloads
Attached File  YesNo_Updated.zip   1.74KB   9 downloads

I also wrote this 39 lines of code with comments in Vb.net 2008
Imports System
Imports System.IO
Public Class Form1
    Dim Yes
    Dim C1 = 30
    '-> Stsrt Timer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub
    '-> Yes
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Yes = 1
    End Sub
    '-> No 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Yes = 2
    End Sub
    '-> Start The Timer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        CountDown()
    End Sub
    '-> Count Down
    Private Sub CountDown()
        If C1 < 10 Then C1 = "0" & C1
        If Yes = 1 Then MakeCmd("Yes")
        If Yes = 2 Then MakeCmd("No")
        If C1 = 0 Then MakeCmd("Timed-Out")
        Counter.Text = "Time Left : " & C1
        C1 = C1 - 1
    End Sub
    '-> Make Reply Cmd With Yes No Time Out
    Private Sub MakeCmd(ByVal T As String)
        Dim Cmd = My.Computer.FileSystem.SpecialDirectories.Temp & "\MyReturn.cmd"
        Dim sw As StreamWriter = New StreamWriter(Cmd)
        sw.Write("Set Reply=" & T)
        sw.Close()
        Me.Close()
    End Sub
End Class

Attached File  YesNo_VbNet.png   128.78KB   10 downloads

VB.Net 2006 Source Code
Attached File  YesNo_Demo.zip   278.06KB   11 downloads

Cmd Promt I Used To Read The Responce
@Echo Off
CLS
Mode 79,11
Color F9
Title Test Return


Set Cmd1="%Temp%\MyReturn.cmd"

If Exist %Cmd1% GoTO Work1
If Not Exist %Cmd1% GoTO Ops1


:Work1
call %Cmd1%
CLS
IF /I '%Reply%'=='Yes' GOTO Y1
IF /I '%Reply%'=='No' GOTO N1
IF /I '%Reply%'=='Timed-Out' GOTO T1

Goto TheEnd

:Ops1
Color F5
CLS
Echo.
Echo  Missing %Cmd1%
Echo  Contact The System Admin For More Information!
pause
Exit

:Y1
CLS
Echo.
Echo User Selected : %Reply%
Echo.
Pause
GoTo TheEnd

:N1
CLS
Echo.
Echo User Selected : %Reply%
Echo.
Pause
GoTo TheEnd

:T1
CLS
CLS
Echo.
Echo Auto Action : %Reply%
Echo.
Pause
GoTo TheEnd

:TheEnd
Del %Cmd1%
Exit



GunSmokingMan






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users