常规写法:
^1:: {
static taskbarVisible := true
taskbarVisible := !taskbarVisible
Switch taskbarVisible {
Case true:
WinShow("ahk_class Shell_TrayWnd")
Case false:
WinHide("ahk_class Shell_TrayWnd")
}
}
三目运算符写法:
^1::{
static taskbarVisible := true
taskbarVisible := !taskbarVisible
(taskbarVisible ? WinShow("ahk_class Shell_TrayWnd") : WinHide("ahk_class Shell_TrayWnd"))
}
精简写法:
^1:: {
static taskbarVisible := 1
Win%(taskbarVisible ^= 1) ? 'Show' : 'Hide'%("ahk_classShell_TrayWnd")
}
适用更多任务栏的写法:
global TaskBars
GroupAdd "TaskBars", "ahk_class Shell_TrayWnd"
GroupAdd "TaskBars", "ahk_class Shell_SecondaryTrayWnd"
^1:: {
static taskbarVisible := 1
Win%(taskbarVisible ^= 1) ? 'Show' : 'Hide'%("ahk_group TaskBars")
}