Edge浏览器怎么设置关闭最后一个标签时不关闭浏览器? 您所在的位置:网站首页 怎么关掉标签页 Edge浏览器怎么设置关闭最后一个标签时不关闭浏览器?

Edge浏览器怎么设置关闭最后一个标签时不关闭浏览器?

2024-02-27 14:56| 来源: 网络整理| 查看: 265

在网上看到一个新方案, ahk代码,原理是每次按下ctrl+w 时,先数一数浏览器(edge或chrome)现在有几个打开的标签页,如果只有一个的化,就不关闭它,而是转到主页。

比那些需要固定一个标签的方法都美观和优雅一些。 缺点是通过鼠标点叉叉关闭标签页还是会导致浏览器关闭。

#include winenum.ahk #ifwinactive ahk_exe chrome.exe ^w:: _number_of_tabs_in_this_chrome_window := WinEnum(WinExist("A")).length() if (_number_of_tabs_in_this_chrome_window=1) send !{home} else send ^w return #ifwinactive ahk_exe msedge.exe ^w:: _number_of_tabs_in_this_chrome_window := WinEnum(WinExist("A")).length() if (_number_of_tabs_in_this_chrome_window=1) send !{home} else send ^w return #if

winenum.ahk的代码

/* Function: WinEnum * Wrapper for Enum(Child)Windows [http://goo.gl/5eCy9 | http://goo.gl/FMXit] * License: * WTFPL [http://wtfpl.net/] * Syntax: * windows := WinEnum( [ hwnd ] ) * Parameter(s) / Return Value: * windows [retval] - an array of window handles * hwnd [in, opt] - parent window. If specified, EnumChildWindows is * called. Accepts a window handle or any string that * match the WinTitle[http://goo.gl/NdhybZ] parameter. * Example: * win := WinEnum() ; calls EnumWindows * children := WinEnum("A") ; enumerate child windows of the active window */ WinEnum(hwnd:=0, lParam:=0) ;// lParam (internal, used by callback) { static pWinEnum := "X" if (A_EventInfo != pWinEnum) { if (pWinEnum == "X") pWinEnum := RegisterCallback(A_ThisFunc, "F", 2) if hwnd { ;// not a window handle, could be a WinTitle parameter if !DllCall("IsWindow", "Ptr", hwnd) { prev_DHW := A_DetectHiddenWindows prev_TMM := A_TitleMatchMode DetectHiddenWindows On SetTitleMatchMode 2 hwnd := WinExist(hwnd) DetectHiddenWindows %prev_DHW% SetTitleMatchMode %prev_TMM% } } out := [] if hwnd DllCall("EnumChildWindows", "Ptr", hwnd, "Ptr", pWinEnum, "Ptr", &out) else DllCall("EnumWindows", "Ptr", pWinEnum, "Ptr", &out) return out } ;// Callback - EnumWindowsProc / EnumChildProc static ObjPush := Func(A_AhkVersion < "2" ? "ObjInsert" : "ObjPush") %ObjPush%(Object(lParam + 0), hwnd) return true }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有