Hi !
New with autohotkey, I don't know why I didn't check it before ! It's brilliant !
I need help for what I'd like to achieve... I already spend hours by searching but... No luck.
I'm a musician, Cubase user. I ALWAYS forget to launch an application called asiolinktool when I load my current cubase project (I always load it by clicking on the cubase project saved file).
I'd like asiolinktool.exe to launch each time I lauch cubase... And if possible ... Only if asiolinktool.exe is not already running. (But first, just launching it at the same time I run cubase).
I made this :
#IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe
Run, C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
But when I run the .ahk script, it lauch immediatly asiolinktool.exe ! It's not exactly what I wished.... I'd like it to launch only if I lauch cubase !
If any one could help me... It would be nice... Thanks a lot !
PS : I went to read ifwinactive / exist documentation... And much more !
Loading a second app
Re: Loading a second app
Try the command Ifwinexist instead of the directive #ifwinexist (https://autohotkey.com/docs/commands/_IfWinActive.htm). The latter only affects context-sensitive hotkeys and hotstrings which you don't have in your script. The first is more like a normalif-statement which executes the next code line conditionally (or more lines by using code blocks {...} ).
To check constantly if Cubase is running, you could use SetTimer. But there are probably many of other ways...
Code: Select all
#Persistent
setTimer, checkCubase, 1000 ; check every second (1000 ms), if Cubase is running
return
checkCubase:
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe ; if Cubase is running...
IfWinNotExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe ; ... check if the tool is already running, if not...
Run, C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe ; ...run the tool
return
Re: Loading a second app
Great ! Excellent !
Works perfectly. Now, I'd like to close the script when cubase & asiolinktool are running...
I added this (But doesn't work !) :
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe, C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp
Or this :
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe
IfWinExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp
I don't find a logical AND to say "if cubase and asiolinktool are running, close the script.
I go to search......
Works perfectly. Now, I'd like to close the script when cubase & asiolinktool are running...
I added this (But doesn't work !) :
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe, C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp
Or this :
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe
IfWinExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp
I don't find a logical AND to say "if cubase and asiolinktool are running, close the script.
I go to search......
Re: Loading a second app
There are again many ways, but that might do it
A method with a logical and could work with the function version of Winexist(), I guess:
if WinExist("ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe") and WinExist("ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe")
Code: Select all
#Persistent
setTimer, checkCubase, 1000 ; check every second (1000 ms), if Cubase is running
return
checkCubase:
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe ; if Cubase is running...
IfWinNotExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe ; ... check if the tool is already running, if not...
{
Run, C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe ; ...run the tool
Sleep, 200
ExitApp ; now that both are running, exit
}
return
if WinExist("ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe") and WinExist("ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe")
Re: Loading a second app
But I would keep the script running (perhaps even adding it to startup), because if you have to start the script again to monitor Cubase, you might forget to start the script in the first place; and that might defeat the whole purpose of the script
If it supposed to work only once as soon as Cubase is running, you probably could get away with a simple Winwait instead of a timer.
Btw, that:actually works like a logical and...
If it supposed to work only once as soon as Cubase is running, you probably could get away with a simple Winwait instead of a timer.
Btw, that:
Code: Select all
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe
IfWinExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp
Re: Loading a second app
Yes ! Sure I'll load it on windows startup.
The problem is that I still see the autokey icon in the systray... Is it normal ? Doesn't it mean that the script is still running ?
I the space you add on the begining of line 2 & 3 important ?
The problem is that I still see the autokey icon in the systray... Is it normal ? Doesn't it mean that the script is still running ?
But look at my previous message ! That's what I did ! Aarrrh ! But ... Anyway... I've got the same behavior as with mine = it seems to still run.gregster wrote:Btw, that:actually works like a logical and...Code: Select all
IfWinExist ahk_exe C:\Program Files\Steinberg\Cubase 9.5\Cubase9.5.exe IfWinExist ahk_exe C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe ExitApp
I the space you add on the begining of line 2 & 3 important ?
Re: Loading a second app
The indentation is just to make clear how the ifs are stacked. And I saw your previous message, but results may vary depending on where you actually put that piece of code. I can test later if my (untested) script from above works. But if it starts the tool, I don't see how it could miss theExitApp.
But like I said, if you are starting the script via startup and only expect it to work the first time, Cubase is running, you could try WinWait:That should wait for Cubase to run and procede as soon as the Cubase window exists.
Edit: Changed the ahk_exe part for more flexibility.
But like I said, if you are starting the script via startup and only expect it to work the first time, Cubase is running, you could try WinWait:
Code: Select all
Winwait, ahk_exe Cubase9.5.exe ; Wait for Cubase
Run C:\Program Files (x86)\ASIOLinkPro\x64\asiolinktool.exe
ExitApp ; optional, if this the actual end of your script
Edit: Changed the ahk_exe part for more flexibility.
Last edited by gregster on 04 Feb 2018, 13:39, edited 1 time in total.
Re: Loading a second app
Does ahk_Exe work like that? I would have expected you'd need to just call it ahk_exe Cubase9.5.exe. What does Window Spy, which can be accessed by right-clicking the tray icon (by the system clock) of a running script, say the ahk_exe title would be on these programs?
I skimmed over the last several responses though. Might be other mistakes to address.
I skimmed over the last several responses though. Might be other mistakes to address.
Re: Loading a second app
ahk_exe Cubase9.5.exe should work, too, according to the docs: "...ahk_exe considers all processes with name or full path matching a given string." But the given paths seemed to work according to the OP... anyway, ahk_exe Cubase9.5.exe might be better: "...ahk_exe accepts a case-insensitive name or full path; for example, ahk_exe notepad.exe covers ahk_exe C:\Windows\Notepad.exe, ahk_exe C:\Windows\System32\Notepad.exe and other variations." (https://autohotkey.com/docs/misc/WinTitle.htm#ahk_exe)
Re: Loading a second app
Oh ! I didn't know winwait ! Yes ! That's even much better ! And so much simplier !
And the script stops as expected.
Thanks a lot ! Very nice ! I must dig autohotkey !
And the script stops as expected.
Thanks a lot ! Very nice ! I must dig autohotkey !
Who is online
Users browsing this forum: Bing [Bot] and 170 guests