Autor Beitrag
Mischel24NRW
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 26.11.05 19:45 
Hab gerade mal ne Zeit lang gesucht aber irgendwie net das richtige gefunden!

Also:

Ich möchte während meines programm stets Tasten abfragen. Das heisst, drückt man zu einem beliebigen zeitpunkt zB das "A" soll das Programm darauf reagieren. Wo muss ich den Programmtext dafür hinschreiben?

In TForm1.Activate??

Vielen Dank schonmal!

Gruß Michael
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Sa 26.11.05 20:15 
such mal im forum nach Suche in der Entwickler-Ecke TASTATURHOOK wenn du es systemweit abfangen willst.
wenn du nur in deinem form oder so dann mit onkeydown, onkeypress oder onkeyup...

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
Mischel24NRW Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Sa 26.11.05 20:25 
Habs mal so versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if boolean(getasynckeystate(vk_shift)) then showmessage('Na wer wird denn gleich');
end;


aber das funzt net! Da passiert gar nix, wenn ich die shift-taste drücke....
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Sa 26.11.05 20:42 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = vk_shift then showmessage('hallo');
if boolean(shift) then showmessage('shift')
end;


es kommen beide mitteilungen.
wenn man ein edit macht geht es nicht da dann die procedure vom edit aufgerufen wird also muss das in dem onkey ereignis passieren. aber ich denk mal nen hook wäre für dich echt besser

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
andras
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Sa 26.11.05 21:28 
schreib folgendes in einen timer und setz den intervall auf ca. 10:
ausblenden Delphi-Quelltext
1:
if getAsyncKeyState(Vk_Escape)<0 then ShowMessage('Escape gedrückt');					

und wenn du buchstabenabfragen willst:
ausblenden Delphi-Quelltext
1:
if getAsyncKeyState(Ord('A'))<0 then ShowMessage('A gedrückt');					
Mischel24NRW Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: So 27.11.05 12:19 
Mit dem Timer hört sich gut an! Hab allerdings damit noch nicht gearbeitet weiss also nicht so genau, wie der funktioniert! Hab mal hier im Forum und in der Hilfe geguckt und hab da sowas hier gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := IntToStr(Mouse.CursorPos.X);
  Label2.Caption := IntToStr(Mouse.CursorPos.Y);
end;


Aber wo kann ich denn da irgendwas einstellen bezüglich Zeit? Und wie bekomm ich die Prozedur überhaupt in mein Programm?
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: So 27.11.05 14:12 
nen timer würde ich dafür nicht nehmen. schau wirklich mal nach tastaturhook. aber vielleicht wäre es besser wenn du einem mal sagst was du überhaupt machen willst... wie sieht dein programm aus, wozu willst du die tasten abfragen, was macht der user? benutzt du edits oder was... dann kann man eher überlegen was das richtige ist. aber nen timer nimmt mehr ressourcen als ne onkey methode...

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
Mischel24NRW Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: So 27.11.05 15:27 
oh das ist schwierig! Ich versuchs mal zu erklären:

Ich bin Jugendbetreuer in ner Jugendgruppe mit ca 40 Jugendlichen. Die sollen in einem Programm Sachen auswählen können, allerdings nur mit der Maus. Sollte jetzt irgendwer ne taste auf der tastatur betätigen soll einfach ne meldung kommen, so nach dem Motto "Lässt du das wohl!" :-)
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: So 27.11.05 15:57 
soll das ganze nur in dem programm passieren oder system weit? also auch wenn dein programm minimiert ist sollen die tasten abgefangen werden??? oder setzt du dein programm als shell rein sodass gar keine benutzeroberfläche oder so geladen wird sondern nur dein programmfenster zu sehen ist.
und können die kinder windows trotzdem benutzen auch mit tastatur oder auch nur mit maus???

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
Mischel24NRW Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 40



BeitragVerfasst: Di 29.11.05 14:59 
Also die ganze Abfrage soll nur in meinem Programm erfolgen! Das liegt sowieso maximiert aufm Desktop über der Taskleiste und hat auch keinen minimieren-"Knopf". Auch wenn dien Windowstaste betätigt wird soll diese Meldung kommen.....
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Di 29.11.05 15:27 
theoretisch nen tastaturhook benutzen der alle tastendrücke abfängt. ob das aber einfach ist ist die andere frage.
man kann natürlich auch die keys im programm mit key= und so anfangen.
aber meine persönliche meinung: für nen computer im jugendzentrum wo man nur mit der maus arbeiten soll(auch wenn ich mich frag wieso) würde ich einfach die bildschirmtastatur deinstallieren oder deaktivieren und die tastatur abkabeln. dann dein programm als shell reingesetzt sodass nur dein prog beim start angezeigt wird. wenn sie keine tastatur benutzen dürfen wäre es doch eh egal ob eine dranhängt. und zur not kann man sie immernoch dran kabeln. dann gibts wirklich keine möglichkeit das ganze doch zu umgehen...

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
DarkLord05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 449

WinXP Pro SP2
Opera; Delphi 3 Pro; Delphi 2005, Turbo Delphi, dev-c++, Eclipse, MS Visual Studio .NET 2003, MS Visual C++
BeitragVerfasst: Di 29.11.05 16:24 
Ich habe da auch mal ne kleine Frage...
Wie kann ich (mit Key) die "ENTF" Taste "abfangen"? Also auch so in der art wie:

ausblenden Delphi-Quelltext
1:
If Key = TASTE then ShowMessage ('Entfernen gedrückt');					
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Di 29.11.05 16:26 
guck mal nach virtuellen tastencodes oder so. da müsste die entf. taste dabei sein. und den namen der taste brauchste...

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
t_hanel
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Di 29.11.05 16:55 
entfernen ist vk_delete

bye thomas
DarkLord05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 449

WinXP Pro SP2
Opera; Delphi 3 Pro; Delphi 2005, Turbo Delphi, dev-c++, Eclipse, MS Visual Studio .NET 2003, MS Visual C++
BeitragVerfasst: Mi 30.11.05 14:19 
user profile icont_hanel hat folgendes geschrieben:
entfernen ist vk_delete

bye thomas


Hat nicht geklappt:
ausblenden Delphi-Quelltext
1:
2:
   if getAsyncKeyState(vk_delete) < 0 then
    ShowMessage('delete gedrückt');


Es passiert rein gar nix, das ist das Problem.
Also testen tu ich das in ner ListBox.
Mit
ausblenden Delphi-Quelltext
1:
If HI (GetKeyState(VK_Back)) <> 0 then...					

klappt das ohne Probleme (VK_Back ist die Löschen Taste über Enter).

Habe auch versucht in der Variante das mit VK_Delete einzusetzen. Genau das gleiche Problem.

Weiß denn keiner Rat?
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Mi 30.11.05 14:27 
hast du es mal mit if key = vk_delete probiert? oder darf es nicht im onkeydown oder so verwendet werden und muss mit getasynckeystate laufen???

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
DarkLord05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 449

WinXP Pro SP2
Opera; Delphi 3 Pro; Delphi 2005, Turbo Delphi, dev-c++, Eclipse, MS Visual Studio .NET 2003, MS Visual C++
BeitragVerfasst: Mi 30.11.05 17:28 
user profile iconAmateur hat folgendes geschrieben:
hast du es mal mit if key = vk_delete probiert? oder darf es nicht im onkeydown oder so verwendet werden und muss mit getasynckeystate laufen???


Dann kommt die Meldung: E2008 Inkompatible Typen
Hatte es schon getestet^^
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Mi 30.11.05 18:11 
aber so oder so ähnlich hat es bei mir auch funktioniert...

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700