[AHK]桌面图标显隐

发布时间 2023-06-09 14:36:14作者: 稻荷夜
; AHKv2可用
!q::
{
    ; 获取FolderView的id
    HWorkerW := WinGetID("ahk_class WorkerW")
    HDefView := DllCall("FindWindowEx", "UInt", HWorkerW, "UInt", 0, "Str", "SHELLDLL_DefView", "UInt", 0)
    HListView := DllCall("FindWindowEx", "UInt", HDefView, "UInt", 0, "Str", "SysListView32", "UInt", 0)
    ; 检查显隐状态
    if DllCall("IsWindowVisible", "UInt", HListView) {
        DllCall("ShowWindow", "UInt", HListView, "UInt", 0)
    }
    else {
        DllCall("ShowWindow", "UInt", HListView, "UInt", 5)
    }
}
 
; AHKvL可用
!q::
{
   ControlGet, class, Hwnd, , SysListView321, ahk_class Progman
    If (class = "")
        ControlGet, class, Hwnd, , SysListView321, ahk_class WorkerW
    If DllCall("IsWindowVisible", UInt, class)
        WinHide, ahk_id%class%
    Else
        WinShow, ahk_id%class%
}