Copy link to clipboard
Copied
Hey guys,
I've recently discovered the wonders of Python and pyautogui's gui automation potential, and I'm wondering if I can use it to get around some of the clunkier behaviors of my Extendscripts, when they use menu commands.
For example, if one of my scripts uses the collect feature, I'd like to be able to write the destination and press ok.
Or when my script needs to automatically save a preset, right now I have to have two dialogs pop up. One with the full path of the preset that my script will assume the new preset's name will be, so the user can copy it, and then the actual save preset dialog that they paste it into. If I were able to automate the gui, only one dialog would be necessary here, and the user wouldn't have to even interact with that one.
The problem I'm running into is that I can call a python script while Extendscript is running, but it won't call DURING a dialog. I can call it BEFORE opening these dialogs, or AFTER they close. I could try to get around this by having python call the command from the menu, instead of using Extendscript's app.executeCommand(app.findMenuCommandId, but then I run into the following problem: pyautogui can't interact with AE while an Extendscript is running, just like you can't manually interact with AE while it's running, since you get the spinning wait mouse cursor until it finishes executing.
Is there any way around this?
1 Correct answer
What about having your AE script execute a .py file on disk that has a timer in it? Unsure whether it'd work, but could be worth trying.
So:
- Extendscript calls a python file to execute
- Extendscript triggers the menu opening
- Your system-level (not running in AE, just running on the OS) py script waits a second or so (however long the menu takes to open)
- Py script does what it needs to do and then stops
- Extendscript sees that the dialog is closed and continues its process
Copy link to clipboard
Copied
What about having your AE script execute a .py file on disk that has a timer in it? Unsure whether it'd work, but could be worth trying.
So:
- Extendscript calls a python file to execute
- Extendscript triggers the menu opening
- Your system-level (not running in AE, just running on the OS) py script waits a second or so (however long the menu takes to open)
- Py script does what it needs to do and then stops
- Extendscript sees that the dialog is closed and continues its process
Copy link to clipboard
Copied
I've tried this, but unfortunately, when I try to run a .bat externally to call my python script, Extendscript still waits for the python script to finish before resuming. Is there any way to run them in parallel?
Copy link to clipboard
Copied
How are you calling the .bat?
Copy link to clipboard
Copied
var file = new File('myBat.bat');
file.open('w');
file.write(myCommand);
file.close();
file.execute();
Copy link to clipboard
Copied
My mistake. It was working this whole time - it was just taking a long time to invoke the initial call to python. Thanks!

