AutoHotKey script activity: pass variable to rest of UiPath workflow

Hi, thanks in advance for all help.
I would like to run an AHK script using “Run Auto Hot Key script”, set variables, and pass them to UiPath.

In the past I’ve been able in Visual Studio to pass variables from both AutoHotkey.Interop.Dll and AutoHotKey.dll to Visual Basic. There the syntax seems to be different than what I’ll need here. Here’s a sample of a working .vb example in VB.NET, using a form with a button to execute this code:

Imports AutoHotkey.Interop
Public Class Form1
Public ahk = AutoHotkeyEngine.Instance
Public vbString As String = ""

Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
    ahk.ExecRaw("MsgBox, Hello World, from AHK!")
    'programmatically set variables
    ahk.SetVar("x", "1")
    ahk.SetVar("y", "4")
    ahk.SetVar("ahkstr", "this value to be passed to .NET")
    vbString = ahk.GetVar("ahkstr")

    MessageBox.Show("From the AHK engine I got " & vbString)

    'execute statements

    'return variables back from ahk
    Dim zValue As Integer = ahk.GetVar("z")
    MessageBox.Show("Value of z is " & zValue.ToString) ' "Value of z is 5"

    End Sub

End Class

Can someone tell me how I might run essentially the same code in an AHK script that UiPath will accept, and how to pass the variables “ahkstr” and “z” to a UiPath MessageBox activity?


Hi all,

The examples I tried above in VB are of course not very useful. Is anyone willing to share an AutoHotKey script that you use with UiPath? I’d really be interested in any that communicate with the UiPath host workflow.

So far all my efforts at getting variables and arguments in or out of AutoHotkey to or from UiPath are coming up empty.

Thanks in advance,

I don’t have an answer but this would be cool to know.
I would check out the AutoHotkey forums for how to pass arguments; it’s been a while since I have looked in there. Looks like UiPath has a Results field and Parameters field that could be used with the AutoHotkey in and out arguments.

1 Like

Some success, but it’s a kludge.
The attached files “HelloWorld.ahk” and “HelloFromAHK.xaml” are all that’s needed (I think).

  1. The AutoHotKey activity calls “HelloWorld.ahk”. An AHK message box displays a preassigned variable.

Hello World

  1. The AHK script writes the variable “myVar” to a text file in the script directory, called ‘myVar’, no extension, and then closes the file object and releases any locks. This last is just for safety.

  2. The UiPath Message Box takes “myVar” as an input variable and displays it.

AHK var passed to UiPath

In the real, non-beginner world, perhaps a more useful activity would be to have the AHK script write to a database or spreadsheet, and have the UiPath workflow retrieve it from there. AHK can do lots of things with databases and spreadsheets, and COM objects in general, so I think it would really be useful.

There is a mechanism described here for communicating with the hosting environment (i.e. UiPath in our case). I’m not a C-sharp programmer, and I haven’t had any luck with it. That looks to me like an expression-tree lambda, but I’m essentially clueless about that. If it is an expression tree, I’m going to try my luck with code described here, and I’ll post if I have any luck.

I have tried to use Invoke Code to communicate with the AutoHotkey instance, but I don’t yet know how to instantiate it so UiPath will see it. I remain hopeful.


Files (you’ll need to unzip to get HelloWorld.ahk) (543 Bytes)
HelloFromAHK.xaml (4.9 KB)

Can someone tell me where do I get the package for AutoHotkeyEngine? I need it in my Uipath to rebuild a process but I cannot find it in my available packages.


Hi @surfettekw

I believe the activity is part of this package:

It is called:

Interesting! I don’t have that - and I don’t see it available. Thank you - at least this gives me a better starting point!

Could you post a screenshot of your Package Manager? It is strange that it doesn’t show.
Maybe you are missing some feeds with the activity package.

Could you add this feed to your list:

The package is part of it and will only display if you have it configured in the settings :slight_smile:

1 Like

I have it now… found and installed but I really need is this:

You can import it over here:

OH nice - Mine still doesn’t have it there. Where do I need to put what in order to get it imported? Thank you for helping me on this!!! image

I tested it on 2018.4 and it is only available after I installed the UiPath.Script package. If I uninstall it, the import is not available anymore.

Maybe that is the clue here?

But I do have that installed…

Could you mention your Studio version? We’ll get to the bottom of this.


And what is the version of the installed Scripts package? Is it exactly the same as this one:


1 Like

A quick potential workaround, not sure if it will work though, use the method here:

With this line:


Where exactly would one put that within the file?

Add it as another AssemlyReference, like below:

Two things can happen after you then restart the Studio with your project.
It will either show your import already on the list
it will show it on the list with an error. In this case we will need to investigate further, but the most likely solution might have to be an update of your Studio.