Run AutoHotkey Script


Script Activities -

Insert a image to word document in Bookmark section

Hi, I’m still struggling with this activity. Per the Properties panel, the script expects a collection to be passed to a VB function.
Normally an AutoHotkey script will not contain a VB function.
Can you please give an example of what might go in the fields indicated in red? Thank you!
A simple example of passing arguments to the script and retrieving a result would be most helpful.

Kind regards,



In FunctionName provide a string with the name of the ahk function you want to call.
In parameters provide parameters to it. They will be passed on in the same order.
You will get a string representation of an output, if any. Store it in a variable just as you would normally do with any other activity.

This activity is a wrapper - it seems your confusion comes from the fact that you know how ahk works. Try for a moment to forget the internals and treat it like invoke method.
If the wrapper works it doesnt matter if it internally calls ahk, com, net or java, the same way it doesnt matter how Refresh activity actually refreshes the web page for different browsers.


Andrzej, thanks so much for your quick response. I’m still having trouble.
Here is the entire contents of my simplest script, Hello_Variable.ahk:

msgbox %1%

That’s it. Ten characters long including the space. If I invoke it on the command line, like so, with or without quotes:


the output is:


If I try a workflow with one “Run Auto Hot Key Script” (attached), I get this error message:


But that is the only function in there.

My properties panel looks like this:


And the parameters are these (“In” and “String” can’t edited or changed):

I’ve attached my script and workflow - I would really appreciate your help understanding this. I am able to use both AutoHotkey.dlll and AutoHotkey.Interop.dll in VB programs (including one that generates the popup menus I referred to elsewhere). Here I just can’t do it.

Thanks a million for your help!
burque505 (1.6 KB)


My knowledge of ahk is basic at best… But, what it looks like to me is that this isnt a function. Can you try with empty FunctionName and that file? Basically running the whole file with an argument or treating the file as an unnamed function.

I’m basing this on the understanding that the function name identifier should point to a function call defined in the file, not just used there. Similar to a net cmd program that writelines an argument doesnt expose console.writeline.

Does ahk even have a concept of defining functions? I need to brush up on that tomorrow (or today, midnight just passed…).


Andrzej, thanks for your patience and continued interest. And thanks for burning the midnight oil :slight_smile:
AHK does indeed have built-in functions and the concept of defined functions:

AutoHotkey Functions
AHK function objects
Function as either command or expression

Although I may be wrong, frequently am and most likely am now, it appears to me AutoHotkey.Interop is being accessed correctly, or at least incompletely, in the UiPath activity; all it appears to be able to do is load and run an AutoHotkey script. This, however, can be more effectively done with “Start Process”. Passing arguments into AHK can be done as shown in the attached workflow sequence, “AHK 2 args.xaml”, and corresponding AutoHotkey script “HelloTwoVariables.ahk” (zipped since the forum doesn’t allow uploading files with an “.ahk” extension):

Pass two variables as args to (2.2 KB)

“Start Process” does require that AutoHotkey.exe be available to the workflow. If you don’t have it installed, here’s an alternate workflow, script and executable, but you’ll have to change the working directory in the “Start Process” activity.

AHK not (412.4 KB)

The module AutoHotkey.dll (for which AutoHotkey.Interop is a wrapper), at least when invoked from a VB.Net or C# program (probably others), can call AutoHotkey functions and send the return value to the hosting code. See the github page:

AutoHotkey.Interop code samples toward the bottom

So far I have not been able to get a single one of these examples to work using “Run Auto Hot Key Script”.

Best regards,


@burque505 you can contribute now to our community repo.


Thank you! Have a good weekend.



Try wrapping your call to the message box into a user-written function in AHK and calling the user-written function.

    msgbox %1%

You’d then have the FunctionName parameter in UiPath be “testFunction”.


@khage, although it doesn’t throw an error, the argument doesn’t get passed to the AHK message box. If you have a workflow where this works, I’d love to see it. Thanks!


The code I’ve got in production is actually moving the other direction (passing information out of the AHK script, not in), so my above testFunction was just an off-the-cuff example. Try adding a parameter to testFunction in the AHK script and then calling the parameter inside the function. Again off the cuff, but. . .

    msgbox some_val

Since we learned in my previous example that the UiPath activity is calling a function in a script, maybe the parameters are being passed to the called function, rather than at a global scope?


@khage, you made my weekend. Thank you. It works.
Actually, I believe passing information out of the AHK script is more valuable than in. I’m having a little luck with that also now, but I want to refine it a bit before I post the workflow and script.
Data in and out.

p.s. Stuck at work but I will keep at it. Thanks again.


@khage, @andrzej.kniola, just wanted to post my progress.
First, Andrzej, you were spot on about the functions, as @khage proved to me. I am delighted to have been proven wrong.
@khage, your help is invaluable, and you already have scripts in production.
In the attached workflow, AHK script and icon (zipped to ‘Function Test 8’.zip), I pass two strings to a function ‘Setting(a, b)’ in an AutoHotkey script. The are returned as ‘varOut’, a string.
Also in the AHK script, the function ‘Setting(a,b)’ is called again, on a variable assigned inside the script. A custom message box is displayed. (‘a’ is assigned “Do the moon”; ‘b’ is assigned “the stars still exist”.)

Once out of the script, UiPath displays a message box showing ‘varOut’ with some accompanying text.

Function Test (7.2 KB)

Here’s an image of the custom message box:

AHK message box

With AHK you can easily make different custom message boxes, task dialogs, multiple choice quiz panels and input boxes with small variations on a theme. If there is interest, perhaps I can try to create a custom activity for these.

Here’s one with a tad more “bling.”

For my next inquiry:
How in the dickens do you get anything other than a string as an output variable from an AHK script, without writing it to the file system? And once again, you guys, thanks for the help. It would be great to get arrays, lists and objects out of AHK and into UiPath.

Edit: Seek and ye shall find :persevere:. Thanks, Andrzej!
Passing datatable
I’ll start there.

Have a great rest of the weekend,


Hi guys,

Funny, this weekend I also decided to play a bit with AutoHotkey too after another post from @burque505 on the topic.
While trying to make the custom activity I found this post randomly and saw the activity made by @Lavinia on Github which is great :slight_smile:

Still, I continued what I was planning to implement handling the script invocation using a slightly different approach.

The main difference are:

  • It does not Inherit the base script activity (shared with execute powershell) having all the wizzards for filepath/paramater (I’m honestly too just in with my WWF skills to implement them on my own activity using the metadata approach to be honest :))

  • It allows to either Invoke from a script file or directly execute AHK script from a string.

  • Since there is now wizard for parameter the communication UiPath=>AHK=>UiPath is made using a InOut Arg of Type Dictionnary but at the end it could be manage via MetaData like other UiPath Activities

  • It can output a variable of Type AutoHotkey.Interop.AutoHotkeyEngine to easyly use it in an Invoke code for example

  • It based on execRaw and Get/SetVar so it allows passing more than 10 args (i will attach an example using 26 of them)

@Lavinia It is definitely basically implemented (Not async, No Design) but i will attach you the .vb ,from the CodeActivity if you are curious (Yes it’s made in VB :smiley:)

@burque505 In case you would like to gie a try i will attach you the Nuget package, just drop it in Program Files (x86)\UiPath Platform\Packages, start studio, install. I’m attaching also a project where it is used in various ways.


AHKActivities.1.0.9.nupkg (1.1 MB) (2.8 KB)

.vb not authorized extension when .cs is, Im scandalized :smiley: you will need to change the extension.

ExcecuteScript.cs (1.8 KB)



@Florent, that is a marvel. I feel like a kid with a new toy. I tried it out right away.
That is just too much for words.

I was happy as a politician with the keys to the public treasury not twenty minutes before you posted when I finally managed to serialize an AHK object, pass UiPath args to and get it out as a string to UiPath (see attached), and now you have REALLY given me something to work with.

Kudos! Kudos! And more kudos to you, Florent. (4.0 KB)

Best regards,


There was a question here about inserting an image (not a URL, the actual image) in a Word bookmark.

I posted a workflow and accompanying files in my reply at that link, that do the task using “Run Auto Hot Key Script”, and with some modification also work with Florent’s AHKActivities and with just “Start Process”.

(“Run Auto Hot Key Script” needs a method, so I used that in the attached workflow. Both AHKActivities and Start Process can just run the second AHK script directly).

For now, I’m starting one AHK script with another to avoid async problems that otherwise crop up.


Sometimes the Input Dialog seems just too small. I’m working on a bigger one. You’ll need AutoHotkey installed (or available in the script directory if not installed, which will also require you to change the :“Start Process” to the AHK executable and add an argument to load the script. Let me know if that isn’t clear, maybe I can post a workaround). For now this is a little fragile - the “Close” button is grayed out to “discourage” you from breaking the robot, and I need to make it bulletproof still.

To change the output variable for the input dialog, look in the workflow for the output of the “Get Text” activity.

You can change the font size in the AHK script, and you can get quite a lot of text in without using the scroll bars:

(Tiny, right? I changed the font to 7pt for this screenshot.)

You can minimize and maximize the input box.
Also, you’ll probably want to do something with the text once you have it. And probably not just a UiPath Message Box, but for demo purposes it looks like this:

Passed into UiPath and displayed thus:

BIB-4 (10.6 KB)



Maybe a RichEdit control? Need to open an RTF from UiPath once in a while?
You need AHK installed for this unless you tweak the “Start Process”. (55.0 KB)

All credit to ‘AHK-just-me’ (definitely not me):

Class_RichEdit github repo here.

A little bling:



i had installed AHK package, but did not found the Run AutoHotkeyScript