Here is a snippet of the code. Most of it is somewhat unreadable because it references controls on various programs that won't make sense without seeing those programs running
ControlClick("Print", "What to print", "[CLASS:Button; INSTANCE:6]") ; print setup, ok button
WinWait("Print", "Printer")
ControlClick("Print", "Printer", "[CLASS:Button; INSTANCE:10]") ; standard print dialog, ok button
WinWait("PDFCreator")
ControlClick("PDFCreator", "", "[CLASS:ThunderRT6CommandButton; INSTANCE:7]") ; pdfcreator, save button
WinWait("Save as")
ControlSetText("Save as", "", "[CLASS:Edit; INSTANCE:1]", $name[0]) ; standard save as dialog, fill in filename
ControlClick("Save as", "", "[CLASS:Button; INSTANCE:2]") ; standard save as dialog, ok button
Using WinSetOnTop helps a bit visually but you're correct in that it doesn't stop focus stealing.
@SW_HIDE is what I've been looking into, but I'm not using Run() or ShellExecute(), so I can't hide it from the start. At best, I can detect the creation of the window using shell hooks then use WinSetState to hide it, but it still takes focus for a split second. My hope was to use a shell hook on window creation to call WinSetState with @SW_HIDE before the window activation event. So far, even though I have the hooks, it seems autoit's hook won't run until after the window is activated.