AutoHotkey Community

It is currently May 26th, 2012, 12:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Peek under a window
PostPosted: March 31st, 2005, 11:12 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2005, 2:12 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Good things can come in small packages. Thanks for posting it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 11:23 pm 
Offline

Joined: November 28th, 2007, 10:00 pm
Posts: 25
Location: USA
Thank you so much i have been trying to do this for EVER. :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 2:13 pm 
Offline

Joined: February 5th, 2007, 12:19 pm
Posts: 192
Location: Osnabrück, Germany
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 4:40 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You probably have to check Window, to ignore the desktop, and possibly other windows, which don't behave nicely.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 11:35 pm 
Offline

Joined: February 24th, 2007, 6:02 pm
Posts: 175
Location: Budapest, Hungary
Nice script.
The best part is that it is 2,5 years old. :)

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 )


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], JamixZol and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group