Advertisement
ravmunken

AHK - Hide Icons

Mar 18th, 2013
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Author:  Jody Holmes (Skwire)
  3. Date:    2009-08-23
  4.  
  5.  
  6. v0.0.0.3 - 2009-09-29
  7.     + Added optional showing/hiding of titlebar min/max/close buttons.
  8.  
  9. v0.0.0.2 - 2009-08-28
  10.     * Hook now fires on two additional messages.
  11.         HSHELL_REDRAW
  12.         HSHELL_RUDEAPPACTIVATED
  13.  
  14. v0.0.0.1 - 2009-08-23
  15.     + Initial build.
  16.  
  17. */
  18.  
  19. #NoTrayIcon
  20. #Persistent
  21. #NoEnv
  22. #SingleInstance, Force
  23. SetWorkingDir, %A_ScriptDir%
  24. DetectHiddenWindows, Off
  25. OnExit, Cleanup
  26. SysGet, TBarHeight, 4
  27.  
  28. Menu, Tray, NoStandard
  29. Menu, Tray, Add, Exit, Cleanup
  30.  
  31. Gui +LastFound
  32. hWnd := WinExist()
  33.  
  34. ; Hook the shell.
  35. ; http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323
  36. DllCall( "RegisterShellHookWindow", UInt, hWnd )
  37. MsgNum := DllCall( "RegisterWindowMessage", Str, "SHELLHOOK" )
  38. OnMessage( MsgNum, "ShellMessage" )
  39.  
  40. ; Create a blank cursor for use instead of a blank icon file.
  41. ; http://www.autohotkey.com/forum/viewtopic.php?p=220113#220113
  42. VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 )
  43. hIcon := DllCall( "CreateCursor", Uint, 0, Int, 0, Int, 0, Int, 32, Int, 32, Uint, &AndMask, Uint, &XorMask )
  44.  
  45. ; Initial loop to blank out existing windows.
  46. WinGet, s, List
  47. Loop, % s
  48. {
  49.     s := s%A_Index%
  50.     ;SendMessage, 0x80, 0, hIcon, , % "ahk_id " . s
  51. }
  52.  
  53. ; MsgBox, 36, TBarIconBlanker, Would you like to enable the min/max/close buttons tweak as well?
  54. ; IfMsgBox, Yes
  55. ; {
  56. ;     MinMaxCloseOption := 1
  57. ;     SetTimer, WatchCursor, 100
  58. ; }
  59. ;MinMaxCloseOption := 1
  60. ;SetTimer, WatchCursor, 100
  61.  
  62. Return ; End of auto-execute section.
  63.  
  64.  
  65. ; ------------------------------------------------------------------------
  66. ; Subroutines ------------------------------------------------------------
  67. ; ------------------------------------------------------------------------
  68.  
  69. Cleanup:
  70. {
  71.     If ( MinMaxCloseOption = 1 ) ; Restore titlebar buttons on close.
  72.     {
  73.         WinGet, s, List
  74.         Loop, % s
  75.         {
  76.             s := s%A_Index%
  77.             WinSet, Style, +0x80000, % "ahk_id " . s ; Restore min/max/close buttons.
  78.         }
  79.     }
  80.     ExitApp
  81. }
  82. Return
  83.  
  84.  
  85. WatchCursor:
  86. {
  87.     MouseGetPos, , yPos, CurrID,
  88.     If ( yPos >= 0 and yPos < ( TBarHeight + 3 ) )
  89.     {
  90.         WinSet, Style, +0x80000, % "ahk_id " . CurrID ; Restore min/max/close buttons.
  91.         SendMessage, 0x80, 0, hIcon, , % "ahk_id " . CurrID ; Blank out titlebar and taskbar icons.
  92.     }
  93.     Else
  94.     {
  95.         WinSet, Style, -0x80000, % "ahk_id " . PrevID ; Get rid of min/max/close buttons.
  96.         WinSet, Style, -0x80000, % "ahk_id " . CurrID ; Get rid of min/max/close buttons.
  97.         SendMessage, 0x80, 0, hIcon, , % "ahk_id " . CurrID ; Blank out titlebar and taskbar icons.
  98.     }
  99. }
  100. Return
  101.  
  102.  
  103. ; ------------------------------------------------------------------------
  104. ; Functions --------------------------------------------------------------
  105. ; ------------------------------------------------------------------------
  106.  
  107. ; Shell hook to blank out windows that are subsequently created.
  108. ShellMessage( wParam, lParam )
  109. {
  110.     Global hIcon, MinMaxCloseOption, PrevID
  111.     If wParam in 1,6,32772
  112.     {
  113.         SendMessage, 0x80, 0, hIcon, , % "ahk_id " . lParam ; Blank out titlebar and taskbar icons.
  114.         If ( MinMaxCloseOption = 1 )
  115.         {
  116.             WinSet, Style, -0x80000, % "ahk_id " . lParam ; Get rid of min/max/close buttons.
  117.         }
  118.     }
  119.     PrevID := lParam
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement