How do I use Unicode in AutoHotKey?

前端 未结 4 1294
盖世英雄少女心
盖世英雄少女心 2021-02-05 03:10

I am trying to make two hyphens trigger a short dash, and three hyphens trigger a long dash; like

:*?:---=::—
:*?:--=::–

except working. Here i

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-05 03:44

    EDIT: don't bother reading my answer, follow Udo Klein instruction, it's much easier and it works as it should.

    how to send unicode characters using the last autohotkey version? (no need of previous unicode-compatible version to work)

    Quite hard to find clear information. So to makes it clear for the beginners (like me):

    1. copy/past the "code A" that at the end of your script (it should be in encoded in ANSI)
    2. copy/past the "code B" on the top of your script
    3. find your unicode character code here http://www.utf8-chartable.de/unicode-utf8-table.pl
    4. copy the 4 figures after the U+
    5. in the code B (on the top of your script): change the key you need (before the "::")
    6. in the code B (on the top of your script): past the unicode you found on 2. AFTER the 0x (instead of the "2260")
    7. save your script
    8. double click on the icon of your script, it will replace/update the previous version

    Code A:

    SendUnicodeChar(charCode)
    {
    VarSetCapacity(ki, 28 * 2, 0)
    EncodeInteger(&ki + 0, 1)
    EncodeInteger(&ki + 6, charCode)
    EncodeInteger(&ki + 8, 4)
    EncodeInteger(&ki +28, 1)
    EncodeInteger(&ki +34, charCode)
    EncodeInteger(&ki +36, 4|2)
    
    
    DllCall("SendInput", "UInt", 2, "UInt", &ki, "Int", 28)
    }
    
    
    EncodeInteger(ref, val)
    {
    DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", 4, "Uint", val)}
    

    Code B:

    !+^D::  ; when press CTRL+ALT+SHIFT will output "≠"
    { 
    SendUnicodeChar(0x2260) 
    }
    return
    

    (watch the space!)

    Improvement needed:

    somehow this script doesn't work for all the unicode given by this website http://unicode-table.com/ , but someone will maybe be kind enough to tell us why some unicode are working and other don't, and maybe how to make it work for any unicode characters of this website. This one for instance http://unicode-table.com/en/0609/ doesn't work. Any idea why?

提交回复
热议问题