Rename clips on several tracks
After getting the mouse position with the getmouseposition macro I receive position as a constant.
How can I adjust position relatively to what it first read?
Trying to
- Get mouse position.
- go 200 pixels up (y axis)
- Click at new position.
Thank you!
- Christian Scheuer @chrscheuer2020-11-03 22:26:41.697Z
Something like this should do it:
let pos = sf.mouse.getPosition().position; let newPos = { x: pos.x, y: pos.y - 200, }; sf.mouse.setPosition({ position: newPos, }); sf.mouse.click({ position: newPos, });
Christian Scheuer @chrscheuer2020-11-03 22:27:29.416Z
Just out of curiosity - what are you trying to do? In 99.9% of cases you don't need to use mouse simulation like this in SoundFlow, so there's a chance there's a better way to achieve your goal.
- RRichard Furch @Richard_Furch
Christian,
I need to grabber click on an audio file on one track (to rename it). Then go two tracks up and grabber click on another audio file to rename it. Any other ideas to do that?Christian Scheuer @chrscheuer2020-11-03 23:04:42.482Z
You can use the following script to rename a clip without any mouse clicking - in this example it renames the clip and suffixes the name with some text:
function renameClip(callback) { //Make sure Pro Tools Edit Window is active sf.ui.proTools.appActivateMainWindow(); //Make sure we have no search in Clips list - if we had, Clip Rename won't work (Pro Tools bug) sf.keyboard.press({ keys: 'cmd+shift+d' }); //Clip Clip->Rename... sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] }); //Wait for 'Name' dialog to come up, assign the dialog to dlg variable var dlg = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({}, 'Could not find "Name" dialog').element; //Find the first text field var textField = dlg.groups.whoseTitle.is('Name').first.textFields.first; //Get the current Name var currentName = textField.value.value; //Make a variable with the new name, based on the old one by calling the callback function provided in the 1st argument var newName = callback(currentName); //Set the value of the textField textField.elementSetTextFieldWithAreaValue({ value: newName }); //Press OK dlg.buttons.whoseTitle.is('OK').first.elementClick(); //Wait for the dialog to close dlg.elementWaitFor({ waitForNoElement: true }); } renameClip(function(oldName) { //Make the new name the oldName plus ' PREF' return oldName + ' PREF'; });
And this script could help you navigate exactly two tracks up.
function trackGotoDelta(delta) { let visibleTrackNames = sf.ui.proTools.visibleTrackNames; let selectedTrackName = sf.ui.proTools.selectedTrackNames[0]; let visibleTrackIndex = visibleTrackNames.findIndex(n => n === selectedTrackName); let newVisibleTrackIndex = visibleTrackIndex + delta; let newTrackName = visibleTrackNames[newVisibleTrackIndex]; sf.ui.proTools.trackSelectByName({ names: [newTrackName] }); } trackGotoDelta(-2);
Those could be easily combined - depending on how exactly you need it to rename, and if in fact it always needs to go 2 tracks up, or if you need it to navigate to a track by name.
The more details you give, the easier it will be to help you get the best possible version of the script.- RRichard Furch @Richard_Furch
Thank you for this, Christian!
I'd like to point out that my questions regarding mousing and modifying clipboards etc are all result of one thing:
Before one goes deeper into java scripting etc, the fundamental need and desire for a macro language is to replace user input.I.e. if I want to shortcut my moves, I think about "okay, how would I do that with a keyboard and mouse" and then replicate it step by step.
I'm SURE there are more elegant coding options, but at the MINIMUM and in the fastest way, I will be able to replace a workflow with mouse and keyboard input.
Thus, knowing where the mouse is and being able to click/drag etc on the ui anywhere and adjust this automatically becomes hugely important.
You have helped a lot with this and I'm thankful.
Christian Scheuer @chrscheuer2020-11-03 23:55:10.817Z
Awesome :)
I have made 2 videos that show exactly the process of converting a keyboard & mouse simulation focused way of thinking into UI Automation-based scripts & macros.
I'd highly recommend watching these: