运行 程序或 activate/toggle 的热键
Hotkey to run program or activate/toggle
我是 autohotkey 程序的新手,但我喜欢它的所有功能。
我正在寻找创建一个热键来打开一个程序(如果它还没有打开)但它打开以激活 window。
我已经尝试了以下方法,但它似乎不起作用。
^+e::
#IfWinExist, ahk_class XLMAIN ahk_exe EXCEL.EXE
{
WinActivate ahk_class XLMAIN ahk_exe EXCEL.EXE
}
return
#IfWinExist
#IfWinNotExist, ahk_class ahk_class XLMAIN ahk_exe EXCEL.EXE
{
run C:\Program Files\Microsoft Office\Office16\EXCEL.EXE
}
#IfWinNotExist
return
此外,您能否确认鼠标位置是否在双屏或 windows 10 上不起作用?
非常感谢任何帮助,非常感谢!
三件事:
- 我修正了代码的语法和逻辑。请尽量避免使用 #If 语句(特别是如果您是新手),因为它们往往会破坏脚本。
- 不要同时为 IfWinActive 使用 ahk_class 和 ahk_exe,因为那样会是多余的(并且就我而言是无用的我知道)。
- 仔细检查 EXCEL.EXE 的位置是否与您在脚本 (
C:\Program Files\Microsoft Office\Office16\EXCEL.EXE
) 中所说的位置一致,因为在我的计算机上它位于 C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
.
这是对我有用的代码:
^+e::
IfWinExist, ahk_exe EXCEL.EXE
{
WinActivate ; Automatically uses the window found above.
WinMaximize ; same
Send, Some text.{Enter}
return
}else{
run C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
}
return
我是 autohotkey 程序的新手,但我喜欢它的所有功能。 我正在寻找创建一个热键来打开一个程序(如果它还没有打开)但它打开以激活 window。 我已经尝试了以下方法,但它似乎不起作用。
^+e::
#IfWinExist, ahk_class XLMAIN ahk_exe EXCEL.EXE
{
WinActivate ahk_class XLMAIN ahk_exe EXCEL.EXE
}
return
#IfWinExist
#IfWinNotExist, ahk_class ahk_class XLMAIN ahk_exe EXCEL.EXE
{
run C:\Program Files\Microsoft Office\Office16\EXCEL.EXE
}
#IfWinNotExist
return
此外,您能否确认鼠标位置是否在双屏或 windows 10 上不起作用?
非常感谢任何帮助,非常感谢!
三件事:
- 我修正了代码的语法和逻辑。请尽量避免使用 #If 语句(特别是如果您是新手),因为它们往往会破坏脚本。
- 不要同时为 IfWinActive 使用 ahk_class 和 ahk_exe,因为那样会是多余的(并且就我而言是无用的我知道)。
- 仔细检查 EXCEL.EXE 的位置是否与您在脚本 (
C:\Program Files\Microsoft Office\Office16\EXCEL.EXE
) 中所说的位置一致,因为在我的计算机上它位于C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
.
这是对我有用的代码:
^+e::
IfWinExist, ahk_exe EXCEL.EXE
{
WinActivate ; Automatically uses the window found above.
WinMaximize ; same
Send, Some text.{Enter}
return
}else{
run C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
}
return