summaryrefslogtreecommitdiffstats
path: root/windows/neo-vars/src/source/screenkeyboard.ahk
blob: 405364686bad1b5d5bafd687347adeea1bb1e55d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
; -*- encoding:utf-8 -*-

BSTalwaysOnTop := 1

UnZipSFXSourceLink := "ftp://ftp.info-zip.org/pub/infozip/win32/unz600xn.exe"
UnZipSFXLocalFile  := ResourceFolder . "\unzipsfx.exe"

UnZipLocalFile := ResourceFolder . "\unzip.exe"

UniFontVersion  := "2.33"
UniFontFilename := "DejaVuSans-Bold.ttf"
UniFontName     := "DejaVu Sans"

UniFontZipFilename   := "dejavu-fonts-ttf-" . UniFontVersion . ".zip"
UniFontZipLocalFile  := ResourceFolder . "\" . UniFontZipFilename

UniFontZipSourceLink := "http://downloads.sourceforge.net/project/dejavu/dejavu/" . UniFontVersion . "/" . UniFontZipFilename

UniFontLocalFilePath := ApplicationFolder
UniFontLocalFile := UniFontLocalFilePath . "/" . UniFontFilename
UniFontZipFontPath := "dejavu-fonts-ttf-" . UniFontVersion . "/ttf/" . UniFontFilename

Check_BSTUpdate(DoBSTUpdate = 0) {
  global
  if (useDBST) {
    if (!useBST and (Comp != "")) {
      useBST := 1
      BSTLastComp := ""
      CharProc__BST1()
    }
  }
  if (useBST 
      and (DoBSTUpdate
           or (Comp != BSTLastComp)
           or (EbeneC != BSTLastEbeneC)
           or (EbeneNC != BSTLastEbeneNC)))
    BSTUpdate()
  if (useDBST) {
    if (useBST and (Comp == "")) {
      useBST := 0
      BSTLastComp := ""
      CharProc__BST0()
    }
  }
}

BSTUpdate() {
    global
    static WM_SETTEXT := 0x0C
    {
      BSTLastComp := Comp
      BSTLastEbeneC := EbeneC
      BSTLastEbeneNC := EbeneNC
      VarSetCapacity(ptrU,20)
      loop,parse,GuiKeyList,`,
      {
        GuiPhysKey := A_LoopField
        if (EbeneC<3) {
          if (NOC%GuiPhysKey%==1) {
            GuiEb := EbeneNC
          } else {
	    GuiEb := EbeneC
          }
        } else
          GuiEb := EbeneC
        if (TransformBSTProc != "")
          GuiVirtKey := TransformBST%TransformBSTProc%(GuiPhysKey)
        else
          GuiVirtKey := GuiPhysKey
	CurrentComp := Comp
        GuiComp := ""
rerun_bstnupdate:
        GuiComp1 := CurrentComp . CP%GuiEb%%GuiVirtKey%
        if (GSYM%GuiComp1% != "") {
          GuiComp .= GSYM%GuiComp1%
        } else if (CD%GuiComp1% != "") {
	  G_Sym    := CD%GuiComp1%
          if (GSYM%G_Sym% != "") 
            GuiComp .= GSYM%G_sym%
          else
            GuiComp .= CD%GuiComp1%
        } else if (CM%GuiComp1% == 1) {
          GuiComp .= "U00002AU00002A"
        } else if (CF%CurrentComp% != "") {
	  if (IM%GuiVirtKey% != 1)
            GuiComp .= CF%CurrentComp%
	  CurrentComp := ""
          goto rerun_bstnupdate
        } else if (CurrentComp == "") {
          GuiComp .= GuiComp1
        }
	GuiPos := 0
        loop {
          if (GuiComp=="")
            break
	  if (SubStr(GuiComp,1,1)=="U") {
            Charcode := "0x" . Substr(GuiComp,2,6)
	      if (charCode < 0x10000) {
	        if (charCode == 0x26) {
		  ; double any Ampersand (&) to avoid being replaced with
		  ; underscore (Windows Shortcut Key terminology)
		  NumPut(CharCode, ptrU, GuiPos, "UShort")
		  GuiPos := GuiPos + 2
		}
		NumPut(CharCode, ptrU, GuiPos, "UShort")
              } else {
                ; surrogates
                NumPut(0xD800|((charCode-0x10000)/1024) , ptrU, GuiPos, "UShort")
		GuiPos := GuiPos + 2
                NumPut(0xDC00|((charCode-0x10000)&0x3FF), ptrU, GuiPos, "UShort")
              }
            GuiPos := GuiPos + 2
	  }
          GuiComp := SubStr(GuiComp,8)
        }
        NumPut(0x0   ,ptrU,GuiPos,"UShort") ; End of string	
        DllCall("SendMessageW", "UInt",GuiKey%GuiPhysKey%, "UInt",WM_SETTEXT, "UInt",0, "Uint",&ptrU)
      }
    }
    GuiControl,MoveDraw,Picture0
}

GuiAddKeyS(sc,x,y) {
  global
  GuiAddKey(vksc%sc%,x,y)
}

GuiAddKeySM(sc,x,y) {
  global
  vksc := vksc%sc%
  IM%vksc% := 1
  GuiAddKey(vksc,x,y)
}

GuiAddKeySN(sc,x,y) {
  global
  GuiAddKey(vkscn1%sc%,x,y)
}

GuiAddKey(key,x,y) {
  global
  x:=x-4
  y:=y-10
  GuiPosx%key% := x
  GuiPosy%key% := y
  Gui, Add, Text, x%x% y%y% w38 h38 Center 0x200 vGuiKey%key% hwndGuiKey%key% BackgroundTrans
  GuiKeyList := GuiKeyList . key . ","
}

CharProc__BSTt() {
  global
  ; Bildschirmtastatur togglen
  useBST := !(useBST)
  if (useBST)
    CharProc__BST1()
  else
    CharProc__BST0()
}

CharProc_DBSTt() {
  global
  useDBST := !(useDBST)
  if (useDBST) {
    if (zeigeModusBox)
      TrayTip,Dynamische Bildschirmtastatur,Die dynamische Bildschirmtastatur wurde aktiviert. Zum Deaktivieren`, Mod3+F3 druecken.,10,1
  } else {
    if (zeigeModusBox)
      TrayTip,Dynamische Bildschirmtastatur,Die dynamische Bildschirmtastatur wurde deaktiviert.,10,1
  }
}

BSTOnClose() {
  global
  useBST := 0
  CharProc__BST0()
}

BSTOnSize() {
  global
  Gui, Show, % "y" . yposition . " w" . A_GuiWidth . " h" . A_GuiWidth*199/729 . " NoActivate", Neo-Bildschirmtastatur
  Gui, Font, % "s" . A_GuiWidth*12/729 . " bold", % UniFontName
  loop,parse,GuiKeyList,`,
  {
    GuiPhysKey := A_LoopField
    GuiControl,Font,GuiKey%GuiPhysKey%
    GuiControl,Move,GuiKey%GuiPhysKey%, % "x" . GuiPosx%GuiPhysKey%*A_GuiWidth/729 . " y" . GuiPosy%GuiPhysKey%*A_GuiWidth/729 . " w" . 38*A_GuiWidth/729 . " h" . 38*A_GuiWidth/729
  }
  GuiControl,,Picture0, % "*w" . A_GuiWidth . " *h-1 " . ResourceFolder . "\ebene0.png"
}

CharProc__BST0() {
  global
  GuiCurrent := ""
  Gui, Destroy
  DllCall( "GDI32.DLL\RemoveFontResourceEx", Str, UniFontLocalFile ,UInt,(FR_PRIVATE:=0x10), Int,0)
}

CharProc__BST1() {
  global
  if (GuiCurrent!="")
    %GuiCurrent%OnClose()

  if (FileExist(ResourceFolder)!="") {
    FileInstall,ebene0.png,%ResourceFolder%\ebene0.png,1
  }

  if (FileExist(UniFontLocalFile)=="") {
    if (FileExist(UnZipLocalFile)=="") {
      Progress,0,Herunterladen des gepackten Entpack-Programms ...
      UrlDownloadToFile,%UnZipSFXSourceLink%,%UnZipSFXLocalFile%
      if (FileExist(UnZipSFXLocalFile)=="") {
        Msgbox,Konnte Unzip-Programm nicht finden und nicht installieren!
      } else {
        Progress,25,Entpacken des Entpack-Programms ...
        RunWait,% """" . UnZipSFXLocalFile . """ -d """ . ResourceFolder . """ unzip.exe",,Hide
      }
    }

    if (FileExist(UniFontZipLocalFile)=="") {
      Progress,50,Herunterladen des Fonts ...
      UrlDownloadToFile,%UniFontZipSourceLink%,%UniFontZipLocalFile%
    }

    Progress,75,Entpacken des Archivs ...
    RunWait,% """" . UnZipLocalFile . """ -j """ . UniFontZipLocalFile . """ """ . UniFontZipFontPath . """",%UniFontLocalFilePath%,Hide
    Progress,OFF
  }

  DllCall( "GDI32.DLL\AddFontResourceEx", Str, UniFontLocalFile ,UInt,(FR_PRIVATE:=0x10), Int,0)


  SysGet, WorkArea, MonitorWorkArea
  yPosition := WorkAreaBottom - 230
  Gui, Color, FFFFFF
  Gui, Add, Picture,AltSubmit x0   y0  vPicture0, % ResourceFolder . "\ebene0.png"
  Gui, Font, s12 bold, %UniFontName%
  GuiKeyList := ""
  GuiAddKeyS("029",6,9)
  GuiAddKeyS("002",44,9)
  GuiAddKeyS("003",82,9)
  GuiAddKeyS("004",120,9)
  GuiAddKeyS("005",158,9)
  GuiAddKeyS("006",196,9)
  GuiAddKeyS("007",234,9)
  GuiAddKeyS("008",272,9)
  GuiAddKeyS("009",310,9)
  GuiAddKeyS("00A",348,9)
  GuiAddKeyS("00B",386,9)
  GuiAddKeyS("00C",424,9)
  GuiAddKeyS("00D",462,9)
  GuiAddKey("backspace",510,9)

  GuiAddKey("tab",10,48)
  GuiAddKeyS("010",58,48)
  GuiAddKeyS("011",96,48)
  GuiAddKeyS("012",134,48)
  GuiAddKeyS("013",172,48)
  GuiAddKeyS("014",210,48)
  GuiAddKeyS("015",248,48)
  GuiAddKeyS("016",286,48)
  GuiAddKeyS("017",324,48)
  GuiAddKeyS("018",362,48)
  GuiAddKeyS("019",400,48)
  GuiAddKeyS("01A",438,48)
  GuiAddKeyS("01B",476,48)
  GuiAddKey("enter",526,68)

  GuiAddKeySM("03A",18,88)
  GuiAddKeyS("01E",75,88)
  GuiAddKeyS("01F",113,88)
  GuiAddKeyS("020",151,88)
  GuiAddKeyS("021",189,88)
  GuiAddKeyS("022",227,88)
  GuiAddKeyS("023",265,88)
  GuiAddKeyS("024",303,88)
  GuiAddKeyS("025",341,88)
  GuiAddKeyS("026",379,88)
  GuiAddKeyS("027",417,88)
  GuiAddKeyS("028",455,88)
  GuiAddKeySM("02B",493,88)

  GuiAddKeySM("02A",8,128)
  GuiAddKeySM("056",50,128)
  GuiAddKeyS("02C",88,128)
  GuiAddKeyS("02D",126,128)
  GuiAddKeyS("02E",164,128)
  GuiAddKeyS("02F",202,128)
  GuiAddKeyS("030",240,128)
  GuiAddKeyS("031",278,128)
  GuiAddKeyS("032",316,128)
  GuiAddKeyS("033",354,128)
  GuiAddKeyS("034",392,128)
  GuiAddKeyS("035",430,128)
  GuiAddKeySM("136",498,128)

  GuiAddKey("space",264,168)
  GuiAddKeySM("138",430,168)

  GuiAddKeyS("145",582,9)
  GuiAddKeyS("135",620,9)
  GuiAddKeyS("037",658,9)
  GuiAddKeyS("04A",696,9)

  GuiAddKeySN("047",582,48)
  GuiAddKeySN("048",620,48)
  GuiAddKeySN("049",658,48)
  GuiAddKeyS("04E",696,68)

  GuiAddKeySN("04B",582,88)
  GuiAddKeySN("04C",620,88)
  GuiAddKeySN("04D",658,88)

  GuiAddKeySN("04F",582,128)
  GuiAddKeySN("050",620,128)
  GuiAddKeySN("051",658,128)
  GuiAddKey("numpadenter",696,148)

  GuiAddKeySN("052",601,168)
  GuiAddKeySN("053",658,168)
  Gui, +AlwaysOnTop +ToolWindow +Resize -MaximizeBox
  Gui, Show, y%yposition% w729 h199 NoActivate, Neo-Bildschirmtastatur
  BSTUpdate()
  BSTalwaysOnTop := 1
  GuiCurrent := "BST"
}

BSTToggleAlwaysOnTop() {
  global
  if (BSTalwaysOnTop) {
    Gui, -AlwaysOnTop
    BSTalwaysOnTop := 0    
  } else {
    Gui, +AlwaysOnTop
    BSTalwaysOnTop := 1
  }
}

CharProc__BSTA() {
  global
  ; Bildschirmtastatur AlwaysOnTop
  if (useBST or useDBST)
    BSTToggleAlwaysOnTop()
}

GUISYM(sym,chars) {
  global
  GSYM%sym% := EncodeUniComposeA(chars)
}

BSTSymbols() {
  global
  ; diverse Symbole für Spezialzeichen
  GUISYM("T__cflx","◌̂")
  GUISYM("T__cron","◌̌")
  GUISYM("T__turn","↻")
  GUISYM("T__abdt","◌̇")
  GUISYM("T__hook","◌˞") ; not perfect
  GUISYM("T__bldt",".") ; not perfect

  GUISYM("T__grav","◌̀")
  GUISYM("T__cedi","◌̧")
  GUISYM("T__abrg","◌̊")
  GUISYM("T__drss","◌̈")
  GUISYM("T_dasia","◌῾") ; not perfect
  GUISYM("T__mcrn","◌̄")

  GUISYM("T__acut","◌́")
  GUISYM("T__tlde","◌̃")
  GUISYM("T__strk","◌̷")
  GUISYM("T__dbac","◌̋")
  GUISYM("T_psili","◌᾿") ; not perfect
  GUISYM("T__brve","◌̆")



  GUISYM("S__Sh_L","⇧")
  GUISYM("S__Sh_R","⇧")
  GUISYM("S__Caps","⇪")
  GUISYM("S___Del","⌦")
  GUISYM("S___Ins","⎀")
  GUISYM("S____Up","⇡")
  GUISYM("S__Down","⇣")
  GUISYM("S__Rght","⇢")
  GUISYM("S__Left","⇠")
  GUISYM("S__PgUp","⇞")
  GUISYM("S__PgDn","⇟")
  GUISYM("S__Home","↸")
  GUISYM("S___End","⇲")

  GUISYM("S__N__0","0")
  GUISYM("S__N__1","1")
  GUISYM("S__N__2","2")
  GUISYM("S__N__3","3")
  GUISYM("S__N__4","4")
  GUISYM("S__N__5","5")
  GUISYM("S__N__6","6")
  GUISYM("S__N__7","7")
  GUISYM("S__N__8","8")
  GUISYM("S__N__9","9")
  GUISYM("S__NDiv","÷")
  GUISYM("S__NMul","×")
  GUISYM("S__NSub","-")
  GUISYM("S__NAdd","+")
  GUISYM("S__NDot",",")
  GUISYM("S__NEnt","⏎")

  GUISYM("S__NDel","⌦")
  GUISYM("S__NIns","⎀")
  GUISYM("S__N_Up","⇡")
  GUISYM("S__N_Dn","⇣")
  GUISYM("S__N_Ri","⇢")
  GUISYM("S__N_Le","⇠")
  GUISYM("S__NPUp","⇞")
  GUISYM("S__NPDn","⇟")
  GUISYM("S__NHom","↸")
  GUISYM("S__NEnd","⇲")

  GUISYM("S_SNDel","⌦")
  GUISYM("S_SNIns","⎀")
  GUISYM("S_SN_Up","⇡")
  GUISYM("S_SN_Dn","⇣")
  GUISYM("S_SN_Ri","⇢")
  GUISYM("S_SN_Le","⇠")
  GUISYM("S_SNPUp","⇞")
  GUISYM("S_SNPDn","⇟")
  GUISYM("S_SNHom","↸")
  GUISYM("S_SNEnd","⇲")

  GUISYM("U00001B","⌧")
  GUISYM("U000008","⌫")
  GUISYM("U000009","↹")
  GUISYM("U00000D","⏎")

  GUISYM("P__M2LD","⇧")
  GUISYM("P__M2RD","⇧")
  GUISYM("P__M3LD","M3")
  GUISYM("P__M3RD","M3")
  GUISYM("P__M4LD","M4")
  GUISYM("P__M4RD","M4")

  GUISYM("U000020","␣")
  GUISYM("U0000A0","⍽")
  GUISYM("U00202F",">⍽<")
}

BSTRegister() {
  global

  CP3F1 := "P__BSTt"
  CP3F2 := "P__BSTA"
  CP3F3 := "P_DBSTt"
  BSTSymbols()

  IniRead,useBST,%ini%,Global,useBST,0
  if (useBST)
    CharProc__BST1()

  IniRead,useDBST,%ini%,Global,useDBST,0
}

BSTRegister()