Tweets

måndag 19 mars 2012

Were are you?

It is not always easy to know which window is the current active one. Specially when you have multiple monitors and an operating system with the bad habit to suddenly activate "important" windows to get your attention.

Active windows are almost always indicated in some graphical way, but not that distinct that you would be able to tell the active window in a split second. And that is how fast you would like to, wouldn't you?

Here is a AutoHotKey script for you. Activate it by ctrl+super+space and toggle with super+alt+space.

; This script puts a red border on the current window. 
; Nice to have something clearly indicating what is active.

; Author: @danielgasinski
; Source of inspiration http://blog.sveri.de/2010/01/27/script-to-draw-a-border-around-an-active-window-with-autohotkey/
Toggle:=0

^#space::
 Loop
 {
  if(Toggle != 1)
  {
   b = 6 ; border 
   full_width = 1936 ; w value from WinGetPos, lite more than screen width
   
   WinGetPos, x, y, w, h,  A
   
   if(w >= full_width)
   {
    b:=12 ; We make the border thicker when in full screen, otherwise it may not be visible
   }
   
   width:=w-b
   height:=h-b

   Gui, -Caption +Lastfound +AlwaysOnTop +Toolwindow
   Gui, Color, FF0000
   
   WinSet, Region, %b%-%b% %b%-%height% %width%-%height% %width%-%b% %b%-%b%  0-0 %w%-0 %w%-%h% 0-%h% 0-0
   
   Gui, Show, w%w% h%h% x%x% y%y% NoActivate, 
  }
  Sleep, 50 ; Chance/time to interupt
 }
return

; Toggle on of alt+win+space 
!#space::
Toggle := Toggle<1 ? 1 : 0

Gui, Show, w0 h0 x0 y0 NoActivate, 
return
Example of how the script works. Nota bene: ignore the semicolons on row 18 and 39. It is something fishy with the AutoHotKey highlight script making them appear in the post. Sorry.

Inga kommentarer:

Skicka en kommentar