Applescript for (re)starting Qlab

689 views
Skip to first unread message

jo...@1erang.nl

unread,
Jan 17, 2013, 10:50:17 AM1/17/13
to ql...@googlegroups.com
Hi,

I'm having some troubles with coming up with a good and reliable Qlab (re)start Applescript.

What I am looking for is this:
- It should start Qlab if it not already running
- It should clear all the cues in the currently open workspace, which are divided among multiple cuelists
(I cheated here a bit sometimes by just closing the workspace)
- The script should open with a clean open workspace (untitled workspace)

I can do all the parts but I can't find a perfectly working solution.

I've tried this for deleting cues:
- "close front workspace saving no", which does the trick, but I couldn't find the command for creating a new blank workspace so there is a problem with that
- You cannot delete the last remaining cue list, so after deleting the cue lists I have to switch to deleting the cues in the last cue list?

Hope someone can help me with this!
Would be much appreciated.



Lucas Krech

unread,
Jan 17, 2013, 11:00:54 AM1/17/13
to ql...@googlegroups.com
I'm confused. How is an apple script prefereble to "CMD-W CMD-N" or just CMD-N?

-L

Lucas Benjaminh Krech
Lighting and Video Artist

Twitter: lucaskrech
- - - - - - - - - - - - - - - - - - - - - - -
"As far as we can discern, the sole purpose of human existence is to kindle a light in the darkness of mere being."
~Carl Jung











--
Change your preferences or unsubscribe here:
http://groups.google.com/group/qlab
 
Follow Figure 53 on Twitter: http://twitter.com/Figure53

jo...@1erang.nl

unread,
Jan 17, 2013, 11:04:19 AM1/17/13
to ql...@googlegroups.com, des...@lucaskrech.com
Probably not.
But the control takes place using a webmanager from another computer, so I use the webinterface to start applescripts.
But I could send these keypresses using applescript, so this already fixed the problem that I didn't know how to open a new workspace.


Op donderdag 17 januari 2013 17:00:54 UTC+1 schreef Lucas Krech het volgende:

jo...@1erang.nl

unread,
Jan 21, 2013, 5:10:24 AM1/21/13
to ql...@googlegroups.com, des...@lucaskrech.com

#!/usr/bin/osascript 

do shell script "open -a /Applications/QLab.app --args -P default -no-remote"

delay 1

tell application "QLab"

close front workspace saving no

end tell

delay 1

tell application "System Events"

keystroke "n" using {command down}

end tell



This seems to do the trick.
Although I would like to remove the keystroke, because on my system every couple of minutes a Safari window is opened. If this happens at the same time it will mess my script up.
Anybody know the correct command to open a new workspace?
 

Op donderdag 17 januari 2013 17:04:19 UTC+1 schreef jo...@1erang.nl het volgende:

Rich Walsh

unread,
Jan 21, 2013, 8:18:25 AM1/21/13
to ql...@googlegroups.com
On 21 Jan 2013, at 10:10, jo...@1erang.nl wrote:

#!/usr/bin/osascript 

do shell script "open -a /Applications/QLab.app --args -P default -no-remote"

delay 1

tell application "QLab"

close front workspace saving no

end tell

delay 1

tell application "System Events"

keystroke "n" using {command down}

end tell



Using the command line to open QLab is overkill, and (as far as I can tell) the --args are passed to QLab (not processed by "open"), so are completely pointless.

What happens if QLab takes more than 1s to launch?

Far better to just do this:

tell application id "com.figure53.qlab.2" to activate

If QLab is open, it will come to the front. If it isn't, the script will wait while QLab launches and comes to the front. Using application ID also protects you against QLab being called something other than "QLab" – and will become important again when QLab 3 arrives and people have more than one copy of "QLab" on their machines…

To close all the open workspaces, regardless of how many there are:

tell application id "com.figure53.qlab.2"
repeat until (count workspaces) = 0
close front workspace without saving
end repeat
end tell

Again, another unnecessary delay here in your version: the script can't move on until QLab reports that it has closed the front workspace, so there's no point waiting 1s here. Even if you thought you had to wait for the workspace to close, how many realistically only take 1s to unload all their assets?!

Finally, to open a new workspace – and make sure this command is only sent to QLab, and not a random key command picked up by whatever happens to be frontmost:

tell application "System Events"
tell (first application process whose bundle identifier is "com.figure53.qlab.2")
click menu item "New Workspace" of menu "File" of menu bar item "File" of menu bar 1
end tell
end tell

This does, of course, require that you have "Access for assistive devices" enabled in your System Preferences.

There is NO AppleScript command to tell QLab to make a new workspace directly…

One has to wonder though why you don't just have a blank template and open that? Since you're not ever saving, it won't get changed. You could lock the file in the Finder – which makes it moderately harder to save. Or, if you are determined to use the command line, cp it first and open the copy (cp defaults to overwriting existing files).

Rich

jo...@1erang.nl

unread,
Jan 21, 2013, 11:23:30 AM1/21/13
to ql...@googlegroups.com
Hi Rich,

Thank you very much for your reply.
Really helpful! 
As you can see I'm not a expert, so your tips are much appreciated.

I'm using this at the moment:

tell application id "com.figure53.qlab.2" to activate


tell application id "com.figure53.qlab.2"

repeat until (count workspaces) = 0

close front workspace without saving

end repeat

open "Macintosh HD:Applications:XAMPP:xamppfiles:htdocs:narrowcasting:resources:blank_workspace.cues"

end tell


Unfortunately I have to run this script on a remote machine sometimes.
I'm using eppc for this.

I cannot send all the commands through eppc, for example "activate" does't work, and the closing of the workspaces also doesn't respond.

That's why I save the above applescript as a application on the remote machine and open it through eppc:

tell application "Finder" of machine "eppc://user:pass@ip_address" to open "Macintosh HD:Applications:XAMPP:xamppfiles:htdocs:narrowcasting:clean_qlab.app" 

After this I start sending commands to Qlab:

tell application "Qlab" of machine "eppc://user:pass@ip_address" etc.etc.
 
At the moment I put a delay between these 2 commands, because I cannot find out how to run this sequentially. 
Any tips how to remove the delay here and startin sending cues/commands to Qlab when the clean script is finished?



Op maandag 21 januari 2013 14:18:25 UTC+1 schreef Rich Walsh het volgende:

Rich Walsh

unread,
Jan 22, 2013, 8:20:17 AM1/22/13
to ql...@googlegroups.com
On 21 Jan 2013, at 16:23, jo...@1erang.nl wrote:

Unfortunately I have to run this script on a remote machine sometimes.
I'm using eppc for this.

I cannot send all the commands through eppc, for example "activate" does't work, and the closing of the workspaces also doesn't respond.

That's why I save the above applescript as a application on the remote machine and open it through eppc:

tell application "Finder" of machine "eppc://user:pass@ip_address" to open "Macintosh HD:Applications:XAMPP:xamppfiles:htdocs:narrowcasting:clean_qlab.app" 

After this I start sending commands to Qlab:

tell application "Qlab" of machine "eppc://user:pass@ip_address" etc.etc.
 
At the moment I put a delay between these 2 commands, because I cannot find out how to run this sequentially. 
Any tips how to remove the delay here and startin sending cues/commands to Qlab when the clean script is finished?

I'm not in a position to test eppc at the moment. I remember that "If the specified remote application is not running, you must run it", for example – and I also know that security changes in Snow Leopard made some scripting even harder (https://developer.apple.com/library/mac/#releasenotes/AppleScript/RN-AppleScript/RN-10_6/RN-10_6.html). You need to be logged in as the same (admin) user on both machines too, I think.

I don't think you can tell QLab to activate from cold on a remote machine; more likely you have to do something like:

set remoteMachine to "eppc://user:pass@ip_address"
set remoteSystemEvents to application "System Events" of remoteMachine
set remoteQLab to application id "com.figure53.qlab.2" of remoteMachine


using terms from application "System Events"
tell remoteSystemEvents
set qLabIsRunning to count (every process whose bundle identifier is "com.figure53.qlab.2")
end tell
end using terms from


if qLabIsRunning = 0 then tell remoteQLab to launch


tell remoteQLab to activate

As I say though, I can't test that. I have no idea why you wouldn't be able to tell remoteQLab to close workspaces… What are the errors coming back in AppleScript Editor?

I think the way to find out if clean_qlab.app has completed its tasks is to poll System Events on the remote machine to see if it's still running:

set remoteMachine to "eppc://user:pass@ip_address"
set remoteSystemEvents to application "System Events" of remoteMachine
set cleanQLabIsRunning to 1


using terms from application "System Events"
repeat until cleanQLabIsRunning = 0
tell remoteSystemEvents
set cleanQLabIsRunning to count (every process whose name is "clean_qlab.app")
end tell
if cleanQLabIsRunning ≠ 0 then delay 1
end repeat
end using terms from

Rich

jo...@1erang.nl

unread,
Jan 22, 2013, 9:54:53 AM1/22/13
to ql...@googlegroups.com
Thanks again!

"System Events" is a pain to call on a remote machine.
I cannot get it to work.

tell application "System Events" of machine "eppc://user:pass@ip"

keypress "n" using {command down}

end tell


Even this is giving an error "application isn't running".
I can give commands to Finder and other apps, but not System Events. Even when I'm using the same user login on both machines.

set remoteMachine to "eppc://user:pass@ip_address"
set remoteSystemEvents to application "System Events" of remoteMachine
set cleanQLabIsRunning to 1


using terms from application "System Events"
repeat until cleanQLabIsRunning = 0
tell remoteSystemEvents
set cleanQLabIsRunning to count (every process whose name is "clean_qlab.app")
end tell
if cleanQLabIsRunning ≠ 0 then delay 1
end repeat
end using terms from

This is giving the output "error "Can't make \"System Events\" into type integer." number -1700 from "System Events" to integer

 
 

Op dinsdag 22 januari 2013 14:20:17 UTC+1 schreef Rich Walsh het volgende:

Rich Walsh

unread,
Jan 22, 2013, 10:31:29 AM1/22/13
to ql...@googlegroups.com
Error -1700 is "bad parameter data or unable to coerce the data supplied" – although as you don't indicate where the error occurred it's hard to troubleshoot that…

Maybe System Events has to be started up too (the Finder is always running)? Try telling it to launch.

I can't test any of this with only one Mac to hand at the moment, so I can't help you any further. Google?

Rich

--
Change your preferences or unsubscribe here:
http://groups.google.com/group/qlab
 
Follow Figure 53 on Twitter: http://twitter.com/Figure53

Philipp Contag-Lada

unread,
Mar 16, 2015, 7:43:47 AM3/16/15
to ql...@googlegroups.com
Hello All!

I'm sorry to warm this up. But it seems the closest thread to my problem: 

I'm running an automated show in a museum. VLC and other programs won't let me use two screens the way I want. So it's QLab 2 with a wall clock triggered cue for both loops to start.

As Mac OSX and the used MacMini take a very long time to start up and recognize the connected screens putting the file "show.cues" into the startup objects of the computer causes the show to start to soon as the screens are not routed correctly yet. 

Putting in some wait time before opening the file fails because Apple script doesn't seem to be able to tell a " .cues" file to open correctly (I tried "tell application "finder" to open file "~/Desktop/show.cues" " and "tell application "QLab" to open file "~/Desktop/show.cues""  The first ends in finder generating the allert that it can't handle the Object, the second causes QLab to tell me that the file doesn't exist.


Any help anyone? Tank You very much!

Philipp Contag-Lada

unread,
Mar 16, 2015, 7:52:45 AM3/16/15
to ql...@googlegroups.com
And sorry for reposting my own bad. Of course if You use HFS syntax it works fine. 

Carry on.  ;]
Reply all
Reply to author
Forward
0 new messages