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

Posted on 2009-02-13
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
    LVL 8

    Accepted Solution

    You will need to add a function to check the window state periodically.
    see to get the state

    You can then try using AppActivate to restore the window.
    LVL 65

    Assisted Solution

    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

    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

    Thank you both for your assistance.
    LVL 65

    Expert Comment


    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
    Read about why website design really matters in today's demanding market.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now