Autor Beitrag
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 25.01.07 21:15 
Hallo,
ich hab in meinem Programm Systemweite Hotkeys reingeschrieben. Leider erkennt mein Programm diese nicht wieder. Hier mal mein Quelltext:

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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
type
TWMHotkey = record
    Msg: Cardinal;
    idHotKey: Word;
    Modifiers: Integer;
    VirtKey: Integer;
    end;
{...}
  private
    strs: array[0..128] of HSTREAM;
    strc: Integer;
    procedure Error(msg: string);
    procedure WMHotKey(var Msg: TWMHotKey); Message WM_HOTKEY;
    { Private-Deklarationen }
{...}
procedure TForm1.WMHotKey(Var Msg: TWMHotkey);
begin
{hier kommt nichts an}
case Msg.IdHotKey of
    ID: Abspielen(1);
    ID+1: Abspielen(2);
    ID+2: Abspielen(3);
    ID+3: Abspielen(4);
    ID+4: Abspielen(5);
    ID+5: Abspielen(6);
    ID+6: Abspielen(7);
    ID+7: Abspielen(8);
    ID+8: Abspielen(9);
    // Abhängig von der ID wird entschieden, was getan werden soll.
  end;
  inherited;
end;


{...}
procedure TForm1.FormCreate(Sender: TObject);
begin
registerHotKey(handle,1,MOD_CONTROL or MOD_ALT, Ord('1'));
registerHotKey(handle,2,MOD_CONTROL or MOD_ALT, Ord('2'));
registerHotKey(handle,3,MOD_CONTROL or MOD_ALT, Ord('3'));
registerHotKey(handle,4,MOD_CONTROL or MOD_ALT, Ord('4'));
registerHotKey(handle,5,MOD_CONTROL or MOD_ALT, Ord('5'));
registerHotKey(handle,6,MOD_CONTROL or MOD_ALT, Ord('6'));
registerHotKey(handle,7,MOD_CONTROL or MOD_ALT, Ord('7'));
registerHotKey(handle,8,MOD_CONTROL or MOD_ALT, Ord('8'));
registerHotKey(handle,9,MOD_CONTROL or MOD_ALT, Ord('9'));
end;
{...}
procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnregisterHotKey(Handle, 1);
  UnregisterHotKey(Handle, 2);
  UnregisterHotKey(Handle, 3);
  UnregisterHotKey(Handle, 4);
  UnregisterHotKey(Handle, 5);
  UnregisterHotKey(Handle, 6);
  UnregisterHotKey(Handle, 7);
  UnregisterHotKey(Handle, 8);
  UnregisterHotKey(Handle, 9);

end;

Warum kommt da kein Befehl an?


Zuletzt bearbeitet von Regan am Mi 31.01.07 16:42, insgesamt 1-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: Fr 26.01.07 15:47 
also bei mir geht das so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
 procedure hotkey(var msg:Tmessage); message WM_HOTKEY;

RegisterHotkey(Form1.handle,1,MOD_CONTROL or MOD_ALT, $BB);  // +
RegisterHotkey(Form1.handle,2,MOD_CONTROL or MOD_ALT, $BD);  // -

procedure TTntForm1.hotkey(var msg:Tmessage);
begin
  case msg.wparam of
    1: begin
       //...Lauter
      end;
    2: begin
       //...Leiser
      end;
   end;
end;

_________________
We are, we were and will not be.
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Fr 26.01.07 15:56 
:cry: :cry: :cry: :cry:
Bei mir gehts immer noch nich. Selbst mit deinem Code.Es kommt einfach nichts bei
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.hotkey(var msg:Tmessage);
begin
ShowMessage(Hy);
end;

an. Nicht mal ansatzweise wird diese Funtkion aufgerufen.
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: Fr 26.01.07 16:07 
Was liefert denn Registerhotkey zurück? Wird das überhaupt erfolgreich durchgeführt, oder sind diese Hotkeys schon von anderen Anwendungen belegt, weswegen das dann fehlschlägt?

_________________
We are, we were and will not be.
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Fr 26.01.07 18:28 
Das Einstellen der Hotkeys funktioniert perfekt. Die Funtkion liefert true zurück (was ja auch kein wunder is. wer belegt schon den zehnerblock ^^) Allerdings kommt bei TForm1.Hotkeys nichts an. Selbst wenn ich ne ShowmEssage mache, um zu überprüfen, ob die Procedure ausgerufen wird, wird diese ShowmEssage nicht angezeigt. Muss ich villeicht was im uses hinzufügen?
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 31.01.07 16:38 
hat jemand anderes villeicht Lösungsvorschläge oder andere Lösungen?
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Fr 02.02.07 22:29 
Du belegst nicht den 10er-Block!

Die Konstanten für den Zehnerblock lauten VK_Numpad0...VK_Numpad9
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 03.02.07 10:40 
user profile iconKarlson hat folgendes geschrieben:
Du belegst nicht den 10er-Block!

Die Konstanten für den Zehnerblock lauten VK_Numpad0...VK_Numpad9

OK. Quellcode geändert:
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
unit nippel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, MPlayer, mmsystem, ExtCtrls, Bass, jpeg, ImgList, inifiles, registry, ActiveX,  ShlOBJ,ShellAPI, CoolTrayIcon, ComCtrls;

type
  TWMHotkey = record
    Msg: Cardinal;
    idHotKey: Word;
    Modifiers: Integer;
    VirtKey: Integer;
    end;

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
{...}
    procedure FormCreate(Sender: TObject);
    procedure Abspielen(Buttonno:Integer);
  private
    strs: array[0..128] of HSTREAM;
    strc: Integer;
    procedure Error(msg: string);

    { Private-Deklarationen }
  public
    procedure SlotsEinstellen();
        procedure hotkey(var msg:Tmessage); message WM_HOTKEY;
    { Public-Deklarationen }
  end;

  const
CSIDL_APPDATA = $001A;

var
  Form1: TForm1;


implementation

uses info, einstellungen;

{$R *.dfm}
{...}
procedure TForm1.hotkey(var msg:Tmessage);
begin
ShowMessage('Hy'); //hier kommt nichts an
Abspielen(msg.WParam);
Abspielen(msg.LParam);
Abspielen(msg.Result);
inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
var iniko:Tinifile;
f:PChar;
ok: longbool;
begin
ok:=RegisterHotkey(Form1.handle,1,MOD_CONTROL or MOD_ALT, VK_NUMPAD1);
if ok then ShowMessage('1 Eingerichtet!'); 
  ok:=RegisterHotKey(Form1.Handle, 2, MOD_CONTROL or MOD_ALT, VK_NUMPAD2);
  if ok then ShowMessage('2 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 3, MOD_CONTROL or MOD_ALT, VK_NUMPAD3);
  if ok then ShowMessage('3 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 4, MOD_CONTROL or MOD_ALT, VK_NUMPAD4);
  if ok then ShowMessage('4 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 5, MOD_CONTROL or MOD_ALT, VK_NUMPAD5);
  if ok then ShowMessage('5 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 6, MOD_CONTROL or MOD_ALT, VK_NUMPAD6);
  if ok then ShowMessage('6 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 7, MOD_CONTROL or MOD_ALT, VK_NUMPAD7);
  if ok then ShowMessage('7 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 8, MOD_CONTROL or MOD_ALT, VK_NUMPAD8);
  if ok then ShowMessage('8 Eingerichtet!');
  ok:=RegisterHotKey(Form1.Handle, 9, MOD_CONTROL or MOD_ALT, VK_NUMPAD9);
  if ok then ShowMessage('9 Eingerichtet!');
  (*
 Mod_control mod_shift mod_Alt
  *)

//Bei allen kommt true heraus (also die Messagebox wird angezeigt
  strc := 0;    // stream count
{...}
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnregisterHotKey(Handle, 1);
  UnregisterHotKey(Handle, 2);
  UnregisterHotKey(Handle, 3);
  UnregisterHotKey(Handle, 4);
  UnregisterHotKey(Handle, 5);
  UnregisterHotKey(Handle, 6);
  UnregisterHotKey(Handle, 7);
  UnregisterHotKey(Handle, 8);
  UnregisterHotKey(Handle, 9);
end;

{...}

end.

Es funktioniert trotzdem nicht.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Sa 03.02.07 20:05 
In deinem Code befindet sich kein Fehler. Genauso wie du das machst funktioniert es bei mir.

Der Fehler liegt folglich bei dir. Vielleicht drückst du falsch (auch sicher alt und strg?).

Versuche mal einfach ord('A') anstelle von VK_Numpad.
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 03.02.07 21:23 
user profile iconKarlson hat folgendes geschrieben:
In deinem Code befindet sich kein Fehler.

Das ist schön.
user profile iconKarlson hat folgendes geschrieben:
Genauso wie du das machst funktioniert es bei mir.

Aber bei mir und bei meinen Kumpels funktioniert es nicht.
user profile iconKarlson hat folgendes geschrieben:
Der Fehler liegt folglich bei dir.

Aber wo?
user profile iconKarlson hat folgendes geschrieben:
Vielleicht drückst du falsch (auch sicher alt und strg?).

Jep. Ganz sicher. Ich trinke nur zu Geburtstagen Alkohol.
user profile iconKarlson hat folgendes geschrieben:
Versuche mal einfach ord('A') anstelle von VK_Numpad.

Hab ich gemcht. Es geht nicht. Das Problem ist ja: Es wird gar nicht erst die Funktion Hotkey aufgerufen. Also diese Showmessage('Hy') kommt erst gar nicht.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Sa 03.02.07 23:23 
Irgendeine aggressive Firewall am laufen?

Probier das Programm aus. Versuch ob du einen Hotkey registrieren kannst.


Zuletzt bearbeitet von Karlson am Mi 07.02.07 01:58, insgesamt 1-mal bearbeitet
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: So 04.02.07 14:00 
user profile iconKarlson hat folgendes geschrieben:
Irgendeine aggressive Firewall am laufen?

Ich hab grad mal alles deaktiviert und trotzdem funktioniert es nicht. Und außerdem funktioniert Gausi's Nemp ohne Fehler.
user profile iconKarlson hat folgendes geschrieben:
Probier das Programm aus. Versuch ob du einen Hotkey registrieren kannst.

und wie?
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: So 04.02.07 17:20 
Programm Runterladen, in das Editfeld einen Buchstaben eintragen, auf Registrieren drücken. Dann STRG+ALT+Buchstabe drücken und im Memo nachschauen ob der Key angekommen ist.

achja: Und wenn du es nicht für nötig hälst einen freundlicheren Ton anzuschlagen kannste selber gucken wie du es hinbekommst :roll:
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mo 05.02.07 18:00 
user profile iconKarlson hat folgendes geschrieben:
Programm Runterladen, in das Editfeld einen Buchstaben eintragen, auf Registrieren drücken. Dann STRG+ALT+Buchstabe drücken und im Memo nachschauen ob der Key angekommen ist.

achja: Und wenn du es nicht für nötig hälst einen freundlicheren Ton anzuschlagen kannste selber gucken wie du es hinbekommst :roll:

OK. OK. Ich werd mich versuchen wieder zu beruhigen. Ich nehm alles zurück, was irgendwie beleidigend klingen könnte.
Also. Ich hab mir dein Programm runtergeladen und ... du musst da was verwechselt haben. Ich find das Programm zwar auch cool, aber es hilft mir irgendiwe nicht weiter.
Ich geb dir auch noch n paar infos zum system:
Windows XP Service Pack 2
Borland Delphi 2005 Personal
Jedi Code Library installiert

Soll ich dir vielleicht mal meinen Projekt Ordner anhängen?


Zuletzt bearbeitet von Regan am Mi 14.02.07 17:00, insgesamt 1-mal bearbeitet
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mo 05.02.07 19:15 
Ui. Tut mir sehr leid. Mein Fehler! Die waren beide auf dem Desktop unter Project1.exe, die richtige wäre aber project2.exe gewesen.

Natürlich war ich auch schon so schlau und habe mein Desktop aufgeräumt...Ich schreibs heute abend nocheinmal neu.
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mo 05.02.07 19:17 
user profile iconKarlson hat folgendes geschrieben:
Ui. Tut mir sehr leid. Mein Fehler! Die waren beide auf dem Desktop unter Project1.exe, die richtige wäre aber project2.exe gewesen.

Natürlich war ich auch schon so schlau und habe mein Desktop aufgeräumt...Ich schreibs heute abend nocheinmal neu.

Das ist nett. Ich hab jetzt sogar eine Übergangslösung gefunden. Wenn das Fenster offen ist, dann benutze ich einfach OnKeyUp. Leider ist das nicht systemweit.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mi 07.02.07 00:36 
So.

Ich hab dir die Anwendung nochmal schnell zusammengeklickt.

Einfach einen gewünschten Buchstaben ins Editfeld eintragen (es geht nur a biz z).
Auf Registrieren klicken und dann die Tastenkombination drücken.

Wenn in der Listbox daraufhin [EMPFANGEN] steht kopierst du dir einfach den Code in deine Anwendung rüber:

Die Anwendung umfasst nur ein paar Zeilen Code, daher ist das so schneller wie das ganze Projekt hochzuladen:

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:
procedure TForm1.WMHotkey(var msg: TMessage);
begin
 if msg.WParam=1 then
  listbox1.Items.add('[EMPFANGEN]');
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
 case Key of
  'a'..'z' : key:=char(integer(key)-32);
  'A'..'Z', char(VK_BACK):;
  else key:=#0;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var b : boolean;
begin
 listbox1.Items.Add('[REG]'+
                   BoolToStr(
                   RegisterHotKey(handle, 1, MOD_CONTROL or MOD_ALT, ord(edit1.text[1])),
                   true));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 UnregisterHotKey(handle, 1);
end;


(Forward vom Handler nicht vergessen).
Einloggen, um Attachments anzusehen!
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 07.02.07 18:36 
user profile iconKarlson hat folgendes geschrieben:

(Forward vom Handler nicht vergessen).

Was ist der Forward vom Handler?
Ich hab es jetzt mal ausprobiert und es geht trotzdem nicht. Ich hab dir mal die Anwendung drangehangen.
Einloggen, um Attachments anzusehen!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 07.02.07 18:52 
user profile iconRegan hat folgendes geschrieben:
user profile iconKarlson hat folgendes geschrieben:

(Forward vom Handler nicht vergessen).

Was ist der Forward vom Handler?

Der Handler ist im OI unter Ereignisse der Eintrag dort. Verknüpfst du das Ereignis mit der Prozedur, hast du den Handler forwarded (wenn ich mich nicht irre ^^)

Hast du es mit einer neuen Tastenkombination bereits versucht?

und woher kommt bei dir das "inherited" ? Meine TForm1 hat keine prozedure WMHotkey... (Meine Prozedur heist WMhotkey, nicht hotkey.) Ausserdem glaube ich, mich zu erinnern, dass die prozedur privat deklariert werden muss... also
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type TForm1
{...}
    Private
        Procedure WmHotkey(Var Msg: TMessage); Message WM_HOTKEY;
{...}
End;

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Mi 07.02.07 19:09 
Lad mal bitte dein komplettes Projekt hoch. Mit dem Installer kann ich nichts anfangen.