root/windows/neo-vars/src/source/screenkeyboard.ahk @ 2402

Revision 2402, 11.9 KB (checked in by mösi, 22 months ago)

Bildschirmtastatur: Wenn der Font (erstmalig) heruntergeladen wird, kommt jetzt ein neuer unzip zum Einsatz, der allerdings als SFX-Archiv heruntergeladen und selbst erst entpackt werden muss. Sollte als Win32-Applikation jetzt auch unter 64-Bit-Windows laufen.

Line 
1; -*- encoding:utf-8 -*-
2
3BSTalwaysOnTop := 1
4
5UnZipSFXSourceLink := "ftp://ftp.info-zip.org/pub/infozip/win32/unz600xn.exe"
6UnZipSFXLocalFile  := ResourceFolder . "\unzipsfx.exe"
7
8UnZipLocalFile := ResourceFolder . "\unzip.exe"
9
10UniFontVersion  := "2.33"
11UniFontFilename := "DejaVuSans-Bold.ttf"
12UniFontName     := "DejaVu Sans"
13
14UniFontZipFilename   := "dejavu-fonts-ttf-" . UniFontVersion . ".zip"
15UniFontZipLocalFile  := ResourceFolder . "\" . UniFontZipFilename
16
17UniFontZipSourceLink := "http://downloads.sourceforge.net/project/dejavu/dejavu/" . UniFontVersion . "/" . UniFontZipFilename
18
19UniFontLocalFilePath := ApplicationFolder
20UniFontLocalFile := UniFontLocalFilePath . "/" . UniFontFilename
21UniFontZipFontPath := "dejavu-fonts-ttf-" . UniFontVersion . "/ttf/" . UniFontFilename
22
23Check_BSTUpdate(DoBSTUpdate = 0) {
24  global
25  if (useDBST) {
26    if (!useBST and (Comp != "")) {
27      useBST := 1
28      BSTLastComp := ""
29      CharProc__BST1()
30    }
31  }
32  if (useBST
33      and (DoBSTUpdate
34           or (Comp != BSTLastComp)
35           or (EbeneC != BSTLastEbeneC)
36           or (EbeneNC != BSTLastEbeneNC)))
37    BSTUpdate()
38  if (useDBST) {
39    if (useBST and (Comp == "")) {
40      useBST := 0
41      BSTLastComp := ""
42      CharProc__BST0()
43    }
44  }
45}
46
47BSTUpdate() {
48    global
49    static WM_SETTEXT := 0x0C
50    {
51      BSTLastComp := Comp
52      BSTLastEbeneC := EbeneC
53      BSTLastEbeneNC := EbeneNC
54      VarSetCapacity(ptrU,20)
55      loop,parse,GuiKeyList,`,
56      {
57        GuiPhysKey := A_LoopField
58        if (EbeneC<3) {
59          if (NOC%GuiPhysKey%==1) {
60            GuiEb := EbeneNC
61          } else {
62            GuiEb := EbeneC
63          }
64        } else
65          GuiEb := EbeneC
66        if (TransformBSTProc != "")
67          GuiVirtKey := TransformBST%TransformBSTProc%(GuiPhysKey)
68        else
69          GuiVirtKey := GuiPhysKey
70        CurrentComp := Comp
71        GuiComp := ""
72rerun_bstnupdate:
73        GuiComp1 := CurrentComp . CP%GuiEb%%GuiVirtKey%
74        if (GSYM%GuiComp1% != "") {
75          GuiComp .= GSYM%GuiComp1%
76        } else if (CD%GuiComp1% != "") {
77          G_Sym    := CD%GuiComp1%
78          if (GSYM%G_Sym% != "")
79            GuiComp .= GSYM%G_sym%
80          else
81            GuiComp .= CD%GuiComp1%
82        } else if (CM%GuiComp1% == 1) {
83          GuiComp .= "U00002AU00002A"
84        } else if (CF%CurrentComp% != "") {
85          if (IM%GuiVirtKey% != 1)
86            GuiComp .= CF%CurrentComp%
87          CurrentComp := ""
88          goto rerun_bstnupdate
89        } else if (CurrentComp == "") {
90          GuiComp .= GuiComp1
91        }
92        GuiPos := 0
93        loop {
94          if (GuiComp=="")
95            break
96          if (SubStr(GuiComp,1,1)=="U") {
97            Charcode := "0x" . Substr(GuiComp,2,6)
98              if (charCode < 0x10000) {
99                if (charCode == 0x26) {
100                  ; double any Ampersand (&) to avoid being replaced with
101                  ; underscore (Windows Shortcut Key terminology)
102                  NumPut(CharCode, ptrU, GuiPos, "UShort")
103                  GuiPos := GuiPos + 2
104                }
105                NumPut(CharCode, ptrU, GuiPos, "UShort")
106              } else {
107                ; surrogates
108                NumPut(0xD800|((charCode-0x10000)/1024) , ptrU, GuiPos, "UShort")
109                GuiPos := GuiPos + 2
110                NumPut(0xDC00|((charCode-0x10000)&0x3FF), ptrU, GuiPos, "UShort")
111              }
112            GuiPos := GuiPos + 2
113          }
114          GuiComp := SubStr(GuiComp,8)
115        }
116        NumPut(0x0   ,ptrU,GuiPos,"UShort") ; End of string     
117        DllCall("SendMessageW", "UInt",GuiKey%GuiPhysKey%, "UInt",WM_SETTEXT, "UInt",0, "Uint",&ptrU)
118      }
119    }
120    GuiControl,MoveDraw,Picture0
121}
122
123GuiAddKeyS(sc,x,y) {
124  global
125  GuiAddKey(vksc%sc%,x,y)
126}
127
128GuiAddKeySM(sc,x,y) {
129  global
130  vksc := vksc%sc%
131  IM%vksc% := 1
132  GuiAddKey(vksc,x,y)
133}
134
135GuiAddKeySN(sc,x,y) {
136  global
137  GuiAddKey(vkscn1%sc%,x,y)
138}
139
140GuiAddKey(key,x,y) {
141  global
142  x:=x-4
143  y:=y-10
144  GuiPosx%key% := x
145  GuiPosy%key% := y
146  Gui, Add, Text, x%x% y%y% w38 h38 Center 0x200 vGuiKey%key% hwndGuiKey%key% BackgroundTrans
147  GuiKeyList := GuiKeyList . key . ","
148}
149
150CharProc__BSTt() {
151  global
152  ; Bildschirmtastatur togglen
153  useBST := !(useBST)
154  if (useBST)
155    CharProc__BST1()
156  else
157    CharProc__BST0()
158}
159
160CharProc_DBSTt() {
161  global
162  useDBST := !(useDBST)
163  if (useDBST) {
164    if (zeigeModusBox)
165      TrayTip,Dynamische Bildschirmtastatur,Die dynamische Bildschirmtastatur wurde aktiviert. Zum Deaktivieren`, Mod3+F3 druecken.,10,1
166  } else {
167    if (zeigeModusBox)
168      TrayTip,Dynamische Bildschirmtastatur,Die dynamische Bildschirmtastatur wurde deaktiviert.,10,1
169  }
170}
171
172BSTOnClose() {
173  global
174  useBST := 0
175  CharProc__BST0()
176}
177
178BSTOnSize() {
179  global
180  Gui, Show, % "y" . yposition . " w" . A_GuiWidth . " h" . A_GuiWidth*199/729 . " NoActivate", Neo-Bildschirmtastatur
181  Gui, Font, % "s" . A_GuiWidth*12/729 . " bold", % UniFontName
182  loop,parse,GuiKeyList,`,
183  {
184    GuiPhysKey := A_LoopField
185    GuiControl,Font,GuiKey%GuiPhysKey%
186    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
187  }
188  GuiControl,,Picture0, % "*w" . A_GuiWidth . " *h-1 " . ResourceFolder . "\ebene0.png"
189}
190
191CharProc__BST0() {
192  global
193  GuiCurrent := ""
194  Gui, Destroy
195  DllCall( "GDI32.DLL\RemoveFontResourceEx", Str, UniFontLocalFile ,UInt,(FR_PRIVATE:=0x10), Int,0)
196}
197
198CharProc__BST1() {
199  global
200  if (GuiCurrent!="")
201    %GuiCurrent%OnClose()
202
203  if (FileExist(ResourceFolder)!="") {
204    FileInstall,ebene0.png,%ResourceFolder%\ebene0.png,1
205  }
206
207  if (FileExist(UniFontLocalFile)=="") {
208    if (FileExist(UnZipLocalFile)=="") {
209      Progress,0,Herunterladen des gepackten Entpack-Programms ...
210      UrlDownloadToFile,%UnZipSFXSourceLink%,%UnZipSFXLocalFile%
211      if (FileExist(UnZipSFXLocalFile)=="") {
212        Msgbox,Konnte Unzip-Programm nicht finden und nicht installieren!
213      } else {
214        Progress,25,Entpacken des Entpack-Programms ...
215        RunWait,% """" . UnZipSFXLocalFile . """ -d """ . ResourceFolder . """ unzip.exe",,Hide
216      }
217    }
218
219    if (FileExist(UniFontZipLocalFile)=="") {
220      Progress,50,Herunterladen des Fonts ...
221      UrlDownloadToFile,%UniFontZipSourceLink%,%UniFontZipLocalFile%
222    }
223
224    Progress,75,Entpacken des Archivs ...
225    RunWait,% """" . UnZipLocalFile . """ -j """ . UniFontZipLocalFile . """ """ . UniFontZipFontPath . """",%UniFontLocalFilePath%,Hide
226    Progress,OFF
227  }
228
229  DllCall( "GDI32.DLL\AddFontResourceEx", Str, UniFontLocalFile ,UInt,(FR_PRIVATE:=0x10), Int,0)
230
231
232  SysGet, WorkArea, MonitorWorkArea
233  yPosition := WorkAreaBottom - 230
234  Gui, Color, FFFFFF
235  Gui, Add, Picture,AltSubmit x0   y0  vPicture0, % ResourceFolder . "\ebene0.png"
236  Gui, Font, s12 bold, %UniFontName%
237  GuiKeyList := ""
238  GuiAddKeyS("029",6,9)
239  GuiAddKeyS("002",44,9)
240  GuiAddKeyS("003",82,9)
241  GuiAddKeyS("004",120,9)
242  GuiAddKeyS("005",158,9)
243  GuiAddKeyS("006",196,9)
244  GuiAddKeyS("007",234,9)
245  GuiAddKeyS("008",272,9)
246  GuiAddKeyS("009",310,9)
247  GuiAddKeyS("00A",348,9)
248  GuiAddKeyS("00B",386,9)
249  GuiAddKeyS("00C",424,9)
250  GuiAddKeyS("00D",462,9)
251  GuiAddKey("backspace",510,9)
252
253  GuiAddKey("tab",10,48)
254  GuiAddKeyS("010",58,48)
255  GuiAddKeyS("011",96,48)
256  GuiAddKeyS("012",134,48)
257  GuiAddKeyS("013",172,48)
258  GuiAddKeyS("014",210,48)
259  GuiAddKeyS("015",248,48)
260  GuiAddKeyS("016",286,48)
261  GuiAddKeyS("017",324,48)
262  GuiAddKeyS("018",362,48)
263  GuiAddKeyS("019",400,48)
264  GuiAddKeyS("01A",438,48)
265  GuiAddKeyS("01B",476,48)
266  GuiAddKey("enter",526,68)
267
268  GuiAddKeySM("03A",18,88)
269  GuiAddKeyS("01E",75,88)
270  GuiAddKeyS("01F",113,88)
271  GuiAddKeyS("020",151,88)
272  GuiAddKeyS("021",189,88)
273  GuiAddKeyS("022",227,88)
274  GuiAddKeyS("023",265,88)
275  GuiAddKeyS("024",303,88)
276  GuiAddKeyS("025",341,88)
277  GuiAddKeyS("026",379,88)
278  GuiAddKeyS("027",417,88)
279  GuiAddKeyS("028",455,88)
280  GuiAddKeySM("02B",493,88)
281
282  GuiAddKeySM("02A",8,128)
283  GuiAddKeySM("056",50,128)
284  GuiAddKeyS("02C",88,128)
285  GuiAddKeyS("02D",126,128)
286  GuiAddKeyS("02E",164,128)
287  GuiAddKeyS("02F",202,128)
288  GuiAddKeyS("030",240,128)
289  GuiAddKeyS("031",278,128)
290  GuiAddKeyS("032",316,128)
291  GuiAddKeyS("033",354,128)
292  GuiAddKeyS("034",392,128)
293  GuiAddKeyS("035",430,128)
294  GuiAddKeySM("136",498,128)
295
296  GuiAddKey("space",264,168)
297  GuiAddKeySM("138",430,168)
298
299  GuiAddKeyS("145",582,9)
300  GuiAddKeyS("135",620,9)
301  GuiAddKeyS("037",658,9)
302  GuiAddKeyS("04A",696,9)
303
304  GuiAddKeySN("047",582,48)
305  GuiAddKeySN("048",620,48)
306  GuiAddKeySN("049",658,48)
307  GuiAddKeyS("04E",696,68)
308
309  GuiAddKeySN("04B",582,88)
310  GuiAddKeySN("04C",620,88)
311  GuiAddKeySN("04D",658,88)
312
313  GuiAddKeySN("04F",582,128)
314  GuiAddKeySN("050",620,128)
315  GuiAddKeySN("051",658,128)
316  GuiAddKey("numpadenter",696,148)
317
318  GuiAddKeySN("052",601,168)
319  GuiAddKeySN("053",658,168)
320  Gui, +AlwaysOnTop +ToolWindow +Resize -MaximizeBox
321  Gui, Show, y%yposition% w729 h199 NoActivate, Neo-Bildschirmtastatur
322  BSTUpdate()
323  BSTalwaysOnTop := 1
324  GuiCurrent := "BST"
325}
326
327BSTToggleAlwaysOnTop() {
328  global
329  if (BSTalwaysOnTop) {
330    Gui, -AlwaysOnTop
331    BSTalwaysOnTop := 0   
332  } else {
333    Gui, +AlwaysOnTop
334    BSTalwaysOnTop := 1
335  }
336}
337
338CharProc__BSTA() {
339  global
340  ; Bildschirmtastatur AlwaysOnTop
341  if (useBST or useDBST)
342    BSTToggleAlwaysOnTop()
343}
344
345GUISYM(sym,chars) {
346  global
347  GSYM%sym% := EncodeUniComposeA(chars)
348}
349
350BSTSymbols() {
351  global
352  ; diverse Symbole für Spezialzeichen
353  GUISYM("T__cflx","◌̂")
354  GUISYM("T__cron","◌̌")
355  GUISYM("T__turn","↻")
356  GUISYM("T__abdt","◌̇")
357  GUISYM("T__hook","◌˞") ; not perfect
358  GUISYM("T__bldt",".") ; not perfect
359
360  GUISYM("T__grav","◌̀")
361  GUISYM("T__cedi","◌̧")
362  GUISYM("T__abrg","◌̊")
363  GUISYM("T__drss","◌̈")
364  GUISYM("T_dasia","◌῾") ; not perfect
365  GUISYM("T__mcrn","◌̄")
366
367  GUISYM("T__acut","◌́")
368  GUISYM("T__tlde","◌̃")
369  GUISYM("T__strk","◌̷")
370  GUISYM("T__dbac","◌̋")
371  GUISYM("T_psili","◌᾿") ; not perfect
372  GUISYM("T__brve","◌̆")
373
374
375
376  GUISYM("S__Sh_L","⇧")
377  GUISYM("S__Sh_R","⇧")
378  GUISYM("S__Caps","⇪")
379  GUISYM("S___Del","⌦")
380  GUISYM("S___Ins","⎀")
381  GUISYM("S____Up","⇡")
382  GUISYM("S__Down","⇣")
383  GUISYM("S__Rght","⇢")
384  GUISYM("S__Left","⇠")
385  GUISYM("S__PgUp","⇞")
386  GUISYM("S__PgDn","⇟")
387  GUISYM("S__Home","↸")
388  GUISYM("S___End","⇲")
389
390  GUISYM("S__N__0","0")
391  GUISYM("S__N__1","1")
392  GUISYM("S__N__2","2")
393  GUISYM("S__N__3","3")
394  GUISYM("S__N__4","4")
395  GUISYM("S__N__5","5")
396  GUISYM("S__N__6","6")
397  GUISYM("S__N__7","7")
398  GUISYM("S__N__8","8")
399  GUISYM("S__N__9","9")
400  GUISYM("S__NDiv","÷")
401  GUISYM("S__NMul","×")
402  GUISYM("S__NSub","-")
403  GUISYM("S__NAdd","+")
404  GUISYM("S__NDot",",")
405  GUISYM("S__NEnt","⏎")
406
407  GUISYM("S__NDel","⌦")
408  GUISYM("S__NIns","⎀")
409  GUISYM("S__N_Up","⇡")
410  GUISYM("S__N_Dn","⇣")
411  GUISYM("S__N_Ri","⇢")
412  GUISYM("S__N_Le","⇠")
413  GUISYM("S__NPUp","⇞")
414  GUISYM("S__NPDn","⇟")
415  GUISYM("S__NHom","↸")
416  GUISYM("S__NEnd","⇲")
417
418  GUISYM("S_SNDel","⌦")
419  GUISYM("S_SNIns","⎀")
420  GUISYM("S_SN_Up","⇡")
421  GUISYM("S_SN_Dn","⇣")
422  GUISYM("S_SN_Ri","⇢")
423  GUISYM("S_SN_Le","⇠")
424  GUISYM("S_SNPUp","⇞")
425  GUISYM("S_SNPDn","⇟")
426  GUISYM("S_SNHom","↸")
427  GUISYM("S_SNEnd","⇲")
428
429  GUISYM("U00001B","⌧")
430  GUISYM("U000008","⌫")
431  GUISYM("U000009","↹")
432  GUISYM("U00000D","⏎")
433
434  GUISYM("P__M2LD","⇧")
435  GUISYM("P__M2RD","⇧")
436  GUISYM("P__M3LD","M3")
437  GUISYM("P__M3RD","M3")
438  GUISYM("P__M4LD","M4")
439  GUISYM("P__M4RD","M4")
440
441  GUISYM("U000020","␣")
442  GUISYM("U0000A0","⍽")
443  GUISYM("U00202F",">⍽<")
444}
445
446BSTRegister() {
447  global
448
449  CP3F1 := "P__BSTt"
450  CP3F2 := "P__BSTA"
451  CP3F3 := "P_DBSTt"
452  BSTSymbols()
453
454  IniRead,useBST,%ini%,Global,useBST,0
455  if (useBST)
456    CharProc__BST1()
457
458  IniRead,useDBST,%ini%,Global,useDBST,0
459}
460
461BSTRegister()
Note: See TracBrowser for help on using the browser.