Interact with Auto-Trace prompt pop up?

Hi!

I’m looking to create an animation that selects every layer that isn’t text, autotraces them and then applies a preset to them. I managed to get the whole thing working however I have ran into one issue, cause of the way auto-trace works, I still have to click Ok on the auto-trace popup manually for it to run fully.

Is there anyway to make it so the automation can interact with the prompt and click Ok?

Thanks,
sen

Hi @sen93, welcome to the forum!

Yes, I’ve encountered a similar question from another user, and the solution might work for you as well. The user needed to simulate a key press on the keyboard—in his case, the letter “p.”

Simulating a key press can also solve your problem. By triggering the “Enter” key press right after the Auto-trace window appears, you can automate the entire process without needing to move your mouse.

Here’s the older post that might help: Adding existing AE keyboard shortcuts to actions

This post details methods to trigger a key press natively on both Mac and Windows, using AppleScript on Mac and PowerShell on Windows.


In your case, you will need to run a Windows batch script before executing the menu command.

Why should you run the Windows script to trigger the “Enter” key before opening the Auto-trace window?

If you run the menu command first and then the script to trigger the key press, the script won’t execute until you manually close the Auto-trace window. This is because the automation stops and waits for the menu command to resolve before continuing.

The solution is to run the Windows batch script with a small delay—set it to 1 second before it triggers the “Enter” key press. Then, execute the menu command. This delay allows the Auto-trace window to open, and the script will automatically press “Enter” after 1 second, completing the automation smoothly.



Creating the PowerShell script -

You need to create a batch file (.bat file that contains a PowerShell code that when run will simulate a key press) -

  1. open the notepad software.
  2. paste this code -
if "%1" == "" start "" /min "%~f0" IS_MINIMIZED && exit
powershell -Command "Start-Sleep -Seconds 1; Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')"
exit

(the first line tells this cmd window to open in minimized mode without taking the focus from the After Effects window, second line start a time delay of 1 second and runs powershell code to simulate the key press, third line tells it to exit the cmd window)

  1. save this script file with .bat file extension, for example “keyboard shortcut 1.bat”.

I left the creation process for you as it is more safe, downloading a malicious shell script can be very dangerous.



Instructions on how to use this bat file -

create an automation that will run this script from automation toolkit -

  1. create a file variable and select the script file you just created (click the folder icon and select the file).
  2. add an action and select the file variable name, and then select open.

    download -
    keyboard shortcut.json (1.9 KB)

the automation is ready!

finally you just have to disable this warning message in the preferences (scripting & expressions) -




This Automation only execute the (.bat) script that waits 1 second and then press enter so you will not be able to see its effect without adding the menu command after these 2 lines



Here is the automation with the Auto-Trace menu command -

Automatic Auto-Trace.zip (780 Bytes)
(remember that you need to select the (.bat) script file that you created earlier)

Let me know if you need help or have more questions
Thanks,
Alon

@sen93, to ensure reliable execution, make sure to configure the settings in the Auto-trace window correctly before starting the automation. I also recommend unchecking the “Preview” checkbox, as the preview can slow down the process, leading to less reliable results.

image

Thanks for the quick and detailed answer!
It works perfectly, I ended up changing off the bat file for an autohotkey script in the end so there is no need for an artificial 1 second delay as ahk can look for the window named “auto-trace” and send the keystroke the moment it appears.

If anyone ends up needing it later on here is the AHK script I used (it times out after 3 seconds if the script gets stuck and sends an error message saying it timed out):

WinWait, Auto-trace, 3
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
Send, {enter}

1 Like

@sen93, thanks for sharing your solution and the AHK script!
I’m glad you found such a simple and excellent solution for the 1 second delay. Well done!

@sen93, if you want to keep the AHK script file within the automation, you can embed the file into the automation file.

This option converts the file content to base64 format and saves it inside the automation JSON file. When running the automation for the first time, it will create the file as a temporary file in the temp folder.

This way, if you move the automation to another computer, you won’t have to worry about transferring the AHK script file or maintaining the same file path.

Just click on the “embedded file” checkbox and select the file.