Skip to content

Instantly share code, notes, and snippets.

@JarvisPrestidge
Last active November 30, 2016 14:56
Show Gist options
  • Save JarvisPrestidge/e882b8e12d6adc79ae77a5055f75dbcd to your computer and use it in GitHub Desktop.
Save JarvisPrestidge/e882b8e12d6adc79ae77a5055f75dbcd to your computer and use it in GitHub Desktop.
; <COMPILER: v1.1.24.03>
#Persistent
#NoTrayIcon
global _HWND := ""
OnExit("Quit")
#IfWinActive ahk_exe WhatsApp.exe
Esc::
{
AssignHWND()
BuildMenu()
WinHide ahk_id %_HWND%
}
return
LButton:: Click Down
LButton Up::
{
AssignHWND()
CoordMode, Mouse, Screen
MouseGetPos, x, y
if (IsOverCloseButton(x, y))
msgbox gotcha
Click Up
}
return
#IfWinActive
AssignHWND() {
WinGet, active_id, ID, A
_HWND := active_id
return
}
BuildMenu() {
Menu, Tray, Icon
Menu, Tray, NoStandard
Menu, Tray, Add, Open WhatsApp, Open
Menu, Tray, Default, Open WhatsApp
Menu, Tray, Add, Exit, Quit
return
}
Open() {
Menu, Tray, NoIcon
WinShow ahk_id %_HWND%
WinActivate ahk_id %_HWND%
return
}
Quit() {
WinShow ahk_id %_HWND%
WinActivate ahk_id %_HWND%
ExitApp
}
IsOverCloseButton(x, y) {
SendMessage, 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16,, ahk_id %_HWND%
msgbox %ErrorLevel%
return (ErrorLevel == 20)
}
F12::listvars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment