Autor Beitrag
HaRaH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: So 13.02.05 16:39 
Hallo,
kann mir jemand sagen wie man das drücken von zwei Tasten gleichzeitig registrieren kann?
Wenn ich zum Beispiel Strg gedrückt halte und dann auf die Leertaste drücke? Oder Strg und dann einen Buchstaben?

Herzlichen Dank im Vorraus!!
Gruß MaX
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: So 13.02.05 16:46 
Dafür musst das OnKeyDown-Ereignis verwenden.
Du kannst "Key" und "Shift" auswerten.
Key ist die eigentliche Taste und in Shift ist die zusätzliche Taste enthalten.
Elite
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 13.02.05 16:48 
im OnKeyDown deines Forumlares, sofern KeyPreview auf true steht folgendermaßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if ssCtrl in Shift then
  begin
    if key = ord('A'then
      beep; // Strg und A
    if key = VK_Space then
      color := clgreen; // Strg und Leertaste
  end;
end;

Für weitere Konstanten einfach mal in die Hilfe schnuppern und nach TShiftState und VK_ suchen!


Zuletzt bearbeitet von Elite am So 13.02.05 16:50, insgesamt 1-mal bearbeitet
HaRaH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: So 13.02.05 16:49 
wow - hammer - danke! :dance:
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 13.02.05 16:51 
global oder nur in deinem programm ?

globaler hotkey:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TWMHotkey = record
    Msg: Cardinal;
    idHotKey: Word;
    Modifiers: Integer;
    VirtKey: Integer;
  end;

const ID = $FF;

das hier muss noch in den privat abschnitt:
ausblenden Delphi-Quelltext
1:
  procedure WMHotKey(var Msg: TWMHotKey); Message WM_HOTKEY;					

und das in den implementation teil
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.WMHotKey(Var Msg: TWMHotkey);
begin
  if Msg.IdHotKey = id then showmessage('Hotkey wurde betätigt');
  inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  RegisterHotKey(Form1.Handle, ID, MOD_Control, vk_space);
end;

damit müsste es gehen :?

man kann auch mehrere hotkeys definieren mit ID+1, ID+2, und um Buchstaben zu
machen, nimmt man statt vk_space ord('A') <- Da kann alles von a-z und von 0 -9 rein :D