Using the Chilkat ActiveX in AutoIt
create Chilkat objects with ObjCreate and call them from any AutoIt script
Windows · AutoIt v3, 32-bit or 64-bit · Chilkat ActiveX v11
AutoIt has built-in COM support, so a script can create Chilkat objects such as Chilkat.Http,
Chilkat.JsonObject, or Chilkat.Crypt2 with ObjCreate and call their methods and
properties with dot notation. That adds HTTP/REST, email, FTP/SFTP, SSH, Zip, PDF, encryption, digital signatures, JSON,
XML, and the rest of the Chilkat API to your automation scripts.
The 60-second version
- Check whether your script runs as 32-bit or 64-bit AutoIt (below).
- Install the matching Chilkat ActiveX, or both. The per-user installers don't need administrator rights.
- Paste the first script into SciTE and press F5.
On this page: Bitness Install First script JSON into an array COM errors AutoIt tips Compiled scripts Troubleshooting
Setup
Find out whether your script runs as 32-bit or 64-bit
The Chilkat ActiveX DLL must have the same bitness as the AutoIt process running the script. AutoIt includes both
interpreters: AutoIt3.exe is 32-bit and AutoIt3_x64.exe is 64-bit. Which one runs depends on:
- the choice you made when installing AutoIt on 64-bit Windows (use the x86 or x64 tools by default);
- in SciTE4AutoIt3, the
#AutoIt3Wrapper_UseX64=yor=ndirective at the top of the script; - for a compiled script, whether it was compiled as an x86 or x64 executable.
The @AutoItX64 macro tells you for certain. Run this line: 1 means 64-bit, 0 means
32-bit.
ConsoleWrite("64-bit AutoIt: " & @AutoItX64 & @CRLF)
Installing both the 32-bit and 64-bit Chilkat ActiveX covers every case; they coexist without problems.
Install the Chilkat ActiveX
The MSI installers copy the DLL and register it, which is all AutoIt needs:
| Installer | Use it when |
|---|---|
| Per-user | Scripts run only under your Windows account, without elevation. Normally needs no administrator rights. |
| Per-machine | Scripts run under other accounts, as scheduled tasks, or with #RequireAdmin
(an elevated process doesn't use per-user registrations). Requires administrator rights to install. |
The ActiveX download page also has ZIP downloads with a register.bat
script that registers the DLL with regsvr32. Keep the DLL on a local drive, not a network share. The downloads
are the full version and are fully functional for a 30-day
evaluation.
Examples
Your first script: unlock Chilkat and fetch a URL
Chilkat must be unlocked once per process with UnlockBundle, so call it once near the top of the script.
During the 30-day trial any string works; after purchase, use your license code.
Local $oGlob = ObjCreate("Chilkat.Global")
If Not IsObj($oGlob) Then
MsgBox(16, "Chilkat", "Chilkat ActiveX is not registered for " & (@AutoItX64 ? "64" : "32") & "-bit AutoIt.")
Exit 1
EndIf
If $oGlob.UnlockBundle("Anything for 30-day trial") <> 1 Then
ConsoleWrite($oGlob.LastErrorText & @CRLF)
Exit 1
EndIf
Local $oHttp = ObjCreate("Chilkat.Http")
Local $s = $oHttp.QuickGetStr("https://www.chilkatsoft.com/helloworld.txt")
If $oHttp.LastMethodSuccess <> 1 Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit 1
EndIf
MsgBox(0, "Chilkat", $s)
Press F5 in SciTE. A message box shows Hello World!. The ProgID is Chilkat. plus the
class name, for example Chilkat.JsonObject or Chilkat.Crypt2.
Load JSON from a web request into an array
This script downloads a small JSON document, parses it with Chilkat.JsonObject, copies each member into a
2D array, and shows it with _ArrayDisplay. The same pattern works for any REST API: send the request with
Chilkat.Http or Chilkat.Rest, then read the fields with StringOf, IntOf,
and SizeOfArray.
#include <Array.au3> ; (Unlock Chilkat first, as in the previous script.) ; {"apple":"red", "lime":"green", "banana":"yellow", ...} Local $oHttp = ObjCreate("Chilkat.Http") Local $sJson = $oHttp.QuickGetStr("https://www.chilkatsoft.com/exampledata/sample.json") If $oHttp.LastMethodSuccess <> 1 Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit 1 EndIf Local $oJson = ObjCreate("Chilkat.JsonObject") If $oJson.Load($sJson) <> 1 Then ConsoleWrite($oJson.LastErrorText & @CRLF) Exit 1 EndIf Local $n = $oJson.Size Local $aRows[$n][2] For $i = 0 To $n - 1 $aRows[$i][0] = $oJson.NameAt($i) $aRows[$i][1] = $oJson.StringAt($i) Next _ArrayDisplay($aRows, "Fruit colors", "", 0, Default, "Fruit|Color")
Handle COM errors
Chilkat reports ordinary failures through return values and LastErrorText, not COM errors. A COM error
occurs when the call itself can't be made, typically because a method or property name is misspelled or the installed
Chilkat version doesn't have it. Without a handler, AutoIt stops the script with The requested action with this object
has failed. Install a handler to report the details and keep going:
Global $oComErr = ObjEvent("AutoIt.Error", "_ComErrFunc")
Func _ComErrFunc($oError)
ConsoleWrite("COM error 0x" & Hex($oError.number) & " on line " & $oError.scriptline & ": " & _
$oError.windescription & @CRLF)
EndFunc
With the handler installed, AutoIt also sets @error after a failed COM call.
Things to know when calling Chilkat from AutoIt
| Topic | What to do |
|---|---|
| Success values | Chilkat methods that report success, and properties such as LastMethodSuccess,
return 1 for success and 0 for failure. AutoIt treats 1 as True and 0 as
False, so If Not $bOk Then works; comparing with <> 1, as the examples do, is the most
explicit. |
| Errors | Check the return value (or LastMethodSuccess for methods that return a string or
object) and print LastErrorText, which explains exactly what went wrong. |
| Passing objects | Pass a Chilkat object to a method as an ordinary variable, for example
$oHttp.HttpStr("POST", $sUrl, $sBody, "utf-8", "application/json", $oResp) where $oResp was created
with ObjCreate("Chilkat.HttpResponse"). |
| Object lifetime | Objects are released when their variable goes out of scope or the script ends. Assign
0 to a variable ($oSsh = 0) to release a connection earlier. |
| Unicode and files | AutoIt strings are Unicode, and Chilkat receives and returns Unicode strings. When you save
text, use Chilkat's file methods with an explicit charset, or FileOpen with a UTF-8 mode flag. |
| Binary data | Methods that return bytes return an AutoIt Binary value. For large data,
Chilkat.BinData keeps the bytes inside Chilkat and avoids copying. |
| Long operations | A GUI script doesn't respond while a Chilkat call runs. Set timeouts such as
ConnectTimeout and ReadTimeout where a class has them. |
| Chilkat v9.5 scripts | v11 ProgIDs are Chilkat.Http, Chilkat.Global, and so on. Older
scripts use Chilkat_9_5_0.Http. Both versions can be installed side by side; see
Chilkat ActiveX v11 and v9.5 on the same computer. |
Running compiled scripts on other computers
A compiled AutoIt EXE doesn't contain Chilkat; it finds the Chilkat ActiveX through the Windows registry. On each computer where the EXE runs:
- Install the Chilkat ActiveX with the same bitness as the EXE (x86 or x64 compile).
- Use the per-machine installer if the EXE runs as a scheduled task, as another account, or elevated.
- If you register the DLL from your own installer, use
regsvr32for the right bitness; the ActiveX DLL Registration Tutorial explains the details.
Troubleshooting
| Message | Cause and fix |
|---|---|
ObjCreate returns a non-object and sets @error |
The Chilkat ActiveX isn't registered for this AutoIt. Usually its bitness doesn't match (check
@AutoItX64), or it's registered per-user and the script runs elevated or as another account. Install the
matching MSI, and check the ProgID spelling (Chilkat.Http). |
| Variable must be of type "Object". | The script used a variable whose ObjCreate failed. Check IsObj after creating each object;
see the previous row. |
| The requested action with this object has failed. | A COM error, usually a misspelled method or property name, or a Chilkat version older than the one the script was written for. Check the name in the reference documentation and install a COM error handler to see the details. |
| A Chilkat method returns 0 or an empty string | The operation itself failed (a network error, a bad password, an invalid file path, and so on). Print
LastErrorText; it names the cause. |
Next Steps
- 📖 Chilkat AutoIt Reference Documentation — every class, method, and property
- 💻 Chilkat AutoIt examples — thousands of ready-to-run examples
- 📦 Chilkat ActiveX downloads (MSI installers and ZIP files)
- ✉ Contact Chilkat support