我正在尝试创建两个不同的热键来启动一个应用程序的两个独立实例。当第二个实例打开时,窗口标题上会添加一个“[2]”,这对我来说非常有用。但它在我的以下代码中不起作用。例如,当我打开第二个实例时,不仅“[2]”没有出现,而且第一个实例“*没有前导数字”也不会启动。
怎样才能使用两个热键分别打开各自的窗口,而不互相依赖?
#1::
IfWinExist Total Commander (x64) 8.51a - NP
{
WinWait Total Commander (x64) 8.51a - NP
WinActivate
}
else
Run c:\Program Files\Total Commander\TOTALCMD64.EXE,,Max
{
WinWait Total Commander (x64) 8.51a - NP
WinActivate
}
Return
#2:: ; application title should show [2] weather the other is opened or not ; corrected indentation here
IfWinExist [2] Total Commander (x64) 8.51a - NP
{
WinWait [2] Total Commander (x64) 8.51a - NP
WinActivate
}
else
Run c:\Program Files\Total Commander\TOTALCMD64.EXE,,Max
{
WinWait [2] Total Commander (x64) 8.51a - NP
WinActivate
}
Return
答案1
我认为你的代码块有点偏离,试试这个:
tc_title:="Total Commander (x64) 8.51a"
tc_path:="c:\Program Files\Total Commander\TOTALCMD64.EXE"
#1::
IfWinExist %tc_title%
{
WinActivate %tc_title%
}
else IfWinNotExist %tc_title%
{
Run %tc_path%,,Max
WinWait %tc_title%
WinActivate
}
Return
#2::
IfWinExist [2] %tc_title%
{
WinActivate [2] %tc_title%
}
else IfWinNotExist [2] %tc_title%
{
Run %tc_path%,,Max
WinWait [2] %tc_title%
WinActivate
}
Return