关闭窗口
动作编号: 1187
动作名称: 关闭窗口
动作作用的对象: 任意窗口
动作热键: 无
动作鼠标手势: 下右(↓→)
动作说明: 关闭窗口(chrome 等特定窗口为关闭标签页)
动作截图:
动作内容: Cando|关闭窗口
执行如意的内置的标签 “关闭窗口”, 为如意内置动作
代码及详细解释:
利用鼠标手势 <下右>, 将鼠标下的窗口关闭, 特定窗口(如浏览器) 为发送 "^W" 来关闭标签页. 使用时需要手动关闭浏览器的对应手势(内置的或安装的扩展), 避免发生冲突. 下面的代码为内置的标签 "关闭窗口" 的代码.下右>
; 1187
关闭窗口:
;Tooltip % Windy_CurWin_Class
if (Windy_CurWin_Class = "Chrome_WidgetWin_1") or (Windy_CurWin_Class = "360se6_Frame") or (Windy_CurWin_Class = "SciTEWindow") or (Windy_CurWin_Class = "CabinetWClass" && (QTTabBar or buildNumber>22000)) or (Windy_CurWin_Class = "Photoshop") or (Windy_CurWin_Class = "notepad" && buildNumber>22000) or (Windy_CurWin_Class = "MozillaWindowClass") or (Windy_CurWin_ProcName ="uedit32.exe") or (Windy_CurWin_Class ="CASCADIA_HOSTING_WINDOW_CLASS") or (Windy_CurWin_Class ="XLMAIN") or (Windy_CurWin_Class ="OpusApp")
{
if (Windy_CurWin_Class = "CabinetWClass" && QTTabBar)
{
try tabNumber := QTTabBar.ActiveWindow.Tabs.Count
if (tabNumber = 1)
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
}
else if (Windy_CurWin_Class = "SciTEWindow")
{
SendMessage % TCM_GETITEMCOUNT:=0x1304,,, SciTeTabCtrl1, ahk_id %Windy_CurWin_id%
tabNumber := ErrorLevel
if (tabNumber = 1)
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
}
else if (Windy_CurWin_Class = "Chrome_WidgetWin_1")
{
if (Windy_CurWin_ProcName ="Code.exe")
{
WinActivate, Ahk_ID %Windy_CurWin_id%
sleep 20
Send ^{F4}
Return
}
else if (Windy_CurWin_ProcName ="chrome.exe")
tabNumber := JEE_ChromeGetTabCount(Windy_CurWin_id)
else if (Windy_CurWin_ProcName ="edge.exe")
tabNumber := JEE_edgeGetTabCount(Windy_CurWin_id)
if (tabNumber = 1)
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
}
else if (Windy_CurWin_Class = "360se6_Frame")
{
if instr(Windy_CurWin_Title, "新标签页 - 360安全浏览器")
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
WinActivate, Ahk_ID %Windy_CurWin_id%
sleep 20
Send ^w
return
}
else if (Windy_CurWin_ProcName ="uedit32.exe")
{
tabNumber := JEE_UeditTabCount(Windy_CurWin_id)
if (tabNumber = 1)
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
WinActivate, Ahk_ID %Windy_CurWin_id%
sleep 20
Send ^{F4}
Return
}
else if (Windy_CurWin_Class = "notepad" && buildNumber>22000)
{
WinGet, OutputVar, ControlList, ahk_id %Windy_CurWin_id%
if !instr(OutputVar, "RichEditD2DPT2")
{
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return
}
}
else if (Windy_CurWin_Class = "CASCADIA_HOSTING_WINDOW_CLASS")
{
WinActivate, Ahk_ID %Windy_CurWin_id%
sleep 20
Send ^+w
return
}
WinActivate, Ahk_ID %Windy_CurWin_id%
sleep 20
Send ^w
}
else if (Windy_CurWin_Class = "Progman") or (Windy_CurWin_Class = "WorkerW") or (Windy_CurWin_Class = "Shell_TrayWnd")
{
WinClose ahk_class Progman
}
else
PostMessage, 0x112, 0xF060,,, ahk_id %Windy_CurWin_id%
return