Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 02.10.09 23:14 
Hallo,

ich möchte eine Tastenkombination, die ich in eine THotKey-Komponente eingegeben habe, simulieren lassen.

Ich stelle das so an:
ausblenden Delphi-Quelltext
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:
type
    TWinHotKey =
    packed record
      Key: Word;
      Modifiers: UInt;
    end;

function TForm1.ShortCutToHotKey(HotKey: TShortCut):TWinHotKey;
var
  Shift: TShiftState;
  WHK:TWinHotKey;
begin
  ShortCutToKey(HotKey, WHK.Key, Shift);
  WHK.Modifiers := 0;
  if (ssShift in Shift) then
  WHK.Modifiers := WHK.Modifiers or MOD_SHIFT;
  if (ssAlt in Shift) then
  WHK.Modifiers := WHK.Modifiers or MOD_ALT;
  if (ssCtrl in Shift) then
  WHK.Modifiers := WHK.Modifiers or MOD_CONTROL;
  result := WHK;
end;

// Simulation
WHK := ShortCutToHotKey(HotKey1.HotKey);
            keybd_event(WHK.Modifiers, 00,0); // HIER !
            keybd_event(WHK.Key, 00,0);
            keybd_event(WHK.Modifiers, 0, KEYEVENTF_KEYUP, 0);
            keybd_event(WHK.Key, 0, KEYEVENTF_KEYUP,0);


Leider funktioniert die markierte (viertletzte) Zeile nicht so recht. Ich habe mal Strg+A als Tastenkombi eingegeben und habe dann versucht, über die Simulation einen Text komplett zu markieren. Mit obigem Code klappt das nicht. Wenn ich allerdings WHK.Modifiers durch VK_CONTROL ersetze, klappt alles.

Was mache ich da falsch ? :(

Ciao LHUser
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Sa 03.10.09 20:53 
Keiner ne Idee :( ?