实现目标:要是软件没开的话,快捷键直接打开,要是开了,他不在最前窗口则会回到最前窗口,如果在最前窗口则最小化。
共四步
1.安装atuohotkey最新版本
2.新建一个文本文档,更改名字比如为为test.ahk, 但是要后缀名为ahk
3.使用记事本或其他文本编辑软件打开test.ahk,在其中输入如下代码。
4.右键test.ahk, 选择使用autohotkey打开。
致谢&参考脚本:本脚本根据uu2ww2发表的《AutoHotKey自定义快捷键启动最小化某个程序。》修改。
Activate(t)
{
IfWinActive ahk_exe %t%
{
WinMinimize
return
}
IfWinExist ahk_exe %t%
{
WinShow
WinActivate
return 1
}
return 0
}
ActivateAndOpen(t,p)
{
if Activate(t)==0
{
Run %p%
WinActivate
return
}
}
; 使用alt+E, 启动Everything. 若everything 没有启动则启动Everything,
; 若已经启动,但evrything窗口没有显示, 则显示everything窗口。
; 若Everything窗口已经显示, 则最小化Everything窗口。
; ActivateAndOpen第一个参数"Everything.exe"是Everything程序名称,可用Autohotkey自带的Window Spy工具
; 获取活动窗口的Title,Class,Process等参数,从而获取想要设置的程序名称, 状态栏中包含Everything中窗口将会被激活或者最小化。
; 第二个参数"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",则是启动程序的路径。
; 可根据需求设置其他的软件
; 再次感谢uu2ww2提供的脚本思路
!e::ActivateAndOpen("Everything.exe","C:\Program Files\Everything\Everything.exe")
!q::ActivateAndOpen("Chrome.exe","C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")