- Posts: 161
- Thank you received: 13
3 Post Moderation Rule for New Boarders (25 Jan 2021)
New boarders will have their posts moderated - Don't worry if you cannot see your post immediately.
GUI scripting FCPX
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
27 Apr 2016 06:11 #76100
by nils.dettmann
GUI scripting FCPX was created by nils.dettmann
Hi,
I know this is more of a programming question but perhaps anybody has had the same problem.
I´m writing an apple script to facilitate some click and keypress intensive workflows in FCPX and everythings works [strike]fine[/strike] as espected but there is one problem.
I would like to select two files in the event browser at the same time.
I know the names and also the "GUI address" (from UI elements) and I can select one file at a time.
But I can´t manage to select two elements.
I had success setting the selection of one file with:
doesn´t work
Has anybody achieved selecting two or more files. I´m not neccessarily limited to applescript but it would nice being able to do it externally.
I know this is more of a programming question but perhaps anybody has had the same problem.
I´m writing an apple script to facilitate some click and keypress intensive workflows in FCPX and everythings works [strike]fine[/strike] as espected but there is one problem.
I would like to select two files in the event browser at the same time.
I know the names and also the "GUI address" (from UI elements) and I can select one file at a time.
But I can´t manage to select two elements.
I had success setting the selection of one file with:
Code:
select element
Code:
set selection ...
Code:
set attribute "AXSelected" of element ...
Code:
click element
doesn´t work
Has anybody achieved selecting two or more files. I´m not neccessarily limited to applescript but it would nice being able to do it externally.
Please Log in to join the conversation.
27 Apr 2016 12:39 #76107
by BenB
Replied by BenB on topic GUI scripting FCPX
You're talking about selecting multiple assets with one click? How would you tell FCPX specifically what media assets to select all at the same time? That would probably be an additional function that adds more keystrokes than Shift-Click or Command-Clicking to select multiple assets together.
Please Log in to join the conversation.
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 161
- Thank you received: 13
27 Apr 2016 12:44 #76109
by nils.dettmann
Replied by nils.dettmann on topic GUI scripting FCPX
I´m talking about setting two asssets in the event browser as selected from an apple script.
I have an array of rows in the event browser within the script.
I can select them one by one - all from within the script - but I can´t set multiple selections.
is a command within apple script and dosen´t refer to a physical mouse click.
I have an array of rows in the event browser within the script.
I can select them one by one - all from within the script - but I can´t set multiple selections.
Code:
click element
is a command within apple script and dosen´t refer to a physical mouse click.
Please Log in to join the conversation.
27 Apr 2016 17:10 #76126
by VidGreg
Replied by VidGreg on topic GUI scripting FCPX
Hi Nils
Getting very rusty with Applescript but this might give you some ideas.
As I remember, you first "Tell" whatever app to "set selected_items as selection"
then do what ever you want with first item in "selection"
then "repeat x in selected_items"
"end repeat"
"end tell"
OK very rusty, but the gist is that you have to create a selection of items, create script to do action, then repeat that action on next item, repeats till all items in selection have been acted on, then end repeat, end tell.
Sorry not more help, would need the entire script to run to figure out.
There are lots of Apple scripting sites out there. You also might see what Automator can do. You can always include Apple Script inside Automator.
Hope this helps, Greg
Getting very rusty with Applescript but this might give you some ideas.
As I remember, you first "Tell" whatever app to "set selected_items as selection"
then do what ever you want with first item in "selection"
then "repeat x in selected_items"
"end repeat"
"end tell"
OK very rusty, but the gist is that you have to create a selection of items, create script to do action, then repeat that action on next item, repeats till all items in selection have been acted on, then end repeat, end tell.
Sorry not more help, would need the entire script to run to figure out.
There are lots of Apple scripting sites out there. You also might see what Automator can do. You can always include Apple Script inside Automator.
Hope this helps, Greg
Please Log in to join the conversation.
27 Apr 2016 17:28 #76129
by BenB
Replied by BenB on topic GUI scripting FCPX
What is the specific goal trying to be achieved?
Please Log in to join the conversation.
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 161
- Thank you received: 13
27 Apr 2016 19:09 #76141
by nils.dettmann
Replied by nils.dettmann on topic GUI scripting FCPX
@Greg
Thanks Greg
Unfortunately FCPX doesn´t work together with applescript so easy natively.
So I have to fall back to GUI scripting where applescripts basically simulates user input.
I don´t know if you refered to that but if I create a group of the objects in question and try to select the group, applescript will still select one item after another and thus deselect all the other items when selecting a new one.
I know this is quite a special question and I also posted the question in programming forums but I thought this would be something coming up for anybody trying to develop workflow scripts for FCPX.
And I am using Automator to use the script as service and invoke it by a keyboard command.
@Ben
Right now the script batch syncs several video files to one audio file resulting in one synchronized clip per video file.
The starting timecode of each synchronized clip is set to the starting timecode of the corresponding video clip.
In the end the synchronized clip is cut down to the length of the corresponding video clip.
That sounds complicated, is it understandable?
Thanks Greg
Unfortunately FCPX doesn´t work together with applescript so easy natively.
So I have to fall back to GUI scripting where applescripts basically simulates user input.
I don´t know if you refered to that but if I create a group of the objects in question and try to select the group, applescript will still select one item after another and thus deselect all the other items when selecting a new one.
I know this is quite a special question and I also posted the question in programming forums but I thought this would be something coming up for anybody trying to develop workflow scripts for FCPX.
And I am using Automator to use the script as service and invoke it by a keyboard command.
@Ben
Right now the script batch syncs several video files to one audio file resulting in one synchronized clip per video file.
The starting timecode of each synchronized clip is set to the starting timecode of the corresponding video clip.
In the end the synchronized clip is cut down to the length of the corresponding video clip.
That sounds complicated, is it understandable?
Please Log in to join the conversation.
28 Apr 2016 06:16 #76151
by BenB
Replied by BenB on topic GUI scripting FCPX
OK, so how does the script know which clips to select?
Please Log in to join the conversation.
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 161
- Thank you received: 13
28 Apr 2016 07:13 #76154
by nils.dettmann
Replied by nils.dettmann on topic GUI scripting FCPX
In the current version it prompts me to select one audio and multiple video files.
It then selects the audio an one video file after another and syncs them.
A future version could parse a project or parse the timecode (eg. with an offset)
It then selects the audio an one video file after another and syncs them.
A future version could parse a project or parse the timecode (eg. with an offset)
Please Log in to join the conversation.
28 Apr 2016 10:14 - 28 Apr 2016 10:14 #76167
by lichinho
Replied by lichinho on topic GUI scripting FCPX
In AppleScript you can simulate the key modifiers by typing something like
using { command down }
e.g. assuming you can type
click element
to select, them you could add to that selection with something like:
click another_element using { command down }
It is a pity that FCP X does not have any decent support for AppleScript. One essentially has to try and mimick in the script the user interface events that trigger the application's behaviors, rather than talk to the application itself. It is quite limiting. But then again most of the use of the application is or should be of the creative, not repetitive kind, and that can hardly be scripted.
using { command down }
e.g. assuming you can type
click element
to select, them you could add to that selection with something like:
click another_element using { command down }
It is a pity that FCP X does not have any decent support for AppleScript. One essentially has to try and mimick in the script the user interface events that trigger the application's behaviors, rather than talk to the application itself. It is quite limiting. But then again most of the use of the application is or should be of the creative, not repetitive kind, and that can hardly be scripted.
Last edit: 28 Apr 2016 10:14 by lichinho.
Please Log in to join the conversation.
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 161
- Thank you received: 13
28 Apr 2016 12:03 #76168
by nils.dettmann
Replied by nils.dettmann on topic GUI scripting FCPX
I already tried to select with command down and key down command in many different variants.
And unfortunately the "click" command doesn´t work on rows within the event browser.
But I agree, it´s a real pity that FCPX doesn´t natively support applescript.
I think it could really grow it´s reputation especially in the field of shorter, vfx intensive productions where people already tend to be more open to FCPX.
The whole roundtrips a lot of people are asking for could be implemented easily.
And though I agree with you that the work should be mostly creative I constantly find myself and others doing repetitive tasks.
And unfortunately the "click" command doesn´t work on rows within the event browser.
But I agree, it´s a real pity that FCPX doesn´t natively support applescript.
I think it could really grow it´s reputation especially in the field of shorter, vfx intensive productions where people already tend to be more open to FCPX.
The whole roundtrips a lot of people are asking for could be implemented easily.
And though I agree with you that the work should be mostly creative I constantly find myself and others doing repetitive tasks.
Please Log in to join the conversation.
- nils.dettmann
-
Topic Author
- Offline
- Elite Member
-
Less
More
- Posts: 161
- Thank you received: 13
07 May 2016 22:25 #76476
by nils.dettmann
Replied by nils.dettmann on topic GUI scripting FCPX
A little update if anybody comes to the same point I am:
I came to the conclusion that what I wanted to achieve (selecting two rows in the event browser) with applescript is just not possible in an easy way.
My workaround ist to select the lower row then sending shift-downarrow to FCPX until the higher row is selected and finally deselecting all the rows in between.
I came to the conclusion that what I wanted to achieve (selecting two rows in the event browser) with applescript is just not possible in an easy way.
My workaround ist to select the lower row then sending shift-downarrow to FCPX until the higher row is selected and finally deselecting all the rows in between.
Please Log in to join the conversation.

