windows-10 - Autohotkey:当程序失去焦点时自动最小化程序
问题描述
我正在使用以下 Autohotkey 脚本 win 10 在程序失去焦点时自动最小化程序,但是即使我在同一个程序中打开子菜单或弹出选项,它仍然会最小化整个窗口。那么我怎样才能尊重该程序中的所有子窗口呢?或任何其他执行此操作的脚本。
#NoEnv
#Warn
var := true
SetTimer, subroutine, -1
return
subroutine:
WinWaitNotActive, ahk_exe word.exe
sleep, 2000
if (var) {
WinMinimize
SetTimer, subroutine, -1
}
return
!t::SetTimer, subroutine, % (var:=not var) ? -1 : "Off"
!x::ExitApp ; ALT+X terminates the script
解决方案
; autohotkey v1
#NoEnv
#Warn
#Persistent
SetTimer, subroutine, 5000
subroutine()
{
If WinActive("ahk_class Notepad++")
{
ToolTip, "notepad++ active"
}
else
{
WinMinimize, ahk_class Notepad++
ToolTip, "notepad++ not active auto minimize after 5 second"
}
}
; autohotkey v2
SetTimer "subroutine", 5000
subroutine()
{
If WinActive("ahk_class Notepad++")
{
ToolTip "notepad++ active"
}
else
{
WinMinimize "ahk_class Notepad++"
ToolTip "notepad++ not active auto minimize after a while"
}
}
推荐阅读
- r - 如何计算 R quosure 中的变量数?
- python - 我的代码在运行时会打印它之前的输出。我希望它只打印该特定计数所需的内容
- html - 为什么 table-layout: fixed 会影响父元素的宽度?
- html - 通过调用css中的类来更改父级中子级的字体颜色和高度
- c++ - 如何将使用 ExternalProject_Add 安装的库添加到目标包括
- sql - 时区 Rails Postgres
- java - 带有 DBRef 的 Mongo 文档
- ruby - 如何从 BasicObject 中访问 Ruby 类型名称
- javascript - 数组元素的依从性属性 i
- angular - 如何为电子邮件制作输入掩码?