Autor Beitrag
Borlox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Sa 22.02.03 15:28 
Hi Leute,

ich möchte gerne den Text überwachen, der auf meiner Tastatur geschrieben wird! Also habe ich ein Programm geschrieben, dass im Hintergrund läuft, aber dann kann ich ja nicht mehr auf das Ereigniss OnKeyPress zugreifen, da die Form nicht mehr angeklickt ist, gibt es noch eine eine andere Möglichkeit die Tastatur zu überwachen?

THX
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 15:48 
Such mal unter dem Begriff Hooks und im Turorial.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 18:14 
Wenn es nur dein Programm betrifft, dann wäre RegisterHotKey das richtige.
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Sa 22.02.03 18:18 
Titel: RegisterHotKey
Es soll nur mein Program betreffen!
Wie funktioniert das denn mit dem RegisterHotKey??

Habe leider nichts darüber gefunden!!!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 18:25 
Hier ein Beispiel für die Drcuk-Taste:
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:
TForm1 = class(TForm)
  private
  { Private-Deklarationen }
  procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;

  public
  { Public-Deklarationen }

end;

const id_SnapShot =101;

procedure TForm1.WMHotKey(var Msg : TWMHotKey);
begin
  if Msg.HotKey=id_SnapShot then
  begin
    // ...;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  RegisterHotKey(Form1.Handle,id_SnapShot,0,VK_Snapshot);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(Form1.Handle,id_SnapShot);
end;
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Sa 22.02.03 18:37 
Titel: Cool
Danke, das ist auf jeden Fall schon mal eine super Idee!
Es klappt auch so weit, aber wie kann ich anstatt der Drucktaste z.B. ein Buchstaben dafür nehmen??
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 18:42 
Einfach für VK_SNAPSHOT einen andern virtuellen KeyCode angeben. Mit Buchstaben wird es da aber etwas komplizierter, glaube ich.
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Sa 22.02.03 18:49 
Titel: d
Aber das mit den Buchstaben ist genau das, was ich brauche!

Da muss es doch irgendeine Möglichkeit geben!???
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Sa 22.02.03 18:54 
A = 65
B = 66
C = 67


wenn du das meinst :?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 18:55 
Das Problem ist, RegisterHotkey will im letzten Parameter einen virtuellen KeyCode haben und Buchstaben haben keinen soweit ich weiß.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Sa 22.02.03 18:58 
eigendlich müssen alle tsten einen haben, sonnst könnte man sie doch nicht benutzen? :?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 22.02.03 19:01 
Ich habe gerade im PSDK gekuckt. Ich glaube, da kann man wirklich das
Zitat:

A = 65
B = 66
C = 67
... = ...

nehmen.

Obwohl im PSDK sind es hex-Werte:
Zitat:

(41)
A key

(42)
B key

(43)
C key

(44)
D key

(45)
E key

(46)
F key

(47)
G key

(48)
H key

(49)
I key

(4A)
J key

(4B)
K key

(4C)
L key

(4D)
M key

(4E)
N key

(4F)
O key

(50)
P key

(51)
Q key

(52)
R key

(53)
S key

(54)
T key

(55)
U key

(56)
V key

(57)
W key

(58)
X key

(59)
Y key

(5A)
Z key
DelphiMan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: So 23.02.03 00:38 
Titel: QuasiHook - wie?
Wie kann ich alle Tasten auf einmal Registrieren - dann hätte man ja nämlich einen systemweiten Hook mit dem man arbeiten kann, oder wo liegt der unterschied? Jedenfalls: gibt es vielleicht einen eleganteren weg, als im oncreate ereignis folgendes für alle tasten zu machen?

RegisterHotKey(Form1.Handle,ord('0'),0,ord('0'));
RegisterHotKey(Form1.Handle,ord('1'),0,ord('1'));
...

Vielen Dank im Voraus!

MfG
DelphiMan
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: So 23.02.03 00:41 
Titel: Danke
Danke, das hat mir schon sehr viel weitergeholfen! Danke an alle!

Nun noch eine letzte kleine Frage, was ist denn mit den kleinen Buchstaben???
Wie kann ich den Unterschied zwischen groß und klein herausfinden?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 23.02.03 00:53 
Musst einfach überprüfen ob die Shift-Taste gedrückt ist und wenn ja, dann ist es ein GROßBUCHSTABE :wink:
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: So 23.02.03 15:08 
Titel: Frage
Hi Leute,

mir ist gerade aufgefallen, wenn ich etwas z.B. in Word schreiben möchte, dann geht das nicht mehr, wenn mein Program gestartet ist!
Ich wollte zwar die Tastaturbefehle abfangen, aber ich wollte nicht, dass man nicht mehr weiterarbeiten kann!

Hat jemand ne Idee?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 23.02.03 15:31 
Ich glaube du musst in deiner Prozedur(WMHotKey) einfach am Ende noch inherited(WMHotKey); aufrufen.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Borlox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: So 23.02.03 17:17 
Titel: Frage
Klappt leider nicht!

Er gibt folgende Fehlermeldung aus:

[Error] Netz.pas(88): Missing operator or semicolon


THX
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 23.02.03 17:37 
schreib mal den Quelltext mit dem "inherited(..);" und das davor/dahinter stehthier rein
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 23.02.03 18:05 
Mein Fehler :oops:
Du musst natürlich den Parameter Msg mit übergeben:
ausblenden Quelltext
1:
inherited WMHotKey(Msg);					


mfg
GSE[/code]

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)