; 使用方法:
; 按住鼠标左键,再按右键1次则记录当前窗口id,给鼠标侧键XButton1隐藏或唤醒窗口1使用
; 按住鼠标左键,再按右键2次则记录当前窗口id,给鼠标侧键XButton2隐藏或唤醒窗口2使用
; 对桌面或者任务栏,按住鼠标左键,再按右键1次或2次。则清除隐藏唤醒功能,恢复原键

#if GetKeyState("LButton", "P")
RButton::
if (winc_presses > 0) {
  winc_presses ++
  Return
}
winc_presses = 1
SetTimer KeyWinC18, -400
Return

KeyWinC18:
if (winc_presses = 1) {
  MouseGetPos,,,WinID
  WinGetClass, WinClass, ahk_id %WinID%
  if (WinClass="Progman") || (WinClass="Shell_TrayWnd")
    XButton1WinID:=""
  else
    XButton1WinID:=WinID
} else if (winc_presses = 2) {
  MouseGetPos,,,WinID
  WinGetClass, WinClass, ahk_id %WinID%
  if (WinClass="Progman") || (WinClass="Shell_TrayWnd")
    XButton2WinID:=""
  else
    XButton2WinID:=WinID
} winc_presses = 0
Return
#if

*$XButton1::
if (XButton1WinID="") {
  Send {XButton1}
} else {
  if WinActive("ahk_id "XButton1WinID) {
    WinMinimize, ahk_id %XButton1WinID%
    WinActivate, ahk_class Shell_TrayWnd
  } else {
    WinRestore, ahk_id %XButton1WinID%
    WinActivate, ahk_id %XButton1WinID%
  }
}
Return

*$XButton2::
if (XButton2WinID="") {
  Send {XButton2}
} else {
  if WinActive("ahk_id "XButton2WinID) {
    WinMinimize, ahk_id %XButton2WinID%
    WinActivate, ahk_class Shell_TrayWnd
  } else {
    WinRestore, ahk_id %XButton2WinID%
    WinActivate, ahk_id %XButton2WinID%
  }
}
Return

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。