595076941@qq.com

设置显示或者隐藏MasterSeeker和Total Commander主窗口的快捷键的AutoHotkey脚本2026年4月8日

 

  ;======== 设置显示或者隐藏MasterSeeker和Total Commander主窗口的快捷键的AutoHotkey脚本2026年4月8日 =========

 

tcms

 

 

 

 

 

头像图标-fnos-飞牛NAS

 

 

 

 

;======== 设置显示或者隐藏MasterSeeker和Total Commander主窗口的快捷键的AutoHotkey脚本2026年4月10日 =========
; 2026年4月10日 修改代码,简化代码 窗口操作都改成用 ahk_class
; 此脚本从此行开始
; D:\app\RegHotkey\RegHotkey.ahk
; 鼠标右击AHK托盘图标显示菜单并提示所有快捷键
; AutoHotkey版本1.1
; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
; https://www.autoahk.com/archives/58891
; https://www.cnblogs.com/delphixx/p/19836312
;======== 强制自身以 ansi + 管理员权限 运行,编译此脚本时选择 ANSI 32位 =========
runwith("admin","ansi")
;-----------------------------------
; 多进程热键——快速响应随时中止 v2.1  By FeiYue
;
; 1、一般的多进程热键,每次按热键都会重新启动一个进程
;    这会造成热键响应延迟,和频繁启动、退出进程。
;    这个库利用线程叠加和双进程交替重启的设计解决了上述问题
;
; 2、Go.Go("标签名或函数名", 序号可省略)  启动子进程
;    Go.Go("清理标签或为空", 序号可省略)  停止子进程
;-----------------------------------
class Go {  ;// 类开始
init() {
	static h:=Go.init()
#NoEnv
#NoTrayIcon
#SingleInstance force
#MaxThreads 255
	if (A_Args.Length()>0)
	{
		Suspend, On
		flag:="Ahk_Sub"
		s:=RegExReplace(A_Args[1], "\s")
		this.WinKill(flag "[" s "]")
		r:=this.Menu_Go.Bind(this)
		Menu, MyMenu, Add, Run, % r
		Gui, %flag%: Add, Text, 0x80 -Wrap
		Gui, %flag%: Menu, MyMenu
		Gui, %flag%: Show, Hide, % flag "[" s "]"
		return
Ahk_SubGuiClose:
	Critical
	WinMenuSelectItem,,, 1&
return
} ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
else
{
	flag:="Ahk_Main"
	this.WinKill(flag)
	Gui, %flag%: Show, Hide, % flag
	OnExit(this.WinKill.Bind(this,"Ahk_Sub"))
	Menu, Tray, Icon
}
}
Menu_Go() {
	ControlGetText, s
	s:=Trim(s)
	if (s="Reload")
	{
		WinGetTitle, s
		this.RunAhk(RegExReplace(s,"Ahk_Sub\[|]"))
		ExitApp
	}
	if IsLabel(s)
		gosub, %s%
	else if IsFunc(s)
		%s%()
	loop
		Sleep, 60000
}
WinKill(flag) {
	DetectHiddenWindows, On
	WinGet, list, List, % flag " ahk_class AutoHotkeyGUI"
	loop % list
		IfWinExist, % "ahk_id " list%A_Index%
		{
			WinGet, pid, PID
			WinClose, ahk_class AutoHotkey ahk_pid %pid%,, 3
			IfWinExist,,, Process, Close, %pid%
		}
	DetectHiddenWindows, Off
}
RunAhk(s="") {
	if (A_IsCompiled)
		Run, "%A_ScriptFullPath%" /f %s%
	else
		Run, "%A_AhkPath%" /f "%A_ScriptFullPath%" %s%
} ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
; https://www.autoahk.com/archives/58891
; https://www.cnblogs.com/delphixx/p/19836312
; 一个进程叠加超过100个线程就切换另一个进程,原进程重启
Go(LabelOrFuncName="", index=0) {
	static arr:=[]
	DetectHiddenWindows, On
	SetFormat, IntegerFast, d
	index:=Floor(index), (!arr[index] && arr[index]:=[0,0])
		, ii:=Floor(arr[index][1]), jj:=Floor(arr[index][2])
		, tt:="Ahk_Sub[" index "_" jj "]"
	if (++ii>100)
	{
		IfWinExist, % tt
		{
			ControlSetText,, Reload
			WinClose
		}
		else
			this.RunAhk(index "_" jj)
		arr[index][2]:=jj:=!jj, ii:=1
			, tt:="Ahk_Sub[" index "_" jj "]"
	}
	arr[index][1]:=ii
	IfWinNotExist, % tt
	{
		this.RunAhk(index "_" jj)
		WinWait, % tt,, 3
	}
	IfWinExist, % tt
	{
		ControlSetText,, % LabelOrFuncName
		WinClose
	}
	DetectHiddenWindows, Off
}
}  ;// 类结束

; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
;======== 添加托盘图标右键菜单 =========
; 鼠标右击AHK托盘图标显示菜单并提示所有快捷键
; Menu, Tray, Add,按Alt+Z终止此脚本, ExitAppMenuHandler  ; 创建新菜单项.
; Menu, Tray, Add,双击Ctrl键2秒后关闭显示器屏幕电源, PowerOffDisplay   ; 创建新菜单项.
; Menu, Tray, Add,按Alt+空格键或者按Ctrl+Win键显示或者隐藏Maye Nano v5.5.1.260409, PowerOffDisplay
; 请在Maye Nano v5.5.1.260409中设置其他应用程序软件的快捷键热键
; Menu, Tray, Add,按F1键显示或者隐藏MasterSeeker, aaa  ; 创建新菜单项.
; Menu, Tray, Add,按~键显示或者隐藏Total Commander, bbb  ; 创建新菜单项.
; Hotkey,!z,ExitAppMenuHandler
; ExitAppMenuHandler()
; {
; ExitApp
; } ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
;======== 设置关闭显示器的快捷键为 双击 Ctrl键 =========
;   Control::
;   	if (A_PriorHotkey <> "Control" or A_TimeSincePriorHotkey > 400)
;   	{ KeyWait, Control
;   		return
;   	}
;   	; MsgBox 双击
;   	Go.Go("PowerOffDisplay")
;   return
;   PowerOffDisplay:
;   	Sleep,2000 ;暂停2秒,防止受键盘操作影响,关闭显示器后又立即开启。
;   	;~ 关闭显示器
;   	SendMessage, 0x112, 0xF170, 2,, Program Manager
;   return

; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
;======== 设置显示或者隐藏 MasterSeeker 主窗口的快捷键为 F1 键 =========
; (F1键位于键盘主键区Esc键右边)
; http://master-seeker.com/
F1::Go.Go("aaa")
aaa:
	DetectHiddenWindows,On
	SetTitleMatchMode,2
	; IfWinActive,ahk_class WindowsForms10.Window.8.app.0.218f99c
	WinGetPos, , ,MSOutWidth,MSOutHeight,ahk_class WindowsForms10.Window.8.app.0.218f99c
	;我不知道如何在Adventure v5.7.0或者SciTE4AutoHotkey中调试并查看变量的值,
	;所以在此处插入ToolTip语句用于显示变量的值,通过检查应用程序的窗口的宽度和高度从而判断窗口当前状态是否最小化。
	;ToolTip,窗口宽度:%MSOutWidth% 窗口高度:%MSOutHeight%
	if (WinActive("ahk_class WindowsForms10.Window.8.app.0.218f99c") and MSOutWidth>400 and MSOutHeight>400)
	{
		; WinHide,MasterSeeker 1.5.1 by DxCK
		WinMinimize,ahk_class WindowsForms10.Window.8.app.0.218f99c
		Go.Go()
		return
	}
	else
	{
		IfWinNotExist,ahk_class WindowsForms10.Window.8.app.0.218f99c
		{
			IfExist,D:\APP\MasterSeeker\MasterSeeker.exe
			{
				Run,D:\APP\MasterSeeker\MasterSeeker.exe
			}
			else
			{
				MsgBox,0,,找不到文件 D:\APP\MasterSeeker\MasterSeeker.exe,5
				ExitApp
			}
		}
		SetTimer,WinActivateMasterSeeker,Delete
		SetTimer,WinActivateMasterSeeker,500
	}
