Sunday 5 August 2018

Windows 7 feature or freeware to keep a window always beneath others


Some programs e.g. GridMove and XNeat allow users to keep a given window above other windows using an "Always On Top" command. Is there a way to do the reverse i.e. "Always At The Bottom" with any Windows 7 commands or freeware for it, except by making all other windows "Always On Top"?


It is sometimes useful to keep chat programs (into which typing occurs) beneath all windows with only the latest message and text entry field visible through the windows' gaps without the rest of chat program's UI cluttering up the space.



Answer



A long time ago, Windows had a PowerToy (later in TweakUI) called X-Mouse that, amongst other things, supported old-style X "focus follows mouse", where "focus" and "foreground" were not the same thing. I don't believe it's maintained any more (last sighting was for WinXP).


Though I haven't used it extensively, the free Windows scripting tool AutoIT can do what you want with a short script:


#include 
#include
#include
#include
#include

Local $hWnd,$flags,$regexp

Func MyExit()
MsgBox(0,"Drop Window","Quitting!",2)
Exit 0
EndFunc

$flags = BitOr($SWP_NOMOVE,$SWP_NOSIZE,$SWP_NOACTIVATE,$SWP_ASYNCWINDOWPOS,$SWP_NOSENDCHANGING)

;; hot key to call exit: ALT + F11
HotKeySet("!{F11}","MyExit")

;; application window title
$regexp=".*Notepad$"

;; 10 second time out on first startup,
$hWnd = WinWait("[REGEXPTITLE:" & $regexp & "]", "", 10)
;; or wait forever
;$hWnd = WinWait("[REGEXPTITLE:" & $regexp & "]")

If ($hWnd) Then
;; uncomment next line to maximize window first
;_SendMessage($hWnd,$WM_SYSCOMMAND,$SC_MAXIMIZE)

_WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, $flags);

While 1
If WinWaitActive($hWnd,"",10) Then
_WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, $flags);
EndIf
;; check for new window
$hWnd = WinWait("[REGEXPTITLE:" & $regexp & "]","",1)

;; uncomment next 3 lines to quit if no window
;if (NOT $hWnd) Then
; MyExit()
;EndIf

Sleep(250)
Wend
Else
MsgBox(0,"Drop Window","No window title matching /" & $regexp & "/")
EndIf

"topmost" is a persistent window property that the WM maintains, there is no equivalent "bottom most", so we have to fudge it a bit.


The While loop waits for the application to get the foreground, then drops it under again while keeping keyboard focus. Modal popups may sometimes interfere with this, but it should be quite usable.The script will continue to run in the background after the watched program terminates. Alt+F11 to exit it at any time.


Change $regexp to match "mIRC" or whatever. The above will only reliably handle one window at a time. Read the AutoIT docs for WinWait() to see how to match windows other than by window title.


Save to dropwindow.au3 and run it with "autoit3 dropwindow.au3".


http://www.autoitscript.com/site/autoit/downloads/


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...