Thanks i really appreciate your time and effort.
It looks like you have a few problems :-
1. Make sure you have 'Tool selections persistent' turned on, this will remember the current tool over power downs , see image. Click the tool DRO on the program run screen, enter a number and press return, exit Mach3 and restart, is the tool number still set?
2. This macro is for a rack type tool changer with no return function so we need to do one for your setup.
3. We need to know the position of the first tool holder relative to the home position and the pitch spacing of the tools. Output used for the tool release, output used for dust shoe lift if fitted.
With this info we can start and fix your problem.
1. You are right i activated tool persistent in my setup now (and tool number are remembered if i close mach3 or reboot computer) i post here a image of my config maybe i need to change something more.
2/3. I use a rack type but with every tool in different spacing's.
Because i need to make some "cuts" in my spoilboard for some large tools because my spindle base are low and i need to put the tool holders near the spoil-board and for avoid crushing it.
Some tools can fit and another ones (larger tools like 75mm tools) i need to put in "special" coord because my spoil-board have some spaces and the larger tools go trought this spaces (attached image of my cnc spolboard).
For this reason and dust shoe not retractable (i go to design a dust shoe compatible with my tools, for use it with a tool change without problems) i want prefer to put the coords of every tool holder manually for avoid problems and avoid to put a fixed space between tool holders and if someday i change the cuts of the spoilboard i can change individually this tool coords.
Sorry if i'm not capable to explain this situation in good terms.
In the script i put a false XYZ tool pos for test first in the air see how "emulate" a tool changes and if i see all is good i put the real coords.
When i return from work i go to test if the macro works, i think if this work i'm capable or i go to try and learn to add the inputs and outputs for security sensors of the spindle and the rack pneumatic relay (rack it's easy to add).
Thank you and sorry for my English (I'm from Barcelona).
Another time thanks for your time.