Skip to content

Instantly share code, notes, and snippets.

@Drugoy

Drugoy/test.ahk Secret

Created February 11, 2014 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drugoy/ecd72e2a36319befa840 to your computer and use it in GitHub Desktop.
Save Drugoy/ecd72e2a36319befa840 to your computer and use it in GitHub Desktop.
#NoEnv
#Persistent
#SingleInstance force
;SetTitleMatchMode, 2
;DetectHiddenWindows, On
SetWorkingDir %A_ScriptDir%
;by SKAN http://www.autohotkey.com/forum/topic33955.html
#NoTrayIcon ; Hide the default Tray icon
IconDataHex =
( Join
000001000100101010000100040028010000160000002800000010000000200000000100040000000000C00000
0000000000000000000000000000000000C6080800CE101000CE181800D6212100D6292900E13F3F00E7525200
EF5A5A00EF636300F76B6B00F7737300FF7B7B00FFC6C600FFCEC600FFDEDE00FFFFFF00CCCCCCCCCCCCCCCCC0
0000000000000CC11111111111111CC22222CFFE22222CC33333CFFE33333CC44444CFFE44444CC55555CFFE55
555CC55555CFFE55555CC55555CFFE55555CC66666CFFE66666CC77777777777777CC88888CFFC88888CC99999
CFFC99999CCAAAAAAAAAAAAAACCBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCC00000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000
)
VarSetCapacity( IconData,( nSize:=StrLen(IconDataHex)//2) )
Loop %nSize% ; MCode by Laszlo Hars: http://www.autohotkey.com/forum/viewtopic.php?t=21172
NumPut( "0x" . SubStr(IconDataHex,2*A_Index-1,2), IconData, A_Index-1, "Char" )
IconDataHex := "" ; Hex contents needed no more
hICon := DllCall( "CreateIconFromResourceEx", UInt,&IconData+22, UInt, NumGet(IconData,14)
, Int,1, UInt,0x30000, Int,16, Int,16, UInt,0 )
; Thanks Chris : http://www.autohotkey.com/forum/viewtopic.php?p=69461#69461
Gui +LastFound ; Set our GUI as LastFound window ( affects next two lines )
SendMessage, ( WM_SETICON:=0x80 ), 0, hIcon ; Set the Titlebar Icon
SendMessage, ( WM_SETICON:=0x80 ), 1, hIcon ; Set the Alt-Tab icon
; Creating NOTIFYICONDATA : www.msdn.microsoft.com/en-us/library/aa930660.aspx
; Thanks Lexikos : www.autohotkey.com/forum/viewtopic.php?p=162175#162175
#Include <Class_DllStruct> ;[CLASS] DllStruct (AHK 1.1) by just me http://www.autohotkey.com/forum/topic74240.html
structGUID := "
(LTrim Join
DWORD Data;
WORD Data2;
WORD Data3;
BYTE Data4[8];
)"
;http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352%28v=vs.85%29.aspx
structNOTIFYICONDATA := "
(LTrim Join
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
TCHAR szTip[64];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
UINT uTimeout;
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
" . structGUID . "
HICON hBalloonIcon;
)"
; msgbox % def_NOTIFYICONDATA
_NOTIFYICONDATA := new DllStruct(structNOTIFYICONDATA)
_NOTIFYICONDATA.cbSize := _NOTIFYICONDATA.GetSize()
_NOTIFYICONDATA.hWnd := A_ScriptHwnd
_NOTIFYICONDATA.uID := 1028
_NOTIFYICONDATA.uFlags := 2
_NOTIFYICONDATA.hIcon := hIcon
Menu, Tray, Icon ; Show the default Tray icon ..
DllCall("shell32\Shell_NotifyIcon", UInt, 0x1, UPtr, _NOTIFYICONDATA.GetPtr() ) ; .. and immediately modify it
Gui, Show, w640 h480
Return
GuiClose:
ExitApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment