Skip to main content
3-Newcomer
December 1, 2025
Question

Running a macro via Java Object Toolkit

  • December 1, 2025
  • 2 replies
  • 448 views

Hello everyone,
We use Creo10.0. and Java Object Toolkit to run a macroA:

~ Command `ProCmdUtilTrailTrain`
< 2 0.118519 178 0 0 100 1920 0 0 1080 13
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`
~ Select `file_open` `Ph_list.Filelist` 1 `macroB.txt`
~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd`

It should call another macro - macroB.txt

 

When we run macroA manually in Creo using "Play Trail File" it works fine.
When we run it using Java Object Toolkit - RunMacro method, it opens the dialog but the last step - clicking the "Open" button - is not performed. If we watch it in the UI and click the Open button manually, it correctly calls macroB.

 

Thank you for any hint.

2 replies

21-Topaz I
December 1, 2025

If I understand correctly macroA is a mapkey and macroB is a trail file. 

it looks like the Java Object Toolkit method does not get the hand back.

The following article suggests to activate the window before firing the trail file : https://www.ptc.com/en/support/article/CS129591 

3-Newcomer
December 2, 2025

Both are trail files.

We want to run them from Java on a backend server.

I tried the advice from the linked article but it didn't help. Also it is for older Creo version.

 

18-Opal
December 2, 2025

No idea if this helps, but you can start Creo with a trail file, maybe you can reverse the task, and later pick the application button within the trail.

And in async mode you can fire mapkeys, but for a long sequence you may have other issues.

 

You need to give the control back to Creo, else it is recursive/nested. Check to do the trail task with Toolkit 🙂

Or first run the app calls, save, and after then run a separate trail file session, it is all a hack!.

 

You can do all the stuff via mapkeys as well, this mapkey can be loaded on start via the config file and can be call via '%', but I guess you know that. But a mapkey could be able to close a toolkit button call. On top you can load a config file with toolkit, to setup mapkeys and call them later.

 

I would not run a nested trail file, I would prepare them to run one after the other. Trail files have no status, they work or crash, mapkeys NOT and they can be nested. You can write lines (with Toolkit) to the trail file to watch your asyn process as well.

 

You can also setup a parameter marker in your model, this may help if the same button is pressed more than one time to continue with the next step. 

 

Have fun 😉, all my 2 Cents!

18-Opal
December 3, 2025

Other options:

 

  1. Quit the asyn session and reconnect later (This may help with the event loop)
  2. Fire the mapkey by active the creo window and "emulate the mapkey entering, like a user would do, you send the char one by one". But in this case I'm not sure how to do this if the window is not visible.

BTW: What is the result if you do this in a different stack order, so the trail file will fire a mapkey?