/* Library:
 *      Hide Desktop Icon
 * Description:
 *      Hide the desktop icon by double clicking the right mouse button
 * Warnning:
 *      None.
 * Version:
 *      v1.0.5
 * Author:
 *      泠音
 */

<!-- more -->

intInterval:=300
~RButton::
    If(A_PriorHotkey <> "~RBUtton" or A_TimeSincePriorHotkey > intInterval){
        KeyWait, RButton
        return
    }
If(check()){
    HideOrShowDesktopIcons()
    Sleep, 40
    Send, {Esc}
    return
}

check(){
    MouseGetPos,X,Y,ID,CLASS
    return CLASS=="SysListView321" 
        or CLASS=="SHELLDLL_DefView1"
        or CLASS==""
        or WinExist("ahk_class WorkerW" . " ahk_id " . CLASS)
}

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%
}