-
Export markers CS6 autohotkey – now with marker durations
Hi everyone!
Thanks to this thread, my recent need for a markers exporter for Premiere CS6 was met. However, I was using markers for sections of the edit, so with marker durations, and I wanted to export this data too.
Having played around with Ed Elliott’s script, I finally managed to do it. The method is rather hacky, as Premiere won’t let autohotkey read the value of the Duration field until it’s been clicked on (and thus is editable), so I have to grab control of the mouse and click this field (with a couple of waiting periods for Premiere to respond).
Confusingly, this click changes the names of the other fields (from Edit 3 and Edit 4 to Edit 4 and Edit 5). Also I’ve used coordinates for the mouse to click on without checking them, which I know is bad form and could break the script in a different resolution.
Another thing I added is a line of column labels at the start of the string, as I found it helpful.
Here’s the code:
; Copies to Clipboard the marker time, duration, name, and comments from all markers in all Premiere Timeline sequences.
; If the sequence is not in the Timeline, the marker data will not be copied.
; (Versions of this script for pre-CS6 versions of Premiere only worked with sequence markers, not clip markers. CS6 eliminated the distinction between sequence, clip, and numbered/unnumbered
; markers but there may be lingering references in this script to "sequence" markers.); Paste this script into a text file with the file extension .ahk (e.g., PremiereMarkers.ahk). Install free AutoHotKey from autohotkey.com. Windows only, not Mac.
; Start Premiere and load your project. Edit > Keyboard Shortcuts... > Edit Marker = Ctrl+Alt+Shift+F12 (one time manual update). <<<<<<<<<<<<<<<<<<<< IMPORTANT <<<<<<<<<<<<<< ; Double-click on the .ahk file. Do not change the focus by interacting with other programs while the script is running. ; Fragility: ; o Relies upon some standard keyboard shortcuts. ; o NEW: Uses a numerical co-ordinate for the Duration box without checking it - this may not work on other monitor resolutions ; o Requires that the user manually create a keyboard short cut to set the Edit Marker shortcut to Ctrl+Alt+Shift+F12. ; o Locates the Marker Name and Marker Comment by their class names Edit4 and Edit3 within the Marker dialog box. Testing with the French version of Premiere indicates ; that these names do NOT vary by language. NEW - using the click method to grab the duration changes the classnames around in the dialog box - making them Edit 1, Edit 4 and Edit 5 ; o Is language sensitive. The Marker dialog box is found by looking for "Marker". This is probably the only line which needs to change for non-English versions of Premiere. ; o Tested with CS6 (use PremiereMarkers.ahk for prior versions because the Adobe default keyboard shortcuts are different than CS6). ; o Unrelated utilities may interfere with clipboard operations and may cause this script to fail. For example I manually turned off ; the "Add Multi-Text Clipboard" option in MultiMonitor TaskBar Version 2.1 because of its interference with other programs which ; perform clipboard operations. I don't recall whether it interfered with this script but I know it has interfered with at least one ; of my custom programs which uses the clipboard so I leave that option turned off. ; I was unable to figure out how to extract the name of the sequence so the extracted data just shows Sequence0001, Sequence0002, etc. ; One way of documenting the sequence name is to manually create a marker at 00:00:00:00 with the sequence name in the Marker Name field. ; The script does not do anything special with the marker at 00:00:00:00. ; In addition to researching getting the sequence name from the Timeline, I also researched: ; o retrieve it by opening various panels (e.g., the Info panel) but there are no edit controls from which to retrieve the name, ; o retrieve it from the Project panel, but there is no "Reveal in Project" command for sequences like there is for a clip. ; One possibility which I did not explore was copying the graphical image of the sequence name from the Timeline. ; Perhaps this is not important, but I was also unable to figure out how to make the left-most sequence be Sequence0001. ; The numbering depends upon what was the last sequence selected in the Timeline before the script began executing. Sequence0001 will be sequence after sending a Shift+3 keysroke. ; So, if you want Sequence0001 to correspond to the left-most sequence, select the right-most sequence before running the script. The remaining sequences ; will be numbered in left-to-right order. Addendum: This is not necessarily true for CS6 -- the Shift+3 shortcut does not necessarily proceed left to right and then wrap back to the leftmost. ; Be careful when making changes. When in doubt, throw in extra whitespace (e.g., WinExist(stringMarker) does not ; produce the same result as WinExist( stringMarker )). Sometimes capitalization is important (e.g., AND rather than and). The difference between = and := ; is significant as is the way variables are referenced (variable vs. %variable%). None of these subtleties will generate a compiler error -- just a different result. ;********************Change Log *************************************** ; 2011.08.28 Fixed bug where output Name & Comment were always empty. ; 2011.08.28 Enhancement: Sequence0001 is always the left-most sequence in the Timeline, rather than the user having to remember to select a particular sequence before starting the script. ; 2011.10.01 Reversed the above enhancement, i.e., went back to the original logic because Premiere > Window > Timeline sorts sequences in alphabetical order,
; so selecting the first sequence in Window > Timeline does not get the left-most sequence in the Timeline as was intended by the 2011.08.28 change. And the other downside to
; the enhancement was that it depended upon Alt+ keyboard shortcuts, which made the script more language dependent.
; 2011.10.01 Added "Marque " for French version of Premiere. That line is presently commented out. Testing with the French version indicates that this is the only change required; that is,
; the Premiere keyboard shortcuts and low-level technical stuff like the naming of Windows "controls" ("Edit3" and "Edit4") is identical between the English version and the French
; version. Hopefully this is true for the other non-English versions of Premiere.
; 2011.10.01 Revised logic so that CTI time is extracted correctly independent of the Premiere language version.
; 2011.12.15 Handle numbered markers in addition to handling unnumbered markers (instead of looking for "Marker @", just look for "Marker" because numbered Markers
; look like "Marker 20 @" -- the marker number caused the old logic to not recognize the Marker dialog box.)
; 2012.05.01 Revised extraction of marker time to handle the different time formats supported by Premiere, e.g., feet and frames now appears as "2+19" rather than the previous versions' "arker @ 2+19".
; 2012.10.26 Changes for CS6. This version of the script will NOT work with versions prior to CS6.
; 2012.10.26 Fixed long-existing bug where the script will terminate prematurely when the first sequence processed has only one marker. A side effect of this change is that in the unlikely event that
; the markers for only one sequence are being exported and that sequence has only one marker, two marker records will be output. This scenario is so unlikely and the consequence so trivial
; that I decided not to invest time in a solution.
; 2013.10.01 Modified to gather marker duration data too, and to add column titles at the start of the clipboard data.
;********************End Change Log ***********************************#SingleInstance force ; Skips the dialog box and replaces the old instance of this script automatically
#NoEnv ; Recommended. Undefined variables (%xxxx%) do not cause a search of Environment variables.SetTitleMatchMode 1 ; Must start with
SetTitleMatchMode faststringMarker := "Marker" ; Beginning of title of the Marker dialog box. Used to find the dialog box.
; If you are running a non-English version of Premiere, you need to change the text inside the quotes. Hopefully, this is the only change required.
; stringMarker := "Marque" ; For the French version of Premiere, remove ; to activate this line of code.if WinExist( stringMarker ) ; just in case the user left a marker dialog box open
WinCloseClipboard := "" ; so there's no risk of having left overs in Clipboard in case script does not complete successfully
clipboardEntries = 0 ; workaround for premature termination which occurs when the first sequence processed has only one markerif WinExist("ahk_class Premiere Pro")
{
WinActivate ; give focus to Premiere
Send +3 ; Shift+3 - activate Timeline. If Timeline was already active, activate next Sequence.
firstMarkerTitle := "" ; for determining when we're done
firstMarkerName := ""
firstMarkerComment := ""
countSequence = 1 ; for labeling sequences
stringClipboard := "" ; for accumulating the text which will be placed in Clipboard. The limit is 64KB (not tested).
stringClipboard = Sequence name%A_Tab%Marker In%A_Tab%Marker Duration%A_Tab%Marker Name%A_Tab%Marker Comment`r`n
doneWithAllSequences = 0
While ( doneWithAllSequences = 0 ) ; for each Sequence
{
Send {Home} ; move to beginning of Timeline
; The following two lines find the first marker of the sequence, if any -- regardless of whether there is a marker at 00:00:00:00 or not.
Send +m ; Shift+M move to 1st Marker after 00:00:00:00, if there is one; otherwise, stay at 00:00:00.
Send ^+m ; Ctrl+Shift+M move to marker at 00:00:00:00 if it exists; otherwise stay at first marker after 00:00:00:00; if no markers, stay at 00:00:00:00.
priorMarkerTitle := "" ; for determining right-most marker in a sequence
doneWithThisSequence = 0
While ( doneWithThisSequence = 0 ) ; for each Marker
{
Send ^!+{F12} ; Ctrl+Alt+Shift+F12 to open marker dialog box. This is a user-defined shortcut, i.e., not an Adobe default.
waitForDialogBox = 0
iterations = 0
while ( waitForDialogBox <> 1 AND iterations < 5) ;max wait = 5 * 200ms = 1 second if WinExist( stringMarker ) waitForDialogBox = 1 else { sleep 200 iterations += 1 } if WinExist( stringMarker ) { WinGetTitle, markerTitle ;get Marker dialog box title ("Marker @ 00;00;00;00" for unnumbered marker or "Marker n @ 00;00;00;00" for numbered markers, where n can be 0 thru 99) MouseMove, 253, 80, 0 Sleep, 100 Click Sleep, 100 WinGet, Controls, ControlList, A ;get Names's of all controls in Marker dialog box markerDuration := "" markerName := "" markerComment := "" Loop, Parse, Controls, `n ;loop thru all of the controls of the Marker dialog box { if ( A_LoopField = "Edit1" ) ;marker Duration { ; ControlGetPos, edit1X, edit1Y, edit1W, edit1H, %A_LoopField% ControlGetText, markerDuration, %A_LoopField% StringReplace, markerDuration, markerDuration, ", ', All ; replace double quotes with single quote so pasting to spreadsheet will work correctly } else if ( A_LoopField = "Edit5" ) ;marker Name { ControlGetText, markerName, %A_LoopField% StringReplace, markerName, markerName, ", ', All ; replace double quotes with single quote so pasting to spreadsheet will work correctly } else if ( A_LoopField = "Edit4" ) ; marker Comments { ControlGetText, markerComment, %A_LoopField% StringReplace, markerComment, markerComment, ", ', All ; replace double quotes with single quote so pasting to spreadsheet will work correctly } } WinClose ; Close the Marker dialog box. We'll WinWaitClose below to make sure that it's closed, but in the meantime let's do some processing... if ( markerTitle = firstMarkerTitle AND markerName = firstMarkerName AND markerComment = firstMarkerComment AND clipboardEntries > 1 ) ; we've probably (not 100% sure) processed all sequences
{
doneWithAllSequences = 1 ; we've looped around back to the very first marker. Perform final actions and terminate.
doneWithThisSequence = 1
}
else
{
if ( firstMarkerTitle = "" ) ; prepare for detecting when we've processed all markers in all sequences
{
firstMarkerTitle := markerTitle
firstMarkerName := markerName
firstMarkerComment := markerComment
}
if ( markerTitle = priorMarkerTitle ) ; we're reprocessing the right-most marker of the sequence
doneWithThisSequence = 1 ; move on to next Sequence
else
{
priorMarkerTitle := markerTitle ; prepare for next iteration and determining when we've processed the right-most marker of a sequence
; Valid marker. Append sequence id, CTI, Name, & Comment to clipboard string.
sequenceName := SubStr("000"countSequence, -3)
if ( positionAtSign := InStr(markerTitle,"@"))
StringRight, markerTime, markerTitle, StrLen(markerTitle) - positionAtSign
else
StringRight, markerTime, markerTitle, 11 ; Defensive programming: we should never hit this code because there should alway be an @ -- but maybe it is a different character in non-English versions of Premiere.
stringClipboard = %stringClipboard%Sequence%sequenceName%%A_Tab%%markerTime%%A_Tab%%markerDuration%%A_Tab%"%markerName%"%A_Tab%"%markerComment%"`r`n
clipboardEntries += 1
}
}
WinWaitClose ; wait for Marker dialog box to close
Send +m ; Shift+M - move to next Marker
}
else ; no markers in this sequence
{ ; Do not remove parentheses. It should work correctly without parentheses but it does not (2012.10.26).
doneWithThisSequence = 1 ; move on to next Sequence
}
} ; end While ( doneWithThisSequence = 0 )
Send +3 ; next Sequence (Shift+3)
countSequence += 1
} ; end While ( doneWithAllSequences = 0 )
clipboard := stringClipboard
MsgBox The list of markers has been placed in the Clipboard. Paste into spreadsheet, word processor, or database. The separator is a tab.
}
else MsgBox ,0,Error,Cannot locate Premiere window
ExitOne other thing to mention is that Ed’s script wasn’t working for me at all initially, till I checked my shortcuts. It seems Ctrl Alt M was set to delete marker for me, rather than Previous Marker, so if the script runs through your timeline deleting markers, check this setting!
So, I don’t know if anyone else will find this useful (and I don’t guarantee it’ll work!) but I thought I’d share it just in case.
Sorry, there were no replies found.