Skip to main content
Inspiring
May 21, 2019
Question

Duplicate selected keyframe to position of mouse cursor in timeline?

  • May 21, 2019
  • 2 replies
  • 1812 views

I've been thinking about an easy way to duplicate keyframes to a position without moving the playhead or having to manually copy/pasta. I think it would be pretty simple in extendscript. So the script would essentially just duplicate the selected keyframe and move it to whatever position in time the mouse is at. Any ideas on how to get started with this one?

This topic has been closed for replies.

2 replies

ShaunreAuthor
Inspiring
May 21, 2019

That makes sense. So about the mouse cursor, the idea is that it's fewer steps. Rather than select the keyframe, copy the keyframe, move the playhead to where I want to paste the keyframe, and then paste the keyframe, I can simply select the keyframe I want to duplicate, point to where I want it to go in the timeline, and run the script.

Think of how you might alt+click and drag something to duplicate it, like in photoshop or something. This script is my idea for something that comes close to be being as easy.

Tomas B. aka Tom10
Inspiring
May 22, 2019

Thanks for a further explanation. I am pretty sure its not possible to achieve with plain scripting. Maybe, but just maybe, through SDK. Despite of that, here are few other questions, in case it might lead to different approach:

1. Can you elaborate the particular situation, where such copying of the keyframe value might take place? For example, lets say that we have keyframe value for position selected at [960,540] @0s. Would you use it to copy between keyframes which has different values? Or just to set the same value keyframe just further ahead in time? Hope this makes sense.

2. The thing is - since you would be pointing mouse in the timeline, it requires only a single mouse click, and then ctrl+c followed by ctrl+v. Sorry, I know its straightforward, but does it really make sense to assign a script to eliminate one extra combination click? Just curious!

The good thing about forums is that we all can share our different perspective - and learn from that. Happy to see what arguments you might posses!

Cheers!

BTW - if Dan says its most likely not possible, chances are high it is really not!

Martin_Ritter
Legend
May 24, 2019

Thanks for trying to understand. So, here's a good example of when you would use this. Let's say you want to do a simple fade in, fade out to a clip. So you might start at 0 seconds. You add an opacity keyframe. It's 100% though, which you'll need, but not right at the current place in time. Rather than drag it out where you need it, you leave the keyframe alone, and instead point in the timeline where you want it to go, say 2 seconds after the first keyframe. Then you use the script which is tied to a hotkey. Then, because you'll need another keyframe at 100%, you point towards the end of the clip, say 2 seconds before the end, and run the script again. Now, you're still at the beginning of the clip, at 0 secs because we didn't actually move anywhere, we just moved the mouse cursor. That first keyframe can now easily be adjusted. So you set it to 0% opacity, make sure it's selected, then point to the end of the clip, and run the script a final time. All keyframes are made, and you didn't even have to move the playhead or manually copy/paste.

It's not that it takes a long time to do it all manually, but it's basically a 4 second process vs a 10 second process.

If we can't do this using the mouse position, like you said, maybe there's a different approach we can take.

Thanks again for your help.

EDIT: By the way I just found this thread: How can I get current Mouse position via Javascript?

It's about illustrator, but I imagine it's similar in terms of scripting.


Scripts have no access to mouse position, as well as clicked panels or windows. Script can only "see" what is happening inside their window or panel.

You need to write an plugin through SDK to get the mouse position. Freeze up your C++ skills, if you are willing to.

Actual, there are some good scripts already available to speed up yourworkflow of basic tasks.

Keyboard (https://aescripts.com/keyboard/) puts shortcuts to everyday keyframe operations such like cloning, aligning, mirroring. Also creating fade in or fade out is just a matter of 2 keystrokes and a bit dragging if you don't want to use the standard duration of 10f.

About the opacity case, there is Autopacity (Autopacity) which lets you do the fade in and out on a highly automate level.

*Martin

Tomas B. aka Tom10
Inspiring
May 21, 2019

Hey Shaunre,

the easiest way of doing this behaviour, is to proceed as following:

1. Check if there are any keyframe(s) selected in selected property. If there are multiple keys, then you have to think whether it makes sense to copy/paste them.

2. When matching condition is reached, execute copy by line below:
     app.executeCommand(19); //Copy command
3. Make sure the property of value you are pasting to is selected:
     [yourProp].selected = true; //Setting property to be selected, depending on what type of prop it is.

4. Execute paste:
     app.executeCommand(20); //Paste command

Not really sure where you could use this, but hope this helps!

ShaunreAuthor
Inspiring
May 21, 2019

I was thinking of a "duplicate" sort of function rather than just copy/paste but I guess I don't mind too much. Most importantly, the paste needs to be applied to the time position of the mouse cursor, not the playhead. I'm planning to assign the script to a hotkey so the cursor would be free to point to wherever I need it, however I'm not even sure if it's possible to get the cursor position like that. Any ideas?

Tomas B. aka Tom10
Inspiring
May 21, 2019

By far as I know, there is no such direct option to 'duplicate', just like moving keyframe in the timeline. In both of those scenarios, what is needed, to get all of the attributes for the keyframe, then create new keyframe with the same interpolations, etc. This is the reason why copying/pasting is a lot easier to handle.

Now talking about the specific location where to paste it - can you explain the idea behind of using mouse cursor to reflect the location? Alone, I can hardly see this working - but wonder what might be specific use case scenario for this.