AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Peek under a window

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Thu Mar 31, 2005 10:12 pm    Post subject: Peek under a window Reply with quote

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.
Code:
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
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri Apr 01, 2005 1:12 pm    Post subject: Reply with quote

Good things can come in small packages. Thanks for posting it.
Back to top
View user's profile Send private message Send e-mail
nickromano



Joined: 28 Nov 2007
Posts: 25
Location: USA

PostPosted: Mon Dec 10, 2007 10:23 pm    Post subject: Reply with quote

Thank you so much i have been trying to do this for EVER. Very Happy
Back to top
View user's profile Send private message Visit poster's website AIM Address
haichen



Joined: 05 Feb 2007
Posts: 140
Location: Osnabrück, Germany

PostPosted: Tue Dec 11, 2007 1:13 pm    Post subject: Reply with quote

Very nice!
Very Happy
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.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Tue Dec 11, 2007 3:40 pm    Post subject: Reply with quote

You probably have to check Window, to ignore the desktop, and possibly other windows, which don't behave nicely.
Back to top
View user's profile Send private message
HuBa



Joined: 24 Feb 2007
Posts: 172
Location: Budapest, Hungary

PostPosted: Tue Dec 11, 2007 10:35 pm    Post subject: Reply with quote

Nice script.
The best part is that it is 2,5 years old. Smile

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

Code:
IfEqual HideWindow,, {
should be:
Code:
if HideWindow =
{

and
Code:
If ( Window = HideWindow && X > 4 && Y > 4 && X < X1-5 && Y < Y1 )
should be
Code:
If ( Window = HideWindow && X > 4 && Y > 4 && X < X1-5 && Y < Y1-5 )
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group