Skip to content

Instantly share code, notes, and snippets.

@dimm0k
Last active December 20, 2015 15:58
Show Gist options
  • Save dimm0k/6157627 to your computer and use it in GitHub Desktop.
Save dimm0k/6157627 to your computer and use it in GitHub Desktop.
;Linear Spoon - http://www.autohotkey.com/board/topic/96036-setting-always-on-top-via-left-mouse-button-hold/?p=604824
;emulate Preme's always_on_top toggle. code began with AcidStrike@freenode#ahk, then modified by Linear Spoon
MoveThreshold = 30 ;# pixels the mouse can move and still toggle
TimeRequired = 1 ;# seconds required to toggle (can have a decimal part such as 1.5)
CoordMode, Mouse
return
~LButton::
MouseGetPos, OutX, OutY, OutWin
KeyWait, LButton, U T%TimeRequired%
MouseGetPos, CurX, CurY, CurWin
If (Abs(CurX-OutX) > MoveThreshold || Abs(CurY-OutY) > MoveThreshold || CurWin != OutWin)
return
If ErrorLevel
{
WinSet, AlwaysOnTop, Toggle, ahk_id %OutWin%
WinGet, ExStyle, ExStyle, ahk_id %OutWin%
Tooltip, % "Always-On-Top: " (ExStyle & 0x8 ? "En" : "Dis") "abled " OutWin
;Negative timer here means "Run only once"
SetTimer, RemoveToolTip, -2000
}
Return
RemoveToolTip:
ToolTip
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment