Keysharp implements the AutoHotkey v2.1-alpha.30 language on .NET, and runs on Windows, Linux and macOS. Most scripts behave as their AutoHotkey documentation describes. This page explains the differences which are structural — the ones worth understanding before porting a script — and then indexes the pages which state each exact contract.
Note: The absence of an item here does not prove that inherited behavior has been verified on every platform. See Platform Support and the platform remarks on the affected page.
AutoHotkey interprets a script. Keysharp reads it, lowers it to C#, and has Roslyn compile it to a .NET assembly which is then executed. How a Script Executes describes the pipeline, and the --transpile and --compile options expose its intermediate results.
Several inherited behaviors follow from this rather than from any deliberate design choice:
AutoHotkey is a Windows automation tool, and much of its library is defined in terms of Win32. Keysharp runs the same language on Windows, Linux and macOS, which means a page describing a Win32 behavior describes an intent that each platform meets to a different degree.
Platform Support is therefore a primary reference rather than an appendix: it covers X11, Wayland, macOS permissions and foreign-window automation. On Linux and macOS, input and window control depend on OS-level permissions and helpers, and a script can declare what it needs with #Requires or RequestCapabilities.
The GUI is built on a cross-platform toolkit rather than Win32 common controls. Window styles, control messages and other Win32-level facilities are consequently unavailable or approximated; GUI Control Types and GUI Events record where.
Objects are .NET objects. Object lifetime and finalization follow the garbage collector instead of reference counting, so __Delete runs when the collector reclaims the object rather than when the last reference goes away, and the reference-counting functions reflect the managed runtime.
The same applies wherever a script reaches outside itself for memory: DllCall, CallbackCreate, StrPtr and ObjPtr operate on managed values, and StringBuffer is the writable string-memory type to pass to native code. For calling .NET directly, Clr is available.
Keysharp adds facilities which have no AutoHotkey counterpart. A script which uses them will not run under AutoHotkey:
Each link below leads to the canonical contract for that behavior.
The affected reference pages document the exact boundary. Notable areas include:
The differences above are between Keysharp and its AutoHotkey compatibility target. For changes between AutoHotkey versions themselves, see Changes from v2.0 to v2.1 and Changes from v1.1 to v2.0. For changes between Keysharp releases, see Recent Changes.