Skip to content

Instantly share code, notes, and snippets.

@dsetareh
Created July 5, 2021 19:51
Show Gist options
  • Save dsetareh/1b7162cb005d31ddaced070124f6eb32 to your computer and use it in GitHub Desktop.
Save dsetareh/1b7162cb005d31ddaced070124f6eb32 to your computer and use it in GitHub Desktop.
cremation keybinds
XButton1::Space
XButton2::
GetKeyState, state, Space
if (state = "D") {
HoldEsc()
}
else {
HoldTwo()
}
return
HoldTwo() {
SetTimer, FollowMouseTwo, 30
Send, {2 Down}
KeyWait, XButton2
Send, {2 Up}
SetTimer, FollowMouseTwo, off
ToolTipFM() ; destroy tooltip
}
FollowMouseTwo:
ToolTipFM("Sending 2!")
return
HoldEsc() {
SetTimer, FollowMouseEsc, 30
Send, {Esc Down}
KeyWait, XButton2
Send, {Esc Up}
SetTimer, FollowMouseEsc, off
ToolTipFM() ; destroy tooltip
}
FollowMouseEsc:
ToolTipFM("Sending Esc!")
return
ToolTipFM(Text="", WhichToolTip=16, xOffset=16, yOffset=16) { ; ToolTip which Follows the Mouse
static LastText, hwnd, VirtualScreenWidth, VirtualScreenHeight ; http://www.autohotkey.com/forum/post-430240.html#430240
if (VirtualScreenWidth = "" or VirtualScreenHeight = "")
{
SysGet, VirtualScreenWidth, 78
SysGet, VirtualScreenHeight, 79
}
if (Text = "") ; destroy tooltip
{
ToolTip,,,, % WhichToolTip
LastText := "", hwnd := ""
return
}
else ; move or recreate tooltip
{
CoordMode, Mouse, Screen
MouseGetPos, x,y
x += xOffset, y += yOffset
WinGetPos,,,w,h, ahk_id %hwnd%
; if necessary, adjust Tooltip position
if ((x+w) > VirtualScreenWidth)
AdjustX := 1
if ((y+h) > VirtualScreenHeight)
AdjustY := 1
if (AdjustX and AdjustY)
x := x - xOffset*2 - w, y := y - yOffset*2 - h
else if AdjustX
x := VirtualScreenWidth - w
else if AdjustY
y := VirtualScreenHeight - h
if (Text = LastText) ; move tooltip
DllCall("MoveWindow", A_PtrSize ? "UPTR" : "UInt",hwnd,"Int",x,"Int",y,"Int",w,"Int",h,"Int",0)
else ; recreate tooltip
{
; Perfect solution would be to update tooltip text (TTM_UPDATETIPTEXT), but must be compatible with all versions of AHK_L and AHK Basic.
; My Ask For Help link: http://www.autohotkey.com/forum/post-421841.html#421841
CoordMode, ToolTip, Screen
ToolTip,,,, % WhichToolTip ; destroy old
ToolTip, % Text, x, y, % WhichToolTip ; show new
hwnd := WinExist("ahk_class tooltips_class32 ahk_pid " DllCall("GetCurrentProcessId")), LastText := Text
%A_ThisFunc%(Text, WhichToolTip, xOffset, yOffset) ; move new
}
Winset, AlwaysOnTop, on, ahk_id %hwnd%
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment