AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Tastatur multilingual

Ein Thema von Ghostwalker · begonnen am 9. Jul 2003 · letzter Beitrag vom 20. Jul 2003
Antwort Antwort
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#1

Tastatur multilingual

  Alt 9. Jul 2003, 08:27
Also..folgendes Problem:

Ich suche nach einer Möglichkeit, herauszufinden welche Tastencodes welches Zeichen ergeben. Das Problem dabei ist das das ganze möglichst im mehrsprachigen Umfeld funktionieren sollte.

Beispiel:
deutsche Tastatur:
# = 191

englische Tastatur:

# = Shift+51

Weiß jemand wie man das möglichst einfach ermitteln kann ?
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
Tiefflieger

Registriert seit: 20. Mai 2003
18 Beiträge
 
Delphi 6 Personal
 
#2

Re: Tastatur multilingual

  Alt 10. Jul 2003, 17:19
meinst du die ascii-codes? die ist doch international:

http://www.asciitable.com/
Irren ist menschlich.
Aber wenn man richtig Mist bauen will, braucht man einen Computer.

Dan Rather, CBS-Fernsehreporter
  Mit Zitat antworten Zitat
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#3

Re: Tastatur multilingual

  Alt 19. Jul 2003, 08:52
Nein...wenn dann brauch ich Ansi, da windows an und für sich mit ASCII nix anfangen kann (darstellung).
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
Dagon

Registriert seit: 13. Jul 2003
505 Beiträge
 
Delphi 7 Professional
 
#4

Re: Tastatur multilingual

  Alt 19. Jul 2003, 09:19
hier findest du eine ANSI-tabelle.
  Mit Zitat antworten Zitat
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#5

Re: Tastatur multilingual

  Alt 19. Jul 2003, 22:13
Du verstehst mich falsch.

In der Windows-API gibts eine Funktion vkkeyscan. diese gibt mir für ein bestimmtes Zeichen den virtuellen Tastencode..und zwar abhängig von der eingestelleten Tastatur (deutsch,englisch, chinesisch usw..). Was ich brauche wär eine Umkehrfunktion dazu. Ich hab den virtuellen Keycode (z.B. VK_Shift+'1') und brauche dazu das entsprechende Zeichen, auch wieder abhängig von der eingestellten Tastatur.


Ich will es eigentlich vermeiden hunderte von Konstanten-Units zu bauen
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
Gast
(Gast)

n/a Beiträge
 
#6

Re: Tastatur multilingual

  Alt 19. Jul 2003, 23:03
Hier mal ein Auszug aus dem PSDK ... wie wäre es denn erstmal mit dem Nachschauen in der Dokumentation? :

Zitat:
ToAscii
The ToAscii function translates the specified virtual-key code and keyboard state to the corresponding character or characters. The function translates the code using the input language and physical keyboard layout identified by the keyboard layout handle.

To specify a handle to the keyboard layout to use to translate the specified code, use the ToAsciiEx function.

ToAsciiEx
The ToAsciiEx function translates the specified virtual-key code and keyboard state to the corresponding character or characters. The function translates the code using the input language and physical keyboard layout identified by the input locale identifier.

ToUnicode
The ToUnicode function translates the specified virtual-key code and keyboard state to the correspondingUnicodecharacter or characters.

To specify a handle to the keyboard layout to use to translate the specified code, use the ToUnicodeEx function.

ToUnicodeEx
The ToUnicodeEx function translates the specified virtual-key code and keyboard state to the corresponding Unicode character or characters.
  Mit Zitat antworten Zitat
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#7

Re: Tastatur multilingual

  Alt 20. Jul 2003, 08:10
oh..hm...öhm...ja...wer lesen kann ist klar im Vorteil.
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#8

Re: Tastatur multilingual

  Alt 20. Jul 2003, 10:45
so..nach etwas tüftelei hab ich nun die Routine fertig. Sie ermittelt zu einem Virtuellen Tastencode das entsprechende Zeichen. Auch die Shift-Taste wird hierbei berücksichtigt.

Delphi-Quellcode:
function VKToChar(Key:smallint;Shift:boolean=false;layout:HKL=0):string;
var
  kb : TKeyboardState;
  VK : UINT;
  scan : UINT;
  hs : array [0..255] of char;
  erg : Integer;
begin
  result := '';
  fillchar(hs,sizeof(hs),0);
//Wenn kein Keyboardlayout angegeben dann das des aktuellen Threads nehmen
  if (layout = 0) then
    layout := GetKeyboardlayout(0);
//virtuellen Tastencode der Taste ermitteln
  VK := VKKeyScan(chr(key));
//Scan-Code ermitteln
  scan := MapVirtualKey(VK,0);
//Keyboard-State ermitteln und entsprechend setzten
  GetKeyboardState(kb);
  kb[key] := (kb[VK] or $80);
  if shift then
    kb[VK_SHIFT] := KB[VK_SHIFT] OR $80;
  SetKeyboardState(kb);
//Zeichen ermitteln
  erg := toAsciiEx(VK,scan,kb,@hs,0,layout);
  if (erg > 0) then
    result := StrPas(HS)
  else
    result := 'ERROR';
end;
Somit ist es möglich zu ermitteln welches zeichen entsteht wenn ich beispielsweise SHIFT+1 drücke ('!'). Leider funktioniert das nicht mit der ALT GR-Taste.
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz