Hi, over the years the need to stop AutoHotkey threads with a MessageBox or similar caused a lot of aggravation. Although it hasn’t been used in production yet, it is working well for me. All it adds as a wrapper around the boolean
AutoHotkey.DLL.ahkReady() command in the module as 'IsReady() in AutoHotkeyEngine.cs. See generally burque505 fork of AutoHotkey.Interop. Might this be of use in UiPath.Script.Activities?
Edit: Any script that makes an external call with a SetTimer command to avoid synchronous problems (such as one creates a Word, Excel, or IE Com object), note the ‘ahkReady() reference’, can probably benefit from it.
AhkCom := ComObjCreate("AutoHotkey.Script") AhkCom.ahktextdll("MsgBox Hello World!") While AhkCom.ahkReady() Sleep, 100 MsgBox Exiting now
Also, if you find your AHK scripts are failing the second time around, and you get a “duplicate function definition” from an #Include file, try adding this at the end of your AHK code: