使用windows系统的时候,桌面有时会变得比较杂乱,想要随时随地很方便的隐藏和显示桌面图标还不是不是一件容易的事情,这里介绍了一个代码,可以很方便地设置快捷方式。
快捷键alt+q隐藏/显示图标,代码如下:
!q::
HideOrShowDesktopIcons()
return
HideOrShowDesktopIcons()
{
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%
}
;双击桌面右上角显示隐藏桌面图标
#Persistent
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
;~ 桌面Progman|WorkerW
GroupAdd, Desktop, ahk_class ExploreWClass
GroupAdd, Desktop, ahk_class WorkerW
WaitTime := DllCall("GetDoubleClickTime")/1000
;屏幕左上
x1:=0
y1:=0
;任务栏高度
WinGetPos,,,, h,ahk_class Shell_TrayWnd
;屏幕右下
x2:=A_ScreenWidth
y2:=A_ScreenHeight-h
OutputDebug %x2%,%y2%
#IfWinActive, ahk_group Desktop
~LButton::
KeyWait,LButton
KeyWait, LButton, d T %WaitTime%+200
If ! Errorlevel
{
MouseGetPos,x,y
OutputDebug %x%-%y%
;~ if (x<x1+10 and y<y1+10 ) ;屏幕左上角10*10见方。
;~ {
;~ OutputDebug 左上角
;~ HideOrShowDesktopIcons()
;~ }
if (x>x2-10 and y<y1+10 ) ;屏幕右上角10*10见方。
{
OutputDebug 右上角
HideOrShowDesktopIcons()
}
else if (x<x1+10)
{
OutputDebug 左边
;~ Run notepad
}
else if (y<y1+10)
{
OutputDebug 上边
;~ Run notepad
}
else if(x>x2-10)
{
OutputDebug 右边
;~ run calc
}
else if(y>y2-10)
{
OutputDebug 下边
;~ run calc
}
else
{
OutputDebug 其它
ToolTip %x%-%y%
Sleep,1000
ToolTip
}
}
return
HideOrShowDesktopIcons()
{
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%
}
新建一个文本文件,将代码复制进去,再将后缀改为.ahk即可,双击文件,即可实现快捷隐藏/显示桌面图标。可以将该文件放入文件自启动文件夹中,这样可以避免每次打开电脑都要重新双击它。使用win+r键打开运行窗口,输入shell:startup,在打开的文件夹中将此文件放入其中即可。
参考链接:链接