Einzelnen Beitrag anzeigen

Benutzerbild von bitsetter
bitsetter

Registriert seit: 17. Jan 2007
1.169 Beiträge
 
Turbo Delphi für Win32
 
#17

Re: Tastendruck simulation nach eingabe im Editfeld?

  Alt 21. Feb 2007, 19:20
Das ganze jetzt mit Sonderzeichen, funktioniert jedoch nur bei einer deutschen Tastatur. Wenn VK_CAPITAL an ist, dann wird alles großgeschrieben.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  c: Char;
  i: integer;
  keyState: TKeyboardState;
  Text: AnsiString;
begin
  //sleep(2000);
  Text:= Edit1.Text;
  if length(Text)> 0 then
  begin
    GetKeyboardState(keyState) ;
    //if not Boolean(keyState[VK_CAPITAL]) then//nicht großschreiben
    for i:= 1 to length(Text) do
    begin
      c:= Text[i];
      Case c of
        '°','!','"','§','$','%','&','/','(',')','=','?','`','*','Ü','Ö','Ä','_',':',';','>' :
          begin
            case c of
              '!': c:= char(ord('1'));
              '"': c:= char(ord('2'));
              '§': c:= char(ord('3'));
              '$': c:= char(ord('4'));
              '%': c:= char(ord('5'));
              '&': c:= char(ord('6'));
              '/': c:= char(ord('7'));
              '(': c:= char(ord('8'));
              ')': c:= char(ord('9'));
              '=': c:= char(ord('0'));
              '?': c:= char(219);
              '`': c:= char(221);
              '*': c:= char(187);
              'Ü': c:= char(186);
              'Ö': c:= char(192);
              'Ä': c:= char(222);
              '_': c:= char(189);
              ':': c:= char(190);
              ';': c:= char(188);
              '>': c:= char(226);
            end;
            keybd_event(vk_Shift,0,0,0);
            keybd_event(ord(c),0,0,0);
            keybd_event(vk_Shift,0,keyeventf_keyup,0);
            keybd_event(ord(c),0,keyeventf_keyup,0);
          end;
        '²','³','{','[',']','}','\','@','~','|','µ':
          begin
            case c of
              '²': c:= char(ord('2'));
              '³': c:= char(ord('3'));
              '{': c:= char(ord('7'));
              '[': c:= char(ord('8'));
              ']': c:= char(ord('9'));
              '}': c:= char(ord('0'));
              ',': c:= char(221);
              '\': c:= char(219);
              '@': c:= char(81);
              '~': c:= char(187);
              '|': c:= char(226);
              'µ': c:= char(77);
            end;
            keybd_event(vk_Control,0,0,0);
            keybd_event(vk_Menu,0,0,0);
            keybd_event(ord(c),0,0,0);
            keybd_event(vk_Control,0,keyeventf_keyup,0);
            keybd_event(vk_Menu,0,keyeventf_keyup,0);
            keybd_event(ord(c),0,keyeventf_keyup,0);
          end;
        '1'..'9','a'..'z','ß',' ','+','#','-','.','<','ä','ö','ü',',':
          begin
            case c of
              'a'..'z':c:= upcase(c);
              'ß': c:= char(219);
              ' ': c:= char(32);
              '+': c:= char(187);
              '#': c:= char(191);
              '-': c:= char(189);
              '.': c:= char(190);
              '<': c:= char(226);
              'ä': c:= char(222);
              'ö': c:= char(192);
              'ü': c:= char(186);
              ',': c:= char(188);
            end;
            keybd_event(ord(c),0,0,0);
            keybd_event(ord(c),0,keyeventf_keyup,0);
          end;
        'A'..'Z':
          begin
            keybd_event(vk_Shift,0,0,0);
            keybd_event(ord(c),0,0,0);
            keybd_event(vk_Shift,0,keyeventf_keyup,0);
            keybd_event(ord(c),0,keyeventf_keyup,0);
          end;
      end;
    end;
  end;
end;
Gruß bitsetter
"Viele Wege führen nach Rom"
Wolfgang Mocker (geb. 1954), dt. Satiriker und Aphoristiker
  Mit Zitat antworten Zitat