用 WinActive() 匹配任何 0-9 数字

Match any 0-9 number with WinActive()

我有一个 AutoHotkey 脚本,它使用 If WinActive("WFC-16 - Windows Internet Explorer")

检查活动的 window 标题

我需要更改它以匹配任何 2 位数字。 IE。 If WinActive("WFC-## - Windows Internet Explorer").

我可以使用 RegEx-like 修饰符来匹配使用 WinActive() 的任何 0-9 数字吗?

是的,我没有发现任何问题。

SetTitleMatchMode RegEx
If WinActive("^WFC-\d\d - Windows Internet Explorer")
…

我建议您删除 « - Windows Internet Explorer» 后缀并添加 ahk_exe iexplore.exe,因为不同的 IE 版本在标题中有不同的名称。

SetTitleMatchMode RegEx
If WinActive("^WFC-\d\d ahk_exe iexplore.exe")
…

如果难以为标题匹配编写特定规则(或者如果规则变得太复杂),另一种方法是获取活动 window 的标题并对其进行任何测试:

WinGetTitle wintitle, A
If (wintitle~="^WFC-\d\d") ; ~= is a shortcut for RegexMatch
…