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.)
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 wscript.quit 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 . """);" cartes.execute(filevar) if (cartes.LastError != "") msgbox % cartes.LastError cartes := "" ExitApp
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: