Hey!
I am trying to get a script to work to do a mouse click on the Envy Connect UI but for some reason it doesn't work... but does if I double up the mouse click command within the script. I have looked at a few bits on the forum involving focus and raising but none seem to work... any advice appreciated! Here's where I'm at with the doubled up click command:
var win = sf.ui.proTools.getAudioSuiteWindow('Envy Connect');
if (!win || !win.exists) {
win = sf.ui.proTools.audioSuiteOpenPlugin({
category: 'The Cargo Cult',
name: 'Envy Connect'
}).window;
}
sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Envy Connect").first.mouseClickElement({
relativePosition: {"x":437,"y":171},
anchor: "TopLeft",
});
sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Envy Connect").first.mouseClickElement({
relativePosition: {"x":437,"y":171},
anchor: "TopLeft",
});
- WWill Cohen @Will_Cohen
Here's the UI in question! I want to automate switching send as source or send as texture (they're not ui buttons).
- OOwen Granich-Young @Owen_Granich_Young
Hi, I'm no help but,
Will you please publish your envy package in the store when you're done with it? Been on my to-do scripting list for a while but I don't use it QUITE enough for me to take the time. Would love to have one though!
Bests,
Owen- WWill Cohen @Will_Cohen
Hey! Certainly Owen. At moment I have just made a key command alt+shift+p in pro tools to send as source, so that it matches the same command in envy 2 - alt+shift+p to spot effected mix back to pro tools. Anyway I will be sure to share in due course if I solve this small bit of the puzzle.
- In reply toOwen_Granich_Young⬆:WWill Cohen @Will_Cohen
Ok I stuck the two quick commands I made up on the store as a package, the latter one being the one I'm asking about here!
- OOwen Granich-Young @Owen_Granich_Young
Already pointed a couple other EVNY fan buddies its way :)
- WWill Cohen @Will_Cohen
Hey! I am not sure if packages would carry shortcuts tbh but the send source would be apple+shift+p to get a sound into envy as source for basic sample mangling, that shortcut in envy being spot the mix (or source) back to pro tools. Then apple+alt+p for sending as a texture, and that same shortcut in envy being spot all textures back to pro tools as separate tracks. Envy has various ways of spotting back to pt in terms of the layers etc but this is how I use it day to day.
- In reply toWill_Cohen⬆:Dustin Harris @Dustin_Harris
I just had a look at this too, and the UI definitely doesn't seem to respond as expected. My method needed 3 clicks for the UI to properly register it... weird.
Here's my approach:
/** * @param {"source" | "texture"} mode */ function setEnvyMode(mode) { let originalMousePosition = sf.mouse.getPosition().position; sf.ui.proTools.appActivateMainWindow(); var asWin = sf.ui.proTools.getAudioSuiteWindow('Envy Connect'); if (!asWin || !asWin.exists) { let category = (sf.ui.proTools.getMenuItem('AudioSuite', 'The Cargo Cult').exists) ? 'The Cargo Cult' : 'Pitch Shift'; asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category, name: 'Envy Connect' }).window; } let modes = { source: { x: asWin.frame.x + 440, y: asWin.frame.y + 152 }, texture: { x: asWin.frame.x + 440, y: asWin.frame.y + 174 } } sf.mouse.setPosition({position: modes[mode]}); sf.mouse.click({ position: modes[mode], clickCount: 3 }); sf.mouse.setPosition({ position: originalMousePosition }); } setEnvyMode("source") //setEnvyMode("texture")
Cheers!
Chris Shaw @Chris_Shaw2022-01-22 05:45:26.385Z
I don't own / use this AS plugin but you may want to try using a mouse down click, a short wait(5-10ms), followed by a mouse up. I've used this in a few scripts when regular mouse clicks aren't behaving as expected
Dustin Harris @Dustin_Harris
Oooh great thinking Chris! I’ll give that a shot in the morning!
- In reply toChris_Shaw⬆:
Dustin Harris @Dustin_Harris
Your idea works perfectly!
/** * @param {"source" | "texture"} mode */ function setEnvyMode(mode) { let originalMousePosition = sf.mouse.getPosition().position; sf.ui.proTools.appActivateMainWindow(); var asWin = sf.ui.proTools.getAudioSuiteWindow('Envy Connect'); if (!asWin || !asWin.exists) { let category = (sf.ui.proTools.getMenuItem('AudioSuite', 'The Cargo Cult').exists) ? 'The Cargo Cult' : 'Pitch Shift'; asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category, name: 'Envy Connect' }).window; } let modes = { source: { x: 440, y: 152 }, texture: { x: 440, y: 174 } } sf.mouse.setPosition({ position: modes[mode] }); asWin.mouseClickElement({ relativePosition: modes[mode], clickType: "Down" }) //increase this as needed if system is slower to respond sf.wait({ intervalMs: 40 }) asWin.mouseClickElement({ relativePosition: modes[mode], clickType: "Up" }) sf.mouse.setPosition({ position: originalMousePosition }); } //setEnvyMode("source"); setEnvyMode("texture");
Chris Shaw @Chris_Shaw2022-01-22 15:41:20.354Z
Have you tried a shorter wait?
I think 20ms is the longest you’ll need.Dustin Harris @Dustin_Harris
I have. with this computer 30 is the lowest I can go with that UI element; and I added 10ms just for a buffer :)
- In reply toDustin_Harris⬆:WWill Cohen @Will_Cohen
Nice one Chris! As I'm a code luddite I don't understand where in the code you are choosing the modes you set but it works!
Dustin Harris @Dustin_Harris
Oh! The secret ingredient here is the 'modes' object where I'm storing the coordinates for the
mouseClickElement()
method.the object looks like this:
let modes = { source: { x: 440, y: 152 }, texture: { x: 440, y: 174 } }
they have what are called key/value pairs. In this case, the keys here are "source" and "texture" and the values are the coordinates.
You access it like this:const sourceButtonLocation = modes["source"] log(sourceButtonLocation) //{ x: 440, y: 152 } const textureButtonLocation = modes["texture"] log(textureButtonLocation) //{ x: 440, y: 174 }
but I take it one step further and pass the 'key' as a variable like this:
let mode = "source" // or "texture" let whereToClick = modes[mode] log(whereToClick) //{ x: 440, y: 152 }
So... when you use
setEnvyMode("source")
orsetEnvyMode("texture")
, that's how it knows which coordinates to click on, you're choosing them.- OOwen Granich-Young @Owen_Granich_Young
So In theory you could make this a toggle yeah? (This is a not smart toggle, doesn't check the current status.
/** * @param {"source" | "texture"} mode */ function setEnvyMode(mode) { let originalMousePosition = sf.mouse.getPosition().position; sf.ui.proTools.appActivateMainWindow(); var asWin = sf.ui.proTools.getAudioSuiteWindow('Envy Connect'); if (!asWin || !asWin.exists) { let category = (sf.ui.proTools.getMenuItem('AudioSuite', 'The Cargo Cult').exists) ? 'The Cargo Cult' : 'Pitch Shift'; asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category, name: 'Envy Connect' }).window; } let modes = { source: { x: 440, y: 152 }, texture: { x: 440, y: 174 } } sf.mouse.setPosition({ position: modes[mode] }); asWin.mouseClickElement({ relativePosition: modes[mode], clickType: "Down" }) //increase this as needed if system is slower to respond sf.wait({ intervalMs: 40 }) asWin.mouseClickElement({ relativePosition: modes[mode], clickType: "Up" }) sf.mouse.setPosition({ position: originalMousePosition }); } ///simple a/b toggle, it is not smart. globalState.ASEnvySendToggle = !globalState.ASEnvySendToggle; if (globalState.ASEnvySendToggle) { setEnvyMode("texture"); } else { setEnvyMode("source"); }
Chris Shaw @Chris_Shaw2022-01-24 16:51:03.299Z
Using
globalState
is the best way to make a toggle. The only thing I would suggest is to use a globalState name that is more descriptive/unique to avoid any possible conflicts with any other scripts that you write/download. Perhaps something likeglobalsState.ASEnvySendToggle
Chris Shaw @Chris_Shaw2022-01-24 16:52:41.549Z
I've wrote a script with
gloablaState.selectedTracks
and forgot I had other scripts with the same globalSate name.- In reply toChris_Shaw⬆:OOwen Granich-Young @Owen_Granich_Young
This globlal state is indeed a direct rip off the forums lol.
Updated.
- In reply toDustin_Harris⬆:WWill Cohen @Will_Cohen
just got my head round this, haha! Nice one Dustin, have updated my package so to speak :-)