Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch an IE .hta and keeping the window active. 1

Status
Not open for further replies.

0LaoyanG0

MIS
Nov 12, 2002
25
US
I know it is possible to have a vbscript execute or open an html/htm/hta file. However, I would like to open a html/htm/hta and keep it the active window all the time (for about 45 seconds) and if the user clicks/navigates away from the window I want it to automatically get the focus back. Then close after 45 seconds. Anyone have an example?

Thanks
 
We want a splash screen to force users NOT to click anywhere else or start any applications til the Citrix ICA Client is finished launching the initial application. Some users are not waiting and are causing multiple profiles to be logged into differen't Citrix Servers.
Forcing them to wait will eliminate this problem.
Oh yeah, telling them to stop being so impatioent doesn't work......lol

Thanks
 
This would cause the window to receive focus every milisecond. The user can click on something behind the window, so I don't know if it meets your needs.
Code:
Dim iTimerID
Sub window_onLoad
  iTimerID = window.setInterval("ShowMe",1)
End Sub

Sub ShowMe
  window.focus()
End Sub
 
I tested it and yes you're right. Users will be able to click on other items. Thanks for your reply though.
 
You could just take up the whole screen.

Code:
<html>
<head>
<hta:application
	applicationname="Wait!"	
	border="none"
	borderstyle="normal"
	caption="Wait!"
	contextmenu="no"
	icon="images/.ico"
	maximizebutton="no"
	minimizebutton="no"
	navigable="no"
	scroll="no"
	selection="no"
	showintaskbar="no"
	singleinstance="yes"
	sysmenu="no"
	version="1.0"
	windowstate="maximize"
>
</head>
<title>Wait!</title>
<body style="font:14 pt arial; color:white; filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#272936', EndColorStr='#272936')" onload="">
<div align="center"><br><br><h1>WAIT!!!</h1></div>
</body>
</html>

maybe execute the hta using Exec method of WScript.Shell and then use the Terminate method to close it out when you are done. i.e.

Code:
Option Explicit
'On Error Resume Next

Dim objShell	:	Set objShell = CreateObject("WScript.Shell")
Dim objExec		:	Set objExec = objShell.Exec("mshta C:\Temp\temp.hta")

WScript.Sleep 5000
objExec.Terminate

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I actually have tested a script similar that launches the hta and monitors the PID of the instance. It looped constantly checking the PID's existance in taskmanager and relaunched if it was gone (if the user hit ALT+F4). However, users still were able to navigate away from the maximized form/window and start clicking on other stuff.

I did however find code to do something very close to what I want to do but I keep getting an error on the line "objIE.document.focus()"

Here's the entire code...

'**************************************************************************************************
'This code will open a web browser and point it at the url specified.
'sURL is the url to the website you want to load.
'This vbscript will not allow the user to switch to any other window till this script ends.
'**************************************************************************************************
dim sURL
'**************************************************************************************************
'**************************************************************************************************

'The url to the webpage that you want the user to go to.
sURL= "
'**************************************************************************************************
'**************************************************************************************************
'**************************************************************************************************
'!!!!!!!!!!DO NOT CHANGE BELOW HERE UNLESS YOU KNOW WHAT YOU DOING!!!!!!
'**************************************************************************************************
'**************************************************************************************************
'**************************************************************************************************
dim objIE, bExit
bExit = 0
'on error resume next

'Create an Internet Explore Browser
Set objIE = CreateObject("InternetExplorer.Application")

objIE.navigate(surl) 'Navigate to the website

'Set the browser to fullscreen and theatermode
objIE.Fullscreen=true

'This makes the window not closable until the user exits the page using a script on the html
'page that has a window.close command or they use Alt-F4
'Setting the TheaterMode on and then off makes the object show properly.

objIE.TheaterMode=true
objIE.TheaterMode=false

'Turn off the status bar
objIE.statusbar=false

'Turn off the toolbar
'objIE.toolbar=false

'Turn off Resizable
objIE.Resizable=false

while bExit=0
'While the browser is showing loop

objIE.document.focus()
'Set the browser to focus which brings it to the top.

objIE.top =0
objIE.Left=0
'Sets the window to the upper left hand corner

if err.number <>0 then
'if an error occured exit the program
bExit = 1
end if
wend
'Clean up the objects

set objIE = nothing



Any help on this is greatly appreciated!

Thanks
 
It's firing before there's a document loaded into ie.
Code:
dim sURL
sURL= "[URL unfurl="true"]http://www.google.com"[/URL]
dim objIE, bExit
bExit = 0

Set objIE = CreateObject("InternetExplorer.Application")    
objIE.navigate(surl) 'Navigate to the website
objIE.Fullscreen=true                                
objIE.TheaterMode=true                                        
objIE.TheaterMode=false                            
objIE.statusbar=false                                
'objIE.toolbar=false                                    
objIE.Resizable=false
[red]while objIE.busy
  wscript.sleep(100)
wend[/red]
while bExit=0                          
    objIE.document.focus()
    objIE.top =0            
    objIE.Left=0                            
    if err.number <>0 then                            
    bExit = 1
    end if
wend
set objIE = nothing
 
You may just consider using AutoIT which has a WinActivate function that is more aggressive and reliable than AppActivate. You can compile it into an executable so AutoIT is not required on the machine you run it on.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top