Im trying to check if an application is open via an AppleScript
This is the following code :
on run {input, parameters}
quit application "KeyboardViewer"
return input
end run
However I want it to check if KeyboardViewer is open in the first place, if it is then quit application, if not, then launch it. In a way, the code should toggle the application.
I am not familiar with coding for AppleScript (first timer here) so I would appreciate some insight.
Thanks
edit
I have been trying to work with it and this seems to work, is there a more efficient way ? I would like to see your inputs please
on run {input, parameters}
if application "KeyboardViewer" is running then
quit application "KeyboardViewer"
else
activate application "KeyboardViewer"
end if
return input
end run
There is a small (less than 1s) delay when using this script. Is there a way to make it faster ?
This seems to work :
What I learned is that
if application "APPLICATION NAME" is runningchecks if the application is open.