Autohotkey 从windows任务栏打开程序
我制作了一个脚本,可以简单地打开或激活特定的应用程序。Autohotkey 从windows任务栏打开程序,autohotkey,Autohotkey,我制作了一个脚本,可以简单地打开或激活特定的应用程序。 它工作得很好,但我有一个问题,当应用程序最小化到windows托盘。 热键激活Else语句部分,从而创建同一应用程序的另一个实例 !a:: If WinExist("ahk_exe Orzeszek Timer.exe") { WinActivate, ahk_exe Orzeszek Timer.exe } Else { Run, "D:\Portable\PortableApps\Orzeszek Timer\Orzesz
它工作得很好,但我有一个问题,当应用程序最小化到windows托盘。 热键激活Else语句部分,从而创建同一应用程序的另一个实例
!a::
If WinExist("ahk_exe Orzeszek Timer.exe")
{
WinActivate, ahk_exe Orzeszek Timer.exe
}
Else {
Run, "D:\Portable\PortableApps\Orzeszek Timer\Orzeszek Timer.exe"
}
Return
如果应用程序出现在系统托盘中,我需要脚本帮助来触发IF语句部分
非常感谢)试试这个
!a::
Process, Exist, Orzeszek Timer.exe
If (Errorlevel != 0) ; is running
{
WinGet, WinState, MinMax, ahk_exe Orzeszek Timer.exe
If (WinState = "") ; is minimized to tray
SendInput, #bo{Enter} ; Win+b activates the tray, o marks the icon of Orzeszek Timer
else
WinActivate, ahk_exe Orzeszek Timer.exe
}
else ; is NOT running
Run, "D:\Portable\PortableApps\Orzeszek Timer\Orzeszek Timer.exe"
return
如果程序有自己的热键来恢复窗口,请使用该热键而不是#bo{Enter}
编辑:
如果SendInput,#bo{Enter}
太快,无法恢复程序,请在要发送的键之间添加睡眠:
...
If (WinState = "") ; is minimized to tray
{
SendInput, #b ; Win+b activates the tray
; WinWaitActive, ahk_class Shell_TrayWnd
Sleep, 300
SendInput, o ; o marks the icon of Orzeszek Timer. Try first of all manually which letter marks the icon
Sleep, 300
SendInput, {Enter}
}
...
编辑2:
我下载了那个小型便携式应用程序,它正在我的系统上运行:
!a::
Process, Exist, Orzeszek Timer.exe
If (Errorlevel != 0) ; is running
{
WinGet, WinState, MinMax, ahk_exe Orzeszek Timer.exe
If (WinState = "") ; is minimized to tray
; SendInput, #bot{Enter} ; OR:
SendInput, #b{Enter}{Up}ot{Enter}
}
else ; is NOT running
Run, "D:\Portable\PortableApps\Orzeszek Timer\Orzeszek Timer.exe"
WinWait, Orzeszek Timer,, 10
If (!ErrorLevel)
{
WinActivate, Orzeszek Timer
WinWaitActive Orzeszek Timer,, 5
If (!ErrorLevel)
MouseMove, 150, 80, 0
}
return
编辑3:
如果在设置中未启用“始终在通知区域显示所有图标”选项,请尝试替换
SendInput, #bot{Enter}
与
用户3419297非常感谢您的脚本,它非常好用。我对它进行了一些修改以打开应用程序
!a::
Process, Exist, Orzeszek Timer.exe
If (Errorlevel != 0) ; is running
{
WinGet, WinState, MinMax, ahk_exe Orzeszek Timer.exe
If (WinState = "") {
SendInput, #bo{Right}{Enter}
Sleep, 500
CoordMode, Mouse, Window
MouseMove, 150, 80, 0
}
else
WinActivate, ahk_exe Orzeszek Timer.exe
}
else ; is NOT running
Run, "D:\Portable\PortableApps\Orzeszek Timer\Orzeszek Timer.exe"
return
脚本所依赖的应用程序只有一个小缺点被放在首位在windows托盘列表中。
当然,我总是可以重新定义{Right x}位置,但有没有更有效的方法来自动找到应用程序在托盘中的位置?终于奏效了!脚本中唯一缺少的部分是{Up}键,如Edit3中所指出的,这样系统托盘就可以进行搜索。所以现在我没有问题找到确切的钥匙。在我的情况下是这样的
SendInput, #b{Enter}{Up}tt
Sleep, 100
SendInput, {Enter}
我真不知道该怎么感谢你。你帮了我很多)最小化到系统托盘的窗口大多是隐藏窗口。如果WinExist和WinShow在WinActivate之前,请尝试在之前添加DetectThiddenWindows On。用户3419297感谢您的回复,我根据您的建议修改了代码。有一个变化。但是“显示”窗口不是应用程序本身,而是与应用程序本身相关的空窗口
在和上检测到Windows和WinShow ahk_exe或Zeszek Timer.exe必须是单独的行。如果这是脚本预期的与此脚本相关的空popapp窗口。还是我在这里做错了什么?为什么{Right}在#bo之后?如果没有其他图标的名称以o开头,o应在托盘上标记Orzeszek定时器的图标。首先手动尝试哪个字母标记图标(按Win+b,然后按o。如果图标未标记,请尝试其他字母,直到图标标记为止)。如果SendInput,#bo{Enter}
速度太快,无法还原程序,请参阅我编辑的答案。按Win+b后,windows托盘上的箭头会像应该的那样高亮显示,但按a-z中的任何键都会导致我的问题没有结果。请参阅我答案中的编辑3。
SendInput, #b{Enter}{Up}tt
Sleep, 100
SendInput, {Enter}