Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Peek under a window


  • Please log in to reply
5 replies to this topic
Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
When writing a script I often need to look at the Help page. Unfortunately, the interesting part of it is always the one covered by the edit window. I can AltTab between the applications, but a mouse movement could be enough to make my edit window transparent. Moving back the mouse cursor restores the edit window. This is also useful as a replacement of a Boss (or Panic) Button: if your boss walks in your cubicle you don't even have to click on anything or hit a key, a quiet mouse movement hides the window you don't want him to see. It was suggested here. (In this case minimizing the window, instead of making it transparent could be better.)

This little utility is activated by LeftWindows-LeftMouseClick (LWin & LButton). The window under the mouse cursor is marked as hide-and-seek. After that, if the mouse cursor leaves the window or gets to its border (useful for maximized windows), the window becomes transparent. When the cursor returns to the inside of the hidden window, it becomes opaque again. This behavior remains active and automatically adapts to moved or resized windows, too. Pressing the HotKey: LWin & LButton again de-activates the script and removes the transparency effect from the hide-and-seek window, if it still exists. If the script exits for whatever reason (error or manual exit through the tray icon), the opacity gets restored, so you won't be left with an invisible window.

If the mouse cursor is on the TaskBar at activation, you get a similar behavior as its Auto Hide option. Pressing the HotKey again, regardless of the mouse position, restores the normal taskbar.
OnExit Cleanup

LWin & LButton::
IfEqual HideWindow,, {       ; Not set => Activate now
   MouseGetPos,,,HideWindow  ; Window ID under mouse
   SetTimer TransWindow, 150
}
Else {                       ; Already set => Stop, Restore
   SetTimer TransWindow, Off
   IfWinNotExist ahk_id %HideWindow%, Return
   WinActivate ahk_id %HideWindow%
   WinSet Transparent, 255, ahk_id %HideWindow%
   HideWindow =
}
Return

TransWindow:
   CoordMode Mouse, Relative
   MouseGetPos X, Y, Window
   WinGetPos,,,X1, Y1, ahk_id %HideWindow%
   If ( Window = HideWindow && X > 4 && Y > 4 && X < X1-5 && Y < Y1 )
        WinSet Transparent, 255, ahk_id %HideWindow%
   Else WinSet Transparent,   1, ahk_id %HideWindow%
Return

Cleanup:
   IfWinExist ahk_id %HideWindow%
   {
      WinActivate ahk_id %HideWindow%
      WinSet Transparent, 255, ahk_id %HideWindow%
   }
ExitApp


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Good things can come in small packages. Thanks for posting it.

nickromano
  • Members
  • 25 posts
  • Last active: Mar 17 2008 12:27 AM
  • Joined: 28 Nov 2007
Thank you so much i have been trying to do this for EVER. :D

haichen
  • Members
  • 200 posts
  • Last active: Oct 20 2013 01:14 PM
  • Joined: 05 Feb 2007
Very nice!
:D
Have you ever tried it on the desktop? The backgroundimage gets invisible and when it comes back you cant see any files and folder. I think its layered at top. Thats not really a problem. Finally a clean desktop. Nice!

But the opacity isnt restored at exit. So you have to restart the PC to get your image back.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You probably have to check Window, to ignore the desktop, and possibly other windows, which don't behave nicely.

HuBa
  • Members
  • 175 posts
  • Last active: Feb 13 2012 09:51 AM
  • Joined: 24 Feb 2007
Nice script.
The best part is that it is 2,5 years old. :)

I tried it and it seems to have some minor bugs:

IfEqual HideWindow,, {
should be:
if HideWindow =
{
and
If ( Window = HideWindow && X > 4 && Y > 4 && X < X1-5 && Y < Y1 )
should be
If ( Window = HideWindow && X > 4 && Y > 4 && X < X1-5 && Y < Y1-5 )