windows - Create custom keyboard layout with AutoHotKey (or something else) -


i'm looking create custom keyboard layout, typing unicode math symbols. symbol set need large, , scheme came involves multiple layouts , special combinations.

i type ` (backtick) once , instead special character we'll symbolize *. typing additional keys, specific keyboard layouts relevant particular theme. (i want replace tick special symbol remember it's control code of sorts. typing twice, normal tick)

here example mappings:

*s -> set theory layout:     [ -> ∈ (element of)     o -> ∅ (empty set)  *r -> general math:     s -> ∫ (integral sign)     s -> ∬ (double integral sign)  *e -> misc operators:     8 -> ∗ (convolution asterisk)     * -> ⋆ (star operator)  *g -> greek alphabet 

after typing character such =, can type few other special combinations modify character. example:

*x -> negates previous character:     = -> ≠ (unequal)     ≡ -> ≢ (negation of 3 line equality)  *w -> expands previous character:     ∫ -> ∭ (triple integral)     ∬ -> ⨌ (quad integral) 

the mappings mnemonic. conceivably cram symbols want onto single layout, unusable, want try stick scheme or similar.

the keyboard windows environment, there no question of me writing keyboard dlls myself. looked , it's way complicated.

right now, i'm looking ahk solution. can done in ahk (or similar)? if so, show me examples me started?

i'd know if there other ways this.

i'm aware of microsoft keyboard layout creator, , have used in past, it's not powerful enough. i'm aware of keyman tavultesoft, , know fact can want, it's absurdly expensive, it's not option.

what need can done autohotkey.

the tricky part is: need assign hotkeys , hotstrings dynamically. former possible hotkey-command, latter has not yet been implemented , never be. can either write them new .ahk-file , execute script seperately, or use polyethene's awesome dynamical regex hotstring creator. autohotkey.net's repository has been down years, found script here. following example script running, you'll need download script hotstrings.ahk , put in same directory main .ahk-file be.

however, haven't been able assign layout changer hotkey

` 

, set ä.

i know site not code-provider-network, have major interest in issue well.

#noenv sendmode input setworkingdir %a_scriptdir% #include hotstrings.ahk  lastkey := ""  ; keys of normal layout should negatable: hotstrings("=", "_equals")  ;  ; choose layout or negate/expand last character: :*?:ä:: ; backspacepressed:  ; wtf this? sorry saw now. not belong here, not belong anywhere     sendraw *     tooltip,      (     n   normal layout      s   set theory     r   general math      x   negate previous     w   expand previous      {esc}   cancel     ), %a_caretx%, %a_carety%     input, layout, l1, {escape}, s,r,e,g,x,w     send {backspace}    ; remove *     if layout in n,s,r,e,g,x,w     {         tooltip, %layout%, %a_caretx%, %a_carety%          ; reset         if layout = n         {             reset_all_hotstrings()              ; keys of normal layout should negatable:             hotstrings("=", "_equals")         }            ; new layout         else if layout = s         {             reset_all_hotstrings()              ; set theory shortcuts             hotstrings("o", "_emptyset")             hotstrings("\[", "_elementof")         }         else if layout = r         {             reset_all_hotstrings()              ; math shortcuts             hotstrings("s", "_integral")             hotstrings("s", "_doubleintegral")             hotstrings("=", "_identical")         }         ; , on         ; ...            ; edit previous character         else if layout = x         {             send {backspace}              if lastkey = identical                 sendunicodechar(0x2262)             else if lastkey = equals                 sendunicodechar(0x2260)         }         ; expand previous character         else if layout = w         {             send {backspace}              if lastkey = integral                 sendunicodechar(0x222d)             else if lastkey = doubleintegral                 sendunicodechar(0x2a0c)         }     }     else     {         tooltip, cancelled, %a_caretx%, %a_carety%     }     sleep, 500     tooltip return  reset_all_hotstrings() {     hotstrings("=")     hotstrings("\[")     hotstrings("o")     hotstrings("s")     hotstrings("s")     ; , on }  ; normal layout shortcuts: _equals:     sendunicodechar(0x003d)     lastkey = equals return    ; special layout shortcuts: _emptyset:     ;sendunicodechar(0x00d8)     altnumpad(0216)         ; find out numpad combination or unicode: press win+r, type in "charmap"         ; or unicode only, go http://www.fileformat.info/info/unicode/category/index.htm         ; (sendunicodchar() needs 0x before unicode string)     ;altnumpad(0248)     ;send Ø     ;send ø     ;   choose whatever works best     lastkey = emptyset return  _elementof:     sendunicodechar(0x2208)     lastkey = elementof return  _integral:     sendunicodechar(0x222b)     lastkey = integral return  _identical:     sendunicodechar(0x2261)     lastkey = identical return  _doubleintegral:     sendunicodechar(0x222c)     lastkey = doubleintegral return  ; -------------------------------------------  altnumpad(numbers) {     stringsplit, n, numbers     setkeydelay, 100     send {alt down}     loop, %n0%     {         t := n%a_index%         send {numpad%t%}     }     send {alt up} }   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) }  ^e::reload 

there room improvement, obviously


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -