Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 19.05.07 23:15 
Hi,
also: ich möchte, dass wenn man z.B. F11 drückt (das programm ist im Hintergrund und nicht aktiv ausgewählt, das heißt es sollte das überall wenn man F11 macht das macht)es immer im 50ms secunden abstand STRG drückt.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure?F11drück?
begin
  if Key = VK_F11 then ? (key STRG 50ms intervall;
...


Es reicht auch wenn ihr mir ne anleitung dazu geben könnt.
Hier im forum hab ich nichts richtiges dazu gefunden..
Smikey
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 45

Win XP, kUbuntu 6.06
Delphi 2005 Architect
BeitragVerfasst: Sa 19.05.07 23:18 
ich weiss net so genau aber ich bin der meinung systemweit F11 abzufangen wird schwierig, da es sicher in vielen sachen eine funktion hat..
bei deinem programm im vordergrund kein problem, aber inaktiv.. ich weiss nich

mfg smikey

_________________
Bloß weil du nicht paranoid bist, heißt das nicht, dass sie nicht hinter dir her sind.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 20.05.07 12:32 
hmm.. k
und wie geht es im Vordergrund?
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: So 20.05.07 12:53 
um einen systemweiten hotkey für das programm zu registrieren:
RegisterHotKey(handle, key, 0, key);

zum wieder entfernen:
unRegisterHotKey(handle, key);

key ist beidemale eine variable vom typ word (in deinem fall also VK_F11);

dann muss dein proggi natürlich noch wissen was es machen soll, wenn der hotkey gedrückt wurde, dafür schreibse eine procedure:

procedure WMHotKey(var Msg: TWMHotKey);message WM_HOTKEY;

und implementierst sie
Noob23
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 93

Win XP, Win Server 2003, Win 7, Ubuntu
Delphi 7, c/c++ Dev-c++, µC-8051 Keil, Webdesign Notepad++
BeitragVerfasst: So 20.05.07 12:56 
hy,
naja was bringts dir wenn dein programm im vordergrund ist?

würds mit einer der beiden varianten machen:
1)globalen hook - aber denk der aufwand rentiert sich nicht
2)globaler hotkey - die bessere variante (in deinem fall)

und dein STRG an ein programm senden würd ich mit der unit im anhang und einem timer...

Grüße
Einloggen, um Attachments anzusehen!
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: So 20.05.07 14:55 
Moin,

am besten machst du es mit nem Hotkey und einem Keyboard Event:
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:
procedure Hotkey(var Message: TMessage); message WM_HOTKEY;

implementation

const F11: Cardinal = $ff + Ord(VK_F11); // Konstante ($ff = 255; Ord(VK_F11) = 122

procedure TForm1.FormActivate(Sender: TObject);
begin
  RegisterHotkey(Handle, F11, 0, F11 - $ff); // Hotkey registrieren: RegisterHotkey(Handle, ID, Modifiers, VK);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 UnregisterHotkey(Handle, F11); // Hotkey (un-) registrieren: UnregisterHotkey(Handle, ID); 
end;

procedure TForm1.Hotkey(var Message: TMessage);
var i: Byte;
begin
 if (Message.LParamHi = F11 - $ff) then begin // Wenn F11 gedrückt wurde...
  for i := 0 to 50 do begin //... 50 ms warten ...
   Application.ProcessMessages;
   Sleep(1);
   end;
   // ...Keyboard Event ...
   keybd_event(VK_CONTROL, 0, 0, 0); // ...STRG drücken...
   keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // ...STRG loslassen
   end;
end;


Gruß
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 20.05.07 18:00 
wenn ichs so mach kommt (28)unknown directive: Message :?

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Image1: TImage;
    procedure Hotkey(var Message: TMessage); message WM_HOTKEY;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
procedure Hotkey(var Message: TMessage); message WM_HOTKEY;
implementation

{$R *.dfm}

 
const F11: Cardinal = $ff + Ord(VK_F11); // Konstante ($ff = 255; Ord(VK_F11) = 122  

procedure TForm1.FormActivate(Sender: TObject);
begin  
  RegisterHotkey(Handle, F11, 0, F11 - $ff); // Hotkey registrieren: RegisterHotkey(Handle, ID, Modifiers, VK);  
end;  

 
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 UnregisterHotkey(Handle, F11); // Hotkey (un-) registrieren: UnregisterHotkey(Handle, ID);   
end;  


procedure TForm1.Hotkey(var Message: TMessage);
var i: Byte;  
begin  
 if (Message.LParamHi = F11 - $ff) then begin // Wenn F11 gedrückt wurde...  
  for i := 0 to 50 do begin //... 50 ms warten ...  
   Application.ProcessMessages;  
   Sleep(1);  
   end;  
   // ...Keyboard Event ...  
   keybd_event(VK_CONTROL, 0, 0, 0); // ...STRG drücken...  
   keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // ...STRG loslassen  
   end;  
end; 


end.
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: So 20.05.07 18:04 
Moin,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  Form1: TForm1;
procedure Hotkey(var Message: TMessage); message WM_HOTKEY; // Diese Zeile muss weg!
implementation


Gruß
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 20.05.07 18:20 
ok, danke
dann meint er
procedure TForm1.FormActivate(Sender: TObject);
FormActive - undeclared idetifier
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 20.05.07 18:44 
Hast Du die proceduren auch über Delphi erzeugt oder nur per Copy und Past eingefügt !?

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 20.05.07 18:57 
Wie man seinem Source entnehmen kann: Copy und Paste.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 20.05.07 19:17 
user profile iconGTA-Place hat folgendes geschrieben:
Wie man seinem Source entnehmen kann: Copy und Paste.


Garnicht drauf geachtet, hatte bloss den letzten Post gelesen.
Dann gibts noch den Link zum Crashkurs. :wink:
www.delphi-library.d...;highlight=crashkurs

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 20.05.07 19:19 
wie mach ich die denn über delphi? ich weiss nur wie man FormCreate macht :oops:
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 20.05.07 19:29 
Im OI auf Ereignisse wechseln entsprechende procedure auswählen - rechts Doppelklick fertig.
Und den crashkurs mal anschauen.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 20.05.07 20:07 
ok es gibt jetz keine fehler, aber wenn ich F11 drücke passiert nichts :?:
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: So 20.05.07 20:26 
Doch, wenn du F11 drückst wird 50 ms später (virtuell) die STRG- Taste gedrückt ;)
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 20.05.07 22:02 
ich hab mal ein programm gemacht das simuliert mausbewegungen und drückt tasten
auch global , das beduetet wenns im hintergrund läuft.
wenn du interesse hast schicke ich es dir


mfg flo
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 20.05.07 22:07 
sonst versuch doch mal das hier :)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
const
  MOD_ALT = 1;
  MOD_CONTROL = 2;
  MOD_SHIFT = 4;
  MOD_WIN = 8;
  VK_I = $49;
  VK_O = $4F;
  VK_A = $41;
  VK_S = $53;
  VK_Q = $51;
  VK_W = $57;



So setzt du die keys Global und sie werden überall aufrufbar sein höhö

natürlich über implementation


Edit: und den interval machste einfach mitm timer und dann luppert das : )
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Mo 21.05.07 14:29 
also ich hab jetz die const von dir rein genommen und einfach mal vk_control im procedure Hotkey(var Message: TMessage); message WM_HOTKEY; gegen $49 (I) ausgetauscht. Jetzt kommt immer wenn ich F11 drück EIN i aber es sollen unendlich kommen (in 50ms secunden abstand). Kann es sein das im Code was falsch ist?

Edit: Das Spiel bei dem ich das machen will hat irgendwie ne Sperre..das is wie bei ACTool (macro), dass da einfach nix kommt wenn ich F11 drücke (oder makro in actool starte)
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: Mo 21.05.07 15:37 
Wenn ich nacher zeit hab guck ich mal muss lernen nun