Autohotkey:发送5位hexUnicode字符

我一直在试图find一种方法来重新映射我的键盘和发送5位hexUnicode字符,这里描述的方法: ahk发送只支持4位hex代码{U + nnnn},我知​​道在过去,autohotkey没有本地支持unicode,所以需要一些function才能做到这一点,也许这就是我的解决scheme。

例:

#If GetKeyState("CapsLock","T") +u::Send {U+1D4B0} 

结果是풰而不是and,풰的代码是{U + D4B0},这意味着AHK只读取最后4位数字。 即使我需要做出新的function来实现这个function,我该如何修复它?

谢谢

-标记

Solutions Collecting From Web of "Autohotkey:发送5位hexUnicode字符"

大于0xFFFF的Unicode值必须被编码为两个代理对:

 +u:: SendInput ,{U+D835}{U+DCB0} 

以下是将范围为0x10000的Unicode 代码点转换为0x10FFFF的代码转换为从wikipedia转义的代理对的算法:

首先从代码点中减去0x10000,得到范围为0xFFFFF的数字

然后右移10位的数字 ,并添加0xD800来获得高代理

取数字的最低十位,并加上0xDC00来取代低位代理

我从上面拿走了2501的解决方案,并把它变成了一个工作的ahk脚本。 我一直在寻找和解决这个解决方案数月!

 +u:: FUNC_SEND_UNICODE( 0x1D4B0 ) FUNC_SEND_UNICODE(func_args) { /* ;commented out proof of concept code: str := "" u1 := Chr( 0xD835 ) u2 := Chr( 0xDCB0 ) str := u1 . u2 bk := clipboard clipboard := str send, ^v sleep,200 clipboard := bk */ ;bk == "clipboard [B]ac[K]up bk := clipboard ;chunk of data that needs to be cut into ;two chunks. ful := func_args + 0 /* commented out testing code, using original sample input of stack overflow post ;msgbox,ful:[%ful%] ;for testing. Expecting input to be equal to ;the value in the post. if(ful != 0x1D4B0 ){ msgbox,"[WHATTHEHECK]" } */ ;Subtract 0x10000 from ful, gets number ;in range(rng) 0x0 to 0xFFFFFF inclusive rng := ful - 0x10000 if(rng > 0xFFFFF) { msgBox,[Step1 Resulted In Out Of Range] } ;Do shifting and masking, then check to make ;sure the value is in the expected range: big_shif := (rng >> 10) lit_mask := (rng & 0x3FF) if(big_shif > 0x3FF) { msgBox,[MATH_ERROR:big_shif] } if(lit_mask > 0x3FF) { msgBox,[MATH_ERROR:lit_mask] } big := big_shif + 0xD800 lit := lit_mask + 0xDC00 if(big < 0xD800 || big >= 0xDBFF){ msgBox, [HIGH_SURROGATE_OUT_OF_BOUNDS] } if(lit < 0xDC00 || lit >= 0xDFFF){ msgBox, [LOW_SURROGATE_OUT_OF_BOUNDS] } ;Convert code points to actual characters: u1 := Chr( big ) u2 := Chr( lit ) ;concatentate those two characters to ;create our final surrogate output: str := u1 . u2 ;set it equal to clipboard, and send ;the clipboard. This is a hack. ;send,%str% works fine in google chrome, ;but fails in notepad++ for some reason. ;tried appending EOF, STX, ETX control codes ;along with output, but to no effect. clipboard := str send, ^v ;Must sleep before restoring clipboard, ;otherwise, the clipboard will get ;overwritten before ctrl+v has the chance ;to output the character. You'll end up just ;pasting whatever was originally on the ;clipboard. sleep,200 clipboard := bk return } 

从互联网上的某个地方: sendunicodechar(0x1D4B0)

 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) } 

编辑。 可能是因为缺少源码而被低估了。 我只是不知道我从哪里得到它。 但是当我几年前使用它时,它完美地工作。