cloudahk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cloudahk [2023-07-15 12:45] – Fancy the page up for publication geekcloudahk [2024-02-08 02:01] (current) – Add compiler section geek
Line 14: Line 14:
  
 <runner ahk2> <runner ahk2>
-msgbox "hi"+MsgBox "hi"
 </runner> </runner>
 +
 +
 +===== Converter =====
 +
 +Attempt to convert AHKv1 syntax to AHKv2 using the [[https://www.autohotkey.com/boards/viewtopic.php?f=6&t=25100|AHK-v2-script-converter]] project.
 +
 +<converter>
 +; Requires AutoHotkey v1.1.26+, and the keyboard hook must be installed.
 +#InstallKeybdHook
 +SendSuppressedKeyUp(key) {
 +    DllCall("keybd_event"
 +        , "char", GetKeyVK(key)
 +        , "char", GetKeySC(key)
 +        , "uint", KEYEVENTF_KEYUP := 0x2
 +        , "uptr", KEY_BLOCK_THIS := 0xFFC3D450)
 +}
 +
 +; Disable Alt+key shortcuts for the IME.
 +~LAlt::SendSuppressedKeyUp("LAlt")
 +
 +; Test hotkey:
 +!CapsLock::MsgBox % A_ThisHotkey
 +
 +; Remap CapsLock to LCtrl in a way compatible with IME.
 +*CapsLock::
 +    Send {Blind}{LCtrl DownR}
 +    SendSuppressedKeyUp("LCtrl")
 +    return
 +*CapsLock up::
 +    Send {Blind}{LCtrl Up}
 +    return
 +</converter>
 +
 +===== Compiler =====
 +
 +Compile C code to an AHK-compatible loader function.
 +
 +<compiler>
 +#include <mcl.h>
 +
 +MCL_EXPORT(add, Int, a, Int, b, Cdecl_Int);
 +int add(int a, int b) {
 +    return a + b;
 +}
 +
 +MCL_EXPORT(sub, Int, a, Int, b, Cdecl_Int);
 +int sub(int a, int b) {
 +    return a - b;
 +}
 +
 +MCL_EXPORT(mul, Int, a, Int, b, Cdecl_Int);
 +int mul(int a, int b) {
 +    return a * b;
 +}
 +</compiler>
 +