return
WinActivateMasterSeeker()
{
	WinShow,ahk_class WindowsForms10.Window.8.app.0.218f99c
	WinGet, WinMSID, ID,ahk_class WindowsForms10.Window.8.app.0.218f99c
	DllCall("SwitchToThisWindow", "UInt", WinMSID, "UInt", 1)
	WinActivate,ahk_class WindowsForms10.Window.8.app.0.218f99c
	; WinMove,ahk_class WindowsForms10.Window.8.app.0.218f99c,,0,0,A_ScreenWidth,A_ScreenHeight
	; WinMaximize,ahk_class WindowsForms10.Window.8.app.0.218f99c
	loop,3
	{
		WinMove,ahk_class WindowsForms10.Window.8.app.0.218f99c,,A_ScreenWidth/2,20,A_ScreenWidth/2-10,A_ScreenHeight-90
		; 注意: MasterSeeker 的搜索框控件的名是 Filename ,很奇怪,很神奇,
		; MasterSeeker 的搜索框控件不是类名 MasterSeeker 1.5.1 by DxCK7,也不是类名 Edit1
		; ControlFocus,In Directory,MasterSeeker 1.5.1 by DxCK
		; 设置输入焦点到窗口的指定控件上.
		ControlFocus,Filename,ahk_class WindowsForms10.Window.8.app.0.218f99c
		Sleep,100
	}
	ControlSend,Filename,{LControl Down}{LControl Down}a{LControl Up},ahk_class WindowsForms10.Window.8.app.0.218f99c
	SetTimer,WinActivateMasterSeeker,Delete
	Go.Go()
	return
}
; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
; https://www.autoahk.com/archives/58891
; https://www.cnblogs.com/delphixx/p/19836312
;======== 设置显示或者隐藏 Total Commander 11.01 主窗口的快捷键为 ~ 键 =========
;(~键位于键盘主键区Tab键正上方
; https://www.ghisler.com/
; Total Commander 11.01使用支持按照“拼音首字母”序列筛选过滤文件列表的增强版QuickSearch eXtended 2.2.7插件)
`::Go.Go("bbb")
bbb:
	DetectHiddenWindows,On
	SetTitleMatchMode,2
	; IfWinActive,ahk_class TTOTAL_CMD
	WinGetPos, , ,TCOutWidth,TCOutHeight,ahk_class TTOTAL_CMD
	;我不知道如何在Adventure v5.7.0或者SciTE4AutoHotkey中调试并查看变量的值,
	;所以在此处插入ToolTip语句用于显示变量的值,通过检查应用程序的窗口的宽度和高度从而判断窗口当前状态是否最小化。
	;ToolTip,窗口宽度:%MSOutWidth% 窗口高度:%MSOutHeight%
	if (WinActive("ahk_class TTOTAL_CMD") and TCOutWidth>400 and TCOutHeight>400)
	{
		WinMinimize,ahk_class TTOTAL_CMD
		Go.Go()
		return
	}
	else
	{
		IfWinNotExist,ahk_class TTOTAL_CMD
		{
			IfExist,D:\APP\TotalCMD\TotalCMD64.exe
			{
				Run,D:\APP\TotalCMD\TotalCMD64.exe
				Go.Go()
				return
			}
			else
			{
				MsgBox,0,,找不到文件 D:\APP\TotalCMD\TotalCMD64.exe,5
				ExitApp
			}
		}
		SetTimer,WinActivateTC,Delete
		SetTimer,WinActivateTC,500
	}
	Go.Go()
return
WinActivateTC()
{
	WinShow,ahk_class TTOTAL_CMD
	WinGet, WinTCID, ID,ahk_class TTOTAL_CMD
	DllCall("SwitchToThisWindow", "UInt", WinTCID, "UInt", 1)
	WinActivate,ahk_class TTOTAL_CMD
	WinMove,ahk_class TTOTAL_CMD,,0,0,A_ScreenWidth,A_ScreenHeight
	WinMove,ahk_class TTOTAL_CMD,,0,0,A_ScreenWidth,A_ScreenHeight
	WinMove,ahk_class TTOTAL_CMD,,0,0,A_ScreenWidth,A_ScreenHeight
	WinMaximize,ahk_class TTOTAL_CMD
	WinMaximize,ahk_class TTOTAL_CMD
	WinMaximize,ahk_class TTOTAL_CMD
	IfWinActive,ahk_class TTOTAL_CMD
	{
		SetTimer,WinActivateTC,Delete
		Go.Go()
		return
	}
}
; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
; https://www.autoahk.com/archives/58891
; https://www.cnblogs.com/delphixx/p/19836312
; ===============================================================
; 强制自身进程以 管理员权限 或 普通权限 或 ANSI 或 U32 或 U64 版本运行。
; 例1: runwith("admin","u32") 强制自身以 u32 + 管理员权限 运行。
; 例2: runwith("","ansi")     强制自身以 ansi 版本运行(权限不变)。
; 例3: runwith("normal")      强制自身以 普通权限 运行(版本不变)。
RunWith(RunAsAdmin:="Default", ANSI_U32_U64:="Default")
{
	; 格式化预期的模式 ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
	switch, RunAsAdmin
	{
		case "Normal","Standard","No","0":		RunAsAdmin:=0
		case "Admin","Yes","1":								RunAsAdmin:=1
		case "default":												RunAsAdmin:=A_IsAdmin
default:															RunAsAdmin:=A_IsAdmin
	}
switch, ANSI_U32_U64
{
	case "A32","ANSI","A":								ANSI_U32_U64:="AutoHotkeyA32.exe"
	case "U32","X32","32":								ANSI_U32_U64:="AutoHotkeyU32.exe"
	case "U64","X64","64":								ANSI_U32_U64:="AutoHotkeyU64.exe"
	case "default":												ANSI_U32_U64:="AutoHotkey.exe"
default:															ANSI_U32_U64:="AutoHotkey.exe"
	}
; 获取传递给 “.ahk” 的用户参数(不是 /restart 之类传递给 “.exe” 的开关参数)
for k, v in A_Args
{
	if (RunAsAdmin=1)
	{
		; 转义所有的引号与转义符号
		v:=StrReplace(v, "\", "\\")
		v:=StrReplace(v, """", "\""")
		; 无论参数中是否有空格,都给参数两边加上引号
		; Run       的内引号是 "
		ScriptParameters  .= (ScriptParameters="") ? """" v """" : A_Space """" v """"
	}
	else
	{
		; 转义所有的引号与转义符号
		; 注意要转义两次 Run 和 RunAs.exe
		v:=StrReplace(v, "\", "\\")
		v:=StrReplace(v, """", "\""")
		v:=StrReplace(v, "\", "\\")
		v:=StrReplace(v, """", "\""")
		; 无论参数中是否有空格,都给参数两边加上引号
		; RunAs.exe 的内引号是 \"
		ScriptParameters .= (ScriptParameters="") ? "\""" v "\""" : A_Space "\""" v "\"""
	}
}
; 判断当前 exe 是什么版本 ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
if (!A_IsUnicode)
	RunningEXE:="AutoHotkeyA32.exe"
else if (A_PtrSize=4)
	RunningEXE:="AutoHotkeyU32.exe"
else if (A_PtrSize=8)
	RunningEXE:="AutoHotkeyU64.exe"
; 运行模式与预期相同,则直接返回。 ANSI_U32_U64="AutoHotkey.exe" 代表不对 ahk 版本做要求。
if (A_IsAdmin=RunAsAdmin and (ANSI_U32_U64="AutoHotkey.exe" or ANSI_U32_U64=RunningEXE))
	return
; 如果当前已经是使用 /restart 参数重启的进程,则报错避免反复重启导致死循环。
else if (RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)"))
{
	预期权限:=(RunAsAdmin=1) ? "管理员权限" : "普通权限"
	当前权限:=(A_IsAdmin=1)  ? "管理员权限" : "普通权限"
	ErrorMessage=
	(LTrim
		预期使用: %ANSI_U32_U64%
		当前使用: %RunningEXE%
		预期权限: %预期权限%
		当前权限: %当前权限%
		程序即将退出。
	)
	MsgBox 0x40030, 运行状态与预期不一致, %ErrorMessage%
	ExitApp
}
else
{
	; 获取 AutoHotkey.exe 的路径
	SplitPath, A_AhkPath, , Dir
	if (RunAsAdmin=0)
	{
		; 强制普通权限运行 ; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
		switch, A_IsCompiled
		{
			; %A_ScriptFullPath% 必须加引号,否则含空格的路径会被截断。%ScriptParameters% 必须不加引号,因为构造时已经加了。
			; 工作目录不用单独指定,默认使用 A_WorkingDir 。
			case, "1": Run, RunAs.exe /trustlevel:0x20000 "\"%A_ScriptFullPath%\" /restart %ScriptParameters%",, Hide
default: Run, RunAs.exe /trustlevel:0x20000 "\"%Dir%\%ANSI_U32_U64%\" /restart \"%A_ScriptFullPath%\" %ScriptParameters%",, Hide
	}
}
else
{
	; 强制管理员权限运行
	switch, A_IsCompiled
	{
		; %A_ScriptFullPath% 必须加引号,否则含空格的路径会被截断。%ScriptParameters% 必须不加引号,因为构造时已经加了。
		; 工作目录不用单独指定,默认使用 A_WorkingDir 。
		case, "1": Run, *RunAs "%A_ScriptFullPath%" /restart %ScriptParameters%
default: Run, *RunAs "%Dir%\%ANSI_U32_U64%" /restart "%A_ScriptFullPath%" %ScriptParameters%
	}
}
ExitApp
}
}
; 我的腾讯QQ电子邮箱地址是:  595076941@qq.com
; https://www.autoahk.com/archives/58891
; https://www.cnblogs.com/delphixx/p/19836312
; 此脚本到此行结束
;-----------------------------------

 

  

 

 

 

 

 

https://www.autoahk.com/archives/58891

 

 

 

https://www.cnblogs.com/delphixx/p/19836312

 

posted @ 2026-04-08 16:38  QQ595076941  阅读(5)  评论(3)    收藏  举报
595076941@qq.com