Restoring HTA after it has been minimized using the "show desktop" button

Posted on 2009-02-13
Medium Priority
Last Modified: 2012-05-06
I have an HTA application of which I've locked down so the user cannot minimize, close, or modify the contents of the window.  It is simply a "HUD", if you will, that we want to always be showing on the user's machine.

The only way a user can minimize the application now is to click the Show Desktop button.  Is there a way I can restore the window from the minimized state or atleast read if it is minimized?
Question by:piattnd
  • 2
  • 2

Accepted Solution

jwarnken earned 1000 total points
ID: 23650553
You will need to add a function to check the window state periodically.
see to get the state http://msdn.microsoft.com/en-us/library/ms536494(VS.85).aspx

You can then try using AppActivate to restore the window.
see http://msdn.microsoft.com/en-us/library/wzcddbek(VS.85).aspx
LVL 65

Assisted Solution

RobSampson earned 1000 total points
ID: 23653283
Hi, this HTA will detect when it has been minimised, but I'm yet to figure out how to maximise it reliably....


<title>Test HTA</title>
     id = "objHTA"
     applicationname="Test HTA"
<script language="vbscript">
     Sub Window_onLoad 
         iTimerID = window.setInterval("CheckState", 2000)
     End Sub
     Sub CheckState
         Set objShell = CreateObject("WScript.Shell")
         If window.ScreenTop < 0 Then
         	MsgBox objHTA.ApplicationName & " has been minimized."
         End If
     End Sub
	<h2>Test HTA</h2>

Open in new window

LVL 12

Author Comment

ID: 23664251
Interesting enough, the program doesn't actually realize it's been minimized if you use the Show Desktop option.

Here's another interesting thing.  If a user minimizes the windows using the Show Desktop feature, upon clicking any of their windows, the HTA restores itself.

I'm hoping this action continues to perform as it is.  I'm going to post another question regarding a script to possibly replace the Show Desktop feature.  I'm interested in making a script that minimizes all other active apps other than the contract stats.
LVL 12

Author Closing Comment

ID: 31546789
Thank you both for your assistance.
LVL 65

Expert Comment

ID: 23665285

You can use this code to minimize all windows except the one with the specific title that you specify.

This requires that Microsoft Word is installed though.


strTitle = "Test HTA"
Const wdWindowStateNormal = 0
Const wdWindowStateMaximize = 1
Const wdWindowStateMinimize = 2
Set objWord = CreateObject("Word.Application")
'objWord.Visible = True
For Each objWindow In objWord.Tasks
	If objWindow.Visible = True Then
		If objWindow.Name <> strTitle Then objWindow.WindowState = wdWindowStateMinimize
	End If

Open in new window


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question