AutoHotkey and Cartes.CartesObj

Since I downloaded RPA Developer two days ago, I have been getting used to the interface and CartesScript, little by little. I have used AutoHotkey for several years, so I wanted to see if the two are a good fit. So far it seems they are. AutoHotkey has very good support for COM objects, so it was a welcome surprise to see Cartes.CartesObj available for use.

AutoHotkey shares similarities with VBS syntax, with some major differences. In general it is fairly easy to port VBA or VBS to AutoHotkey, so the VBS examples seemed a good place to start. Here I used a version (admittedly wacky) of the “Hello world” example. Here is the CartesScript:

/* Put here the source code of your process.
   Remember, Cartes Script is similar to PHP. */
$FirstApe = "Say hello to the monkey, okay?" & LF;
$Notepad.value("Hello, ape!");
$Notepad.value($FirstApe & $Notepad.value & LF & "Big fat ape.");

(This is absurd, granted.) :grinning:

I wanted to use the script below, taken almost straight from the Examples folder, as a base:

Dim Cartes
Set Cartes = CreateObject("Cartes.CartesObj")
projectFile = "C:\Users\HP6300\Documents\RPA Developer\Projects\FirstApe.rpa"
result = Cartes.execute("open("""&projectFile&""");"&chr(13)&chr(10)&"$Notepad.value(""Hello world."");")
if Cartes.LastError <> "" then
msgBox Cartes.LastError
end if

This works fine (if Notepad is already running, of course). Here is the AutoHotkey code that accomplishes the same thing, and then replaces the text in the Notepad editor control.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

myvar =
Hello world.
This is a message from the Planet of the Apes.
All your bases are already belong to us!
Bring bananas or die.

cartes := ComObjCreate("Cartes.CartesObj")
cartes.balloon("Hello, Rigel developer, from AutoHotkey!")
projectFile = "C:\Users\HP6300\Documents\RPA Developer\Projects\FirstApe.rpa"
filevar := "open(" . projectFile . ");" . "`r`n" . "$Notepad.value(""" . myvar . """);"
if (cartes.LastError != "")
	msgbox % cartes.LastError
cartes := ""

Note the curious syntax for creating ‘myvar’. This allows multiline strings to be created easily. Note also the differences in constructing ‘filevar’:

There are differences in quoting best resolved by trial and error.
In AHK (AutoHotkey), “rn” is equal to ‘chr(13)&chr(10)’
In AHK ‘.’ is a concatenation operator for strings, as opposed to ‘&’ in VBS.
The ‘if’ syntax is different, but not much.

AutoHotkey has been used for robotic process automation since before the term existed, so I believe it will be a good fit with RPA developer. There are thousands of user-created libraries to leverage.

Here is a screenshot:




Visual Basic and Autohotkey are tools that only allow very simple programming. We know Autohotkey well and like RPA Suite and its Robot Cartes they have existed since before the term RPA was so vulgar. In fact RPA is a registered trademark in Spain, that’s why the tool is called RPA, we added Suite later because the market was confused.

About Autohotkey libraries I will only tell you that compared to Visual Studio or Java libraries (Cartes works with both) they are minimal.

If you like RPA Suite, use it. Look at their C# examples, everything else is toys.

1 Like

@burque505, another thing. Cartes Script allows you to handle exceptions, object-oriented programming, modularity … It has all the characteristics of a high-level programming language.
VBS doesn’t have those capabilities, and Autohotkey doesn’t, as far as I know, either.

Anyway, I recommend that you use C# - Visual Studio has a free version - and forget everything else.

1 Like

@xavier, by chance I just watched the VS video about five minutes ago. Very exciting!
Thanks for the tip. That does look like the solution for professionals.

@RpaTeam, I will definitely be using it!

1 Like