Autor Beitrag
neo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: So 02.03.03 14:11 
Hallo!

Wie kann ich einen Hotkey (zb. STRG+ALT+A) unter Windows registrieren, der dann mein Programm (eine einfache exe Datei) öffnet?

Oder geht das direkt im Programm (mit Delphi geschrieben)?

thx @ all
Jetro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: So 02.03.03 14:18 
Also es geht, wenn du eine Verknüpfung auf deine *.exe erstellst. Dann Rechtsklick auf die Verknüpfung und bei "Tastenkombination" kannst du dann deinen Hotkey festlegen.

Ciao :)
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: So 02.03.03 14:23 
Titel: RE:
Das habe ich schon probiert aber irgendwie geht das nicht richtig.

Keine Ahnung warum...
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 02.03.03 14:28 
Das mit den Windowsverknüpfungen ist ne Glückssache. Du kannst versuchen die Verknüpfung in die QuickLunch oder auf den Desktop zu packen, was machnmal noch funktioniert.

Ansonsten gibt es die Möglichkeit ein anderes Programm im Hintergrund laufen zu lassen, wenn HotKey -> Programm starten.

maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: So 02.03.03 14:32 
Titel: RE:
Das mit dem anderen programm hab ich mir auch schon gedacht.

Wird wohl die einzige wirkliche Möglichkeit sein....
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: So 02.03.03 14:36 
Titel: RE:
Hätte da noch eine Frage:

Wie kann ich ein Programm im Hintergrund (ab dem Systemstart (Autostart) laufen lassen?

. Das Formular sollte gar nicht angezeigt werden, dass müsste mit visible:=false gehen.

wie ist es mit dem (tray und )task icon? wie kann man das ausblenden?
Jetro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: So 02.03.03 14:51 
Das geht mit:

ausblenden Quelltext
1:
ShowWindow(Application.Handle, SW_HIDE);					


Ich bin mir allerdings nicht ganz sicher ob es dann "für immer" versteckt wird, ich glaube das Ganze musste man in einen Timer packen und alle paar Sekunden ausführen, das es richtige Wirkung zeigt...aber probieren...

Cya :)
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: So 02.03.03 15:03 
Titel: RE:
Für alle dies noch brauchen, ich habs jetzt mit dem Code gemacht, und es geht super!

Application.ShowMainForm:=false;

Da benötigt man keinen Timer etc.

Danke an alle die mir geholfen haben!
mcfrag
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Fr 14.03.03 19:57 
nur nebenbei, mich wuerde schon noich interessieren wie ich systemweite hotkeys in nem delphi programm regesrtiere hat da jemand ne idee?
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Sa 15.03.03 02:46 
mcfrag hat folgendes geschrieben:
nur nebenbei, mich wuerde schon noich interessieren wie ich systemweite hotkeys in nem delphi programm regesrtiere hat da jemand ne idee?
Soweit ich weiss, geht das mit Suche in: Delphi-Forum, Delphi-Library REGISTERHOTKEY. Nähere dazu in der Hilfe!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: Sa 15.03.03 12:38 
Titel: RE:
HIer siehst du wie man den Sys weiten Hotkey machen kann
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:

  The following example demonstrates registering hot keys with the 
  system to globally trap keys. 

  Das Folgende Beispiel zeigt, wie man Hotkeys registrieren und 
  darauf reagieren kann, wenn sie gedrückt werden. (systemweit) 
}
 

unit Unit1; 

interface 

uses 
  Windows, Messages, Forms, Dialogs; 

type 
  TForm1 = class(TForm) 
    procedure FormCreate(Sender: TObject); 
    procedure FormDestroy(Sender: TObject); 
  private 
    // Hotkey Ids 
    id1, id2, id3, id4: Integer; 
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY; 
    { Privat-Declarations} 
  public 
    { Public-Declarations} 
  end

var 
  Form1: TForm1; 

implementation 

{$R *.DFM} 

// Trap Hotkey Messages 
procedure TForm1.WMHotKey(var Msg: TWMHotKey); 
begin 
  if Msg.HotKey = id1 then 
    ShowMessage('Ctrl + A was pressed !'); 
  if Msg.HotKey = id2 then 
    ShowMessage('Ctrl + Alt + R was pressed !'); 
  if Msg.HotKey = id3 then 
    ShowMessage('Win + F4 was pressed !'); 
  if Msg.HotKey = id4 then 
    ShowMessage('Print Screen was pressed !'); 
end


procedure TForm1.FormCreate(Sender: TObject); 
  // Different Constants from Windows.pas 
const 
  MOD_ALT = 1
  MOD_CONTROL = 2
  MOD_SHIFT = 4
  MOD_WIN = 8
  VK_A = 65
  VK_R = 82
  VK_F4 = 115
begin 
  // Register Hotkey Ctrl + A 
  id1 := GlobalAddAtom('Hotkey1'); 
  RegisterHotKey(Handle, id1, MOD_CONTROL, VK_A); 

  // Register Hotkey Ctrl + Alt + R 
  id2 := GlobalAddAtom('Hotkey2'); 
  RegisterHotKey(Handle, id2, MOD_CONTROL + MOD_Alt, VK_R); 

  // Register Hotkey Win + F4 
  id3 := GlobalAddAtom('Hotkey3'); 
  RegisterHotKey(Handle, id3, MOD_WIN, VK_F4); 

  // Globally trap the Windows system key "PrintScreen" 
  id4 := GlobalAddAtom('Hotkey4'); 
  RegisterHotKey(Handle, id4, 0, VK_SNAPSHOT); 
end

// Unregister the Hotkeys 
procedure TForm1.FormDestroy(Sender: TObject); 
begin 
  UnRegisterHotKey(Handle, id1); 
  UnRegisterHotKey(Handle, id2); 
  UnRegisterHotKey(Handle, id3); 
  UnRegisterHotKey(Handle, id4); 
end

end


  RegisterHotKey fails if the keystrokes specified for the hot key have 
  already been registered by another hot key. 
   
  Windows NT4 and Windows 2000/XP: The F12 key is reserved for use by the 
  debugger at all times, so it should not be registered as a hot key. Even 
  when you are not debugging an application, F12 is reserved in case a 
  kernel-mode debugger or a just-in-time debugger is resident. 
}
mcfrag
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Sa 15.03.03 14:26 
dankeschoen