Hi Bruce, I hope you won't mind if I question that script.

> local hact = win.handle("active")
> if (hact != 0 and not win.minned(hact)) do
> win.minimize(hact)
> win.show(hact)
> endif

When tested here, win.handle("active") never equals O.

To demonstrate that, set a hotkey, such as Ctrl+Shift+F10,
to do this:
Command: hact=win.handle("active")
More commands: win.debug(hact,win.caption(hact))

Test 1: minimise every window, then press your hotkey.
Test 2: close every window, then press your hotkey.

In every case, hact never equals 0. As can be seen from
debugging win.caption(hact), after all windows are minimised
hact might become the Desktop (caption: Program Manager),
or the Taskbar (returns a blank caption),
or one of your PowerPro bars (most likely an OnTop one),
or more rarely the handle of a minimised window.

To learn more, change Test 1 to:
- minimise all windows, then click a blank area on the desktop,
then press the hotkey.
- minimise all windows, then click a blank area on the Taskbar,
then press the hotkey.
- use an OnTop PP bar, then minimise all, then try the hotkey.
- etc.

So that script is not able to avoid problems allegedly arising
from minimising and restoring "nothing", or the wrong thing
such as the Desktop or the Taskbar or a PowerPro bar.

---------------------------------------

However I agree he probably doesn't wish to restore the rare
minimised-and-active window. So I guess he could keep the
test for whether it is minimised.
I suggest:

if(not win.minned("active"))do
window min active
wait for 10
Exec RestoreLastMin
endif

Note: that tiny wait is only necessary if there is nothing between
the Min and the Restore, to make time for "LastMin" to be updated.
Otherwise a previously minimised window will be restored.

In my tests, if you execute this script when there are
no open windows, not even minimised, nothing happens,
no harm done, not even an error message.
So there seems no need to add more If conditions.

-------------------------------------

I doubt if Exec RestoreLastMin would ever try to restore
a hidden window, even less likely a window with handle "0"!
but to be hyper cautious:

I guess it might be possible (but very unlikely)
for win.handle("active") to be 0 or "" in the unusual situation
where there is no Windows Shell, not even an alt Shell,
to become active by default, and no open windows (not even minimised)
and no PP bars.
I didn't test that scenario.

Probably even then, Windows will find something with a real
handle to designate as "active", maybe a hidden window.
Minimising and restoring a randomly chosen hidden window
might cause problems, so for minimalist no-shellers
an extra if(condition) might be necessary, just in case.

"if (hact != 0)" would not protect against Exec RestoreLastMin
restoring a hidden window, or some other unsuitable handle.

The following script would give better protection I think:

If(visiblewindow("active") and not win.minned("active"))do
window min active
wait for 10
Exec RestoreLastMin
endif



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income homes are not online. Make a difference this holiday season!
http://us.click.yahoo.com/5UeCyC/BWHMAA/TtwFAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to