/ahk_scripts/toggleTaskBar.ahk

http://github.com/jixiuf/my_autohotkey_scripts · AutoHotKey · 82 lines · 47 code · 11 blank · 24 comment · 1 complexity · b84a939c554b20453c69917ea095dbe7 MD5 · raw file

  1. ;RunAndHide.ahk
  2. ; Run to hide or show the taskbar
  3. ;Skrommel @ 2008
  4. ; #NoEnv
  5. ; #SingleInstance,Force
  6. ; #NoTrayIcon
  7. SetWinDelay,0
  8. Gosub, AUTOHIDE
  9. #z::
  10. IfWinExist,ahk_class Shell_TrayWnd
  11. {
  12. WinHide,ahk_class Shell_TrayWnd
  13. WinHide, ahk_class Button
  14. Gosub, AUTOHIDE
  15. }
  16. Else
  17. {
  18. ; WinSet,Region,,ahk_id %taskbar%
  19. ; Send #d
  20. WinShow,ahk_class Shell_TrayWnd
  21. WinShow, ahk_class Button
  22. ; WinShow, ahk_class DV2ControlHost
  23. RefreshTray()
  24. Gosub, Normal
  25. }
  26. return
  27. ;;;启动后就隐藏任务栏
  28. ;;为了更大得用桌面空间
  29. ;; 右键任务栏取消选中"将任务栏保持在其它窗口的前端"
  30. ;;这样在任务栏隐藏之后这部分空间才能得以利用
  31. ;Stolen from SKAN at http://www.autohotkey.com/forum/topic26107.html
  32. AUTOHIDE: ;Stolen from SKAN at http://www.autohotkey.com/forum/topic26107.html
  33. ABM_SETSTATE := 10
  34. ABS_NORMAL := 0x0 ; 正常
  35. ABS_AUTOHIDE := 0x1 ; 自动隐藏
  36. ABS_ALWAYSONTOP := 0x2 ; 总在最前
  37. VarSetCapacity(APPBARDATA,36,0)
  38. Off:=NumPut(36,APPBARDATA)
  39. Off:=NumPut(WinExist("ahk_class Shell_TrayWnd"),Off+0)
  40. ; NumPut(ABS_AUTOHIDE|ABS_ALWAYSONTOP, Off+24)
  41. NumPut(ABS_NORMAL, Off+24)
  42. DllCall("Shell32.dll\SHAppBarMessage",UInt,ABM_SETSTATE,UInt,&APPBARDATA)
  43. Return
  44. NORMAL:
  45. NumPut(ABS_ALWAYSONTOP,Off+24)
  46. DllCall("Shell32.dll\SHAppBarMessage",UInt,ABM_SETSTATE,UInt,&APPBARDATA)
  47. Return
  48. ; AlwaysAtBottom(Child_ID)
  49. ; {
  50. ; WinGet, Desktop_ID, ID, ahk_class Progman
  51. ; Return DllCall("SetParent", "uint", Child_ID, "uint", Desktop_ID)
  52. ; }
  53. ; ;;WinSet:=AlwaysAtBottom(WinExist("A"))
  54. ; ;;让任务栏始终在下
  55. ; AlwaysAtBottom(WinExist("ahk_class Shell_TrayWnd"))
  56. ; 刷新右下角区域
  57. RefreshTray() {
  58. WM_MOUSEMOVE := 0x200
  59. ControlGetPos, xTray,, wTray,, ToolbarWindow321, ahk_class Shell_TrayWnd
  60. endX := xTray + wTray
  61. x := 5
  62. y := 12
  63. Loop
  64. {
  65. if (x > endX)
  66. break
  67. point := (y << 16) + x
  68. PostMessage, %WM_MOUSEMOVE%, 0, %point%, ToolbarWindow321, ahk_class Shell_TrayWnd
  69. x += 18
  70. }
  71. }