What the script is supposed to do is draw a super-thick (enough to cover the rest of the desktop spannig two displays) semi-transparent border around an active window. Like Ghoster, but a different approach.
Please help me get the script to a working condition. I think it's worth mentioning here that my secondary display is in portrait mode, with the upper edge higher than that of the primary display, which results in negative Y-coordinates of any point on that screen that is above the upper edge of the primary display.
Ideally (but that is beyond my current skill level), it would be awesome if the border only covered the display the window is on, and there was another border around a window that was last active on the other display.
Code: Select all
#Persistent
OnExit, ExitSub
Menu, Tray, Icon, %A_WorkingDir%\icons\activeWinHighlight.ahk.ico
border_thickness = 2730 ; 1680+1050, enough for two displays, one in portrait mode
border_color = 000000
transparency = 88
border_type = outside ; set to inside, outside, or both
Gui, +HwndRG +Toolwindow +Disabled -SysMenu -Caption +E0x20
Gui, Color, %border_color%
WinSet,Transparent,%transparency%, ahk_id %RG%
SetTimer, R, 80
Return
R:
KeyWait, LButton ; in case a window is being moved/resized
; See if there is a change in the active window
if (id <> WinExist("A"))
{
id := WinExist("A")
WinGet m, MinMax ; 1=maximized, 0=restored, -1=minimized
WinGetPos, x, y, w, h, A
WinGet xs, ExStyle
Goto D
}
else
{
WinGet mc, MinMax ; 1=maximized, 0=restored, -1=minimized
if (m <> mc)
{
m := mc
WinGetPos, x, y, w, h, A
WinGet xs, ExStyle
Goto D
}
else
{
WinGetPos, xc, yc, wc, hc, A
if (x <> xc or y <> yc or w <> wc or h <> hc)
{
x := xc
y := yc
w := wc
h := hc
WinGet xs, ExStyle
Goto D
}
else
{
WinGet xsc, ExStyle
if (xs <> xsc)
{
xs := xsc
Goto D
}
}
}
}
Return
D:
if w > 0
{
if (border_type="outside") {
outerX:=0
outerY:=0
outerX2:=w+2*border_thickness
outerY2:=h+2*border_thickness
innerX:=border_thickness
innerY:=border_thickness
innerX2:=border_thickness+w
innerY2:=border_thickness+h
newX:=x-border_thickness
newY:=y-border_thickness
newW:=w+2*border_thickness
newH:=h+2*border_thickness
} else if (border_type="inside") {
WinGet, myState, MinMax, A
if (myState=1)
offset:=8
else
offset:=0
outerX:=offset
outerY:=offset
outerX2:=w-offset
outerY2:=h-offset
innerX:=border_thickness+offset
innerY:=border_thickness+offset
innerX2:=w-border_thickness-offset
innerY2:=h-border_thickness-offset
newX:=x
newY:=y
newW:=w
newH:=h
} else if (border_type="both") {
outerX:=0
outerY:=0
outerX2:=w+2*border_thickness
outerY2:=h+2*border_thickness
innerX:=border_thickness*2
innerY:=border_thickness*2
innerX2:=w
innerY2:=h
newX:=x-border_thickness
newY:=y-border_thickness
newW:=w+4*border_thickness
newH:=h+4*border_thickness
}
GUI, Hide ; Do I need this?
WinSet, Region, %outerX%-%outerY% %outerX2%-%outerY% %outerX2%-%outerY2% %outerX%-%outerY2% %outerX%-%outerY% %innerX%-%innerY% %innerX2%-%innerY% %innerX2%-%innerY2% %innerX%-%innerY2% %innerX%-%innerY%, ahk_id %RG%
Gui, +AlwaysOnTop
Gui, Show, w%newW% h%newH% x%newX% y%newY% NA
Gui, -AlwaysOnTop
}
Return
^+q::Goto ExitSub
ExitSub:
Gui, Destroy
ExitApp