Autor Beitrag
kinghavi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 13:30 
eigentlich spricht das thema ja für sich, man kann ja bei bestimmten Tasten, denen, wenn sie gedrückt werden, eine funktion zuordnen. Dies geht aber mit den normalen Buchstaben nciht, soviel ich weiß, da man sonst ja nicht mehr Schreiben kann. deswegen die Frage ob dies zum Beispiel mti eienr Kombination von "strg+a" geht??

danke
SteffenF
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Sa 19.08.06 14:05 
ist zwar nicht gerade die eleganteste variante das zu realisieren aber du kannst ja ein tmainmenu platzieren dir dort dann menüpunkte hinterlegen dennen du dann eine tastenkombination via 'shortcut' hinterlegst. dann weist du dem Onclick event nur noch deine procedur zu.
NCortex
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 126

WIN 2000
D7 Enterprise
BeitragVerfasst: Sa 19.08.06 14:07 
das geht mit hooks glaub ich... google mal einfach danach..

Ich hab das mal vor langer zeit für ein Programm benutzt. war recht konfortabel. hooks sind global hotkeys und funktionieren auch, wenn dein Programm nicht im vordergrund ist

_________________
"...by all means, do not use a hammer." (aus einer IBM Technikerdokumentation ca. 1920)
--->außer es kam von Microsoft<---
kinghavi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 14:57 
hab mich mal umgeguckt im i net und so gar ein tutorial gefunden aber leider nix aber wirklich überhaupt nix verstanden! kann mir das wer erklären, wenn das nicht den rahmen sprengt?
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 19.08.06 16:41 
Luckie hat dazu ein gutes Tutorial:
www.michael-puff.de/...ad/hook_tutorial.pdf

Ist eigentlich recht gut verständlich, die im Dokument verlinkten Seiten sind auch recht interessant. Im Moment kann ich da nichts mehr zu sagen, ist ziemlich lange her dass ich mich damit mal beschäftigt hab. Allerdings werde ich das demnächst wieder tun, da ich das in meinem nächsten Projekt brauche.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 19.08.06 16:48 
stopstopstop...doch nicht direkt mit Kanonen auf dieses kleine Problem schießen...

Generell kann man das so machen, das KeyPreview der Form auf True stellt, und dann im FormKeyDown die Eigenschaft ShiftState mit abfragt und dann entsprechend darauf reagiert.

Also
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
if ssctrl in shift then 
begin
  case key of
    $41: showmessage('STRG + A gedrückt');
    $42: showmessage('STRG + B gedrückt');
  end;
end;

_________________
We are, we were and will not be.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 19.08.06 16:52 
Naja, das wird aber nur was, wenn er programmintern Shortcuts haben will.

Also @kinghavi: willst du das oder systemweite Hotkeys?

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 19.08.06 16:56 
Für systemweite Hotkeys gibts RegisterHotkey. Da braucht man auch keinen Hook :roll:

_________________
We are, we were and will not be.
kinghavi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 19:57 
also an sich klappt das mit dem hier forgestellten vorchlag wunderbar. kann ich jetzt auch als ereignis eine procedur wühlen und auch einen buttonclick procedure? was muss dann nachdem z.B. "$41:" folgen?

woher hast du eigentlich §41 für Strg +a?

gibt es da eine Liste für?
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 19.08.06 20:01 
Ich weis nicht ob ich das richtig verstehe, aber nen Button kannst du mit Buttonx.Click; drücken lassen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
if ssctrl in shift then 
begin
  case key of
    $41: Button1.Click;
    $42: EineProcedure;
    ord('C'):
    begin
       BlockAnweisungA;
       BlockAnweisungB; // ...
    end;
  end;
end;

Oder was meinst du? Als Ereignis eine Procedure "wühlen" ??? :shock:
Ach und folgendes: $42 ist das A. Mehr nicht. Kannst genausogut ord('A'); schreiben, da kommt auch der Hexadezimalwert 42 raus. Obs STRG gedrückt gehalten wird, findet er per if ssctrl in shift then .. heraus.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.


Zuletzt bearbeitet von JayEff am Sa 19.08.06 20:06, insgesamt 2-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 19.08.06 20:03 
Naja, dann ersetzt du das Showmessage durch ein Button1OnClick(Nil); - oder wie auch immer die Prozedur für den Buttonklick benannt ist.

_________________
We are, we were and will not be.
kinghavi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 20:03 
jup das wars schon, danke! ich hatte immer noch ein Tform. davor, damit ging es net, jetzt müsste ich nur noch wissen welche code für welche buchstaben/Buchstabenkombination gilt!

danke schön nochmal!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 19.08.06 20:05 
Siehe mein ge-editteter Beitrag.
ord('A'); für A. B für B etc. du musst immer große Buchstaben benutzen.
Du kannst in der Delphi hilfe nach TShiftState gucken, da findest du auch die abfragen für ALT und solche tasten.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
zlotti
Hält's aus hier
Beiträge: 7



BeitragVerfasst: So 29.04.07 17:34 
Sorry das ich so ein altes Thema rausgesucht hab, aber ich komm irgendwie nich klar.
Bin noch nen ganz schöner Anfänger und probier erstmal sonen paar Sachen aus.
Hab das hier geschriebene auch einfach mal ausprobiert, bloß bei mir rührt sich nix.

ausblenden volle Höhe 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:
30:
31:
32:
33:
34:
35:
36:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus;

type
  TForm1 = class(TForm)
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if ssctrl in shift then
begin
  case key of
    $41: showmessage('STRG + A gedrückt');
    $42: showmessage('STRG + B gedrückt');
  end;
end;
end;
end.



KeyPreview is auf true gesetzt.

Ich starte, er compiliert auch ohne Probleme, bloß dann kann ich auf
meiner Tastatur rumhämmern wie ich will der macht einfach nix!

Hab ich irgendwas übersehen?

Könnt ihr mir helfen?

Danke schonmal!
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 29.04.07 17:39 
Hm. Bei mir funktioniert das ohne Probleme. :gruebel:.

Hast du die Prozedur FormKeyDown auch dem Event OnKeyDown der Form zugeordnet?

_________________
We are, we were and will not be.
zlotti
Hält's aus hier
Beiträge: 7



BeitragVerfasst: So 29.04.07 17:52 
OH MANN! Ja hast recht! :roll: :roll: :roll: :roll: :roll: :roll: :roll: :roll:
Man kann sich aber auch dumm anstellen! :oops: :oops: :oops:

DANKE! :wink:
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: So 29.04.07 21:49 
Hi,

ich würde es dennoch mit globalen Hotkeys machen z.B. so:

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:
procedure Hotkey(var Message: TMessage); message WM_HOTKEY;

implementation

const HK_CTRL_A: Cardinal = $ff + Ord('A');

procedure TForm1.FormActivate(Sender: TObject);
begin
 RegisterHotkey(Handle, HK_CTRL_A, MOD_CONTROL, HK_CTRL_A - $ff);
end;

procedure TForm1.Hotkey(var Message: TMessage);
begin
 if (Message.LParamLo = MOD_CONTROL) and (Message.LParamHi = HK_CTRL_A - $ff) then begin
  // do what you want
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 UnregisterHotkey(Handle, HK_CTRL_A);
end;


Gruß
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mo 30.04.07 02:32 
Ich würde keine globalen hotkeys benutzen. Die reagieren nämlich auch dann wenn dein Programm nicht den Fokus hat. Da muss man halt abwegen was man genau will...wenn globale Hotkeys doch das richtige für dich sind schau dir lieber diesen FAQ-Beitrag an: www.delphi-library.d...rarbeiten_19371.html , ist einfacher nachvollziehbarer und funktioniert genauso.

Übrigens kansnt du bei RegisterHotkey auch einzelne Hotkeys registrieren (weil du das im Eingangsposting ja schriebst). Also z.B. nur 'A' ohne STRG o. ALT o. Shift. Richtig schreiben kann man dann allerdings wirklich nicht mehr^^.