Autohotkey: envoie des caractères unicode hexadécimaux à 5 chiffres

J’ai essayé de trouver un moyen de remapper mon clavier et d’envoyer des caractères unicode hexadécimaux à 5 chiffres, la méthode décrite ici: ahk Send ne prend en charge que les codes hexadécimaux à 4 chiffres {U + nnnn} supporte nativement unicode, il fallait donc certaines fonctions pour y parvenir, c’est peut-être la solution pour moi.

Exemple:

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

Le résultat est is au lieu de 𝒰 et le code pour 풰 est {U + D4B0}, ce qui signifie que AHK ne lit que les 4 derniers chiffres. Comment puis-je résoudre ce problème même si je dois créer de nouvelles fonctions pour y parvenir?

Merci

-Marque

Les valeurs Unicode supérieures à 0xFFFF doivent être codées en deux paires de substitution:

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

Voici l’algorithme pour convertir un sharepoint code Unicode compris entre 0x10000 et 0x10FFFF, pour remplacer les paires, paraphrasé à partir de wikipedia :

Tout d’abord soustraire 0x10000 du sharepoint code , pour obtenir un nombre dans la plage 0xFFFFF.

Puis déplacez à droite le nombre de 10 bits et ajoutez-y 0xD800 pour obtenir le substitut élevé .

Prenez les dix derniers bits du nombre et ajoutez-y 0xDC00 pour obtenir le substitut faible

J’ai pris la solution de 2501 par le haut et je l’ai transformée en un script ahk fonctionnel. Cela fait des mois que je recherche cette solution depuis des mois!

 +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. ;sortinged 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 } 

De quelque part sur internet: 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) } 

modifier. probablement obtenu bc de la source manquante. Je ne sais simplement pas d’où je viens. Mais quand je l’ai utilisé il y a quelques années, cela a fonctionné sans problème.