We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

piattnd
piattnd asked
on
Medium Priority
1,959 Views
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?
Comment
Watch Question

Commented:
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
 

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Hi, this HTA will detect when it has been minimised, but I'm yet to figure out how to maximise it reliably....

Regards,

Rob.
<html>
<title>Test HTA</title>
<hta:application 
     id = "objHTA"
     applicationname="Test HTA"
     scroll="yes"
     singleinstance="yes"
     windowstate="normal"
>
<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
 
</script>
</head> 
<body>
	<h2>Test HTA</h2>
</body>
</html>

Open in new window

Author

Commented:
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.

Author

Commented:
Thank you both for your assistance.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Hi,

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.

Regards.

Rob.
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
Next
objWord.Quit

Open in new window

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.