trytell application id "com.figure53.QLab.4" to tell front workspaceset selectedCue to last item of (selected as list)set {theNumber, theName, theTarget, theStatus} to {q number, q list name, file target, running} of selectedCueif theStatus is true thenset theAction to "Stop "panic selectedCueelseset theAction to "Start"start selectedCueend ifif theTarget is missing value thenset theMessage to theAction & " | " & theNumber & " | " & theNameelseset theMessage to theAction & " | " & theNumber & " | " & theName & " | " & theTargetend ifend telldo shell script "echo `date '+%d-%m-%y %T'`\" | " & theMessage & "\" >> $HOME/Library/Logs/QLab.log"end try
--
Contact support anytime: sup...@figure53.com
Follow Figure 53 on Twitter: http://twitter.com/Figure53
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/CAFicLi%3DF3wOfggLEh7meOzYYDxtXjU%3DMLqHBbz%3DYWHp1d_YhZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
start time (real) : Time in the file where playback begins.
end time (real) : Time in the file where playback ends.
I trigger these cues via Hot Key in a Cue Cart.
I have tried reverse engineering some other Apple Scripts without much luck.
Would anyone be able to help draw up even the basics like getting qname and elapsed time of the selected cue so that I can adapt it further into a text file log?
Kind regards,
Ben
set userLogFilenameSuffix to " | Logged Events" -- Text to append to log file namesset userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)-- Grab the active cues (excluding this cue – well, all Script Cues – and cue lists / carts)
tell application id "com.figure53.QLab.4" to tell front workspace
set workspaceName to q number
set activeCueNames to q list name of cues whose running is true ¬and q type is not "Script" and q type is not "Cue List" and q type is not "Cart"set activeCueActionElapsed to action elapsed of cues whose running is true ¬and q type is not "Script" and q type is not "Cue List" and q type is not "Cart" -- These will be raw times in seconds: no formatting
end tell-- Grab the timeset logTime to do shell script "date " & quoted form of userFileTimestampFormat-- Get path to log fileset theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"-- Cycle through the cues to make a message for the logset theMessageList to {}set firstColumn to logTimerepeat with i from 1 to (count activeCueNames)set end of theMessageList to firstColumn & tab & item i of activeCueNames & tab & item i of activeCueActionElapsedif i = 1 then set firstColumn to tab -- Only log the time in the first row for each messageend repeatset currentTIDs to AppleScript's text item delimitersset AppleScript's text item delimiters to linefeedset theMessage to theMessageList as textset AppleScript's text item delimiters to currentTIDs-- Write to the logdo shell script "echo \"" & theMessage & "\" >> " & quoted form of theFilePath
Follow Figure 53 on Twitter: https://twitter.com/Figure53
User Group Code of Conduct: https://figure53.com/help/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/72a3cfe8-954f-44a2-afb4-100633e03738%40googlegroups.com.
It's really just the clip name and total elapsed duration (during that particular play) that i am after. Can you think of a better way of achieving this every time?
Which, barring some minor tidying up, seems to be exactly what you are requesting.
tell application id "com.figure53.QLab.4"
try
tell front workspace
set workspaceName to q number
set theactivecues to (count of (active cues as list))
if theactivecues > 0 then
set thelastcue to uniqueID of last item of (active cues as list)
set thecuename to q list name of cue id thelastcue
else
set thelastcue to ""
set thecuename to "NO CUES PLAYING "
end if
end tell
end try
end tell
tell application id "com.figure53.QLab.3"
try
tell front workspace
if notes of cue "LOG" = thelastcue then
return
else
set notes of cue "LOG" to thelastcue
--log routine here
if notes of cue "PREV" = "" then set notes of cue "PREV" to "0"
set notes of cue "THIS" to (do shell script "date +%s")
set theduration to ((notes of cue "THIS") as integer) - ((notes of cue "PREV") as integer)
set notes of cue "PREV" to notes of cue "THIS"
set userLogFilenameSuffix to " | Logged Events" -- Text to append to log file names
set userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;
(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)
set logTime to do shell script "date " & quoted form of userFileTimestampFormat
set theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"
set theMessageList to {}
set firstColumn to logTime
set theduration to tab & tab & tab & tab & tab & theduration
do shell script "echo \"" & theduration & "\" >> " & quoted form of theFilePath
set end of theMessageList to firstColumn & tab & thecuename
set currentTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to linefeed
set themessage to theMessageList as text
set AppleScript's text item delimiters to currentTIDs
-- Write to the log
do shell script "echo \"" & themessage & "\" >> " & quoted form of theFilePath
end if
end tell
end try
end tell
If you didn't want to use QLab 3 as the logger you can adapt the script, so that after running the first part which gets the info from QLab 4, as long as your logging app can store 3 variables you can use whatever you want.
(* STOP loggerRun this app alongside QLab to write a log file to the Desktop of how long Audio Cues had played for when they stop (rounded down to the nearest second)**** TO QUIT: close all workspaces (the app won't run if there aren't any)v0.9: 22/03/18 Rich Walsh (inspired by Mic Pool)-- ###FIXME### This has not been tested AT ALL beyond proving that it works in principal; there is no real error protection-- ###FIXME### Notifications don't work well when multiple cues stop at the same time-- ###FIXME### Action elapsed is affected by scrubbing, so is not a true reflection in general of how long a cue _played_ for-- ###FIXME### Build in detection that QLab is running to avoid trying to launch it-- ###FIXME### Notify why the app is quitting!<<< Last run with QLab 4.2, MacOS 10.12.6 >>> *)-- User-defined variablesset userLogFilenameSuffix to " | Logged Stops" -- Text to append to log file names
set userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)
set userNotificationsOn to true -- Set this to false if you don't want a notificationset userPollingInterval to 1 -- Set how many seconds between iterations (accuracy will be roughly ±userPollingInterval)-- Declarationsproperty dialogTitle : "STOP logger"-- Get setup detailstrytell application id "com.figure53.QLab.4" to tell front workspace to set workspaceName to q numberon errorreturn -- Quit if no workspace openend try
set theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"
set capturedAudioCueIDs to {}set capturedAudioCueElapses to {}-- Run the looprepeat
-- Get the latest news
try
tell application id "com.figure53.QLab.4" to tell front workspace
set latestAudioCueIDs to uniqueID of cues whose running is true and q type is "Audio"set latestAudioCueElapses to action elapsed of cues whose running is true and q type is "Audio"end tellon errorreturn -- Quit if no workspace openend try
-- Compare against the last capture and log accordingly
if latestAudioCueIDs ≠ capturedAudioCueIDs then
set logTime to do shell script "date " & quoted form of userFileTimestampFormat
repeat with i from 1 to count capturedAudioCueIDsif item i of capturedAudioCueIDs is not in latestAudioCueIDs thenset elapsedTime to makeMSS(item i of capturedAudioCueElapses)
tell application id "com.figure53.QLab.4" to tell front workspace
set stoppedCue to q list name of cue id (item i of capturedAudioCueIDs)end tellset theMessage to logTime & tab & stoppedCue & tab & elapsedTime
do shell script "echo \"" & theMessage & "\" >> " & quoted form of theFilePath
if userNotificationsOn then display notification stoppedCue & " stopped at " & elapsedTime with title dialogTitle subtitle "Event logged"end ifend repeatend if
-- Update the cache
set capturedAudioCueIDs to latestAudioCueIDsset capturedAudioCueElapses to latestAudioCueElapses
-- Wait…
delay userPollingInterval
end repeat-- Subroutines(* === TIME === *)on makeMSS(howLong) -- [Shared subroutine]set howManyMinutes to howLong div 60set howManySeconds to howLong mod 60 div 1return (howManyMinutes as text) & ":" & my padNumber(howManySeconds, 2)end makeMSS(* === TEXT WRANGLING === *)on padNumber(theNumber, minimumDigits) -- [Shared subroutine]set paddedNumber to theNumber as textrepeat while (count paddedNumber) < minimumDigitsset paddedNumber to "0" & paddedNumberend repeatreturn paddedNumberend padNumber(* END: STOP logger *)
On 22 Mar 2018, at 03:11, Ben Bull <benb...@gmail.com> wrote:Hi Mic and Rich,
Thanks for your reply and help so far.
I have actually taken ideas from both of you and now have it working pretty much how it needs to, which is great.Mic, you are right. All of my clips are triggered out of carts and (other than a transition fade) there is never more than one clip playing at a time.
I am now using Rich's script via Keyboard Maestro (Macro software) which is just running the script every second when Qlab is open and is the front window.
This is spitting out:
--
Contact support anytime: sup...@figure53.com
Follow Figure 53 on Twitter: https://twitter.com/Figure53
User Group Code of Conduct: https://figure53.com/help/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/147da1fb-054c-44be-a784-85b0768b9dd8%40googlegroups.com.
<Qlab GG - Ben B.zip>