Autor Beitrag
Assun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: Do 23.06.05 10:04 
Hi !

Ich habe vor einen Text Trainer zu schreiben. Soll heissen ich möchte mit meinem "Trainer" tastendrücke im Spiel simulieren und so cheats "eingeben lassen".

Doch mein Code funktioniert nicht so recht.

Könnt ihr mir da weiterhelfen ?

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 Cheat(myString : String);
var
  c : Cardinal;
  i : integer;
  s : String;
begin
  c:=FindWindow(nil,'GTA: San Andreas'); //Get WindowHandle
  if c=0 then
  begin
    MessageDlg('Sie müssen das Spiel zuerst starten !',mtwarning,[mbOK],0);
    Exit;
  end;
for i := 1 to Length(mystring) do
SendMessage(c, WM_CHAR, Word(mystring[i]), 0); //send Keys
CloseHandle(c);
end;

procedure TForm1.WMHotKey(var msg: TMessage);
begin
if (msg.WParam = 1) then Cheat('LXGIWYL');       // you can choose any number ( up to 4000 )

end;


THX !


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Fr 24.06.2005 um 09:38
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Do 23.06.05 11:04 
Zitat:
Könnt ihr mir da weiterhelfen ?


Tipp : Es wäre ratsam, wenn du beschreiben würdest, was genau nicht funktioniert.

Die Art der Fragestellung beeinflusst die Art der Antwort :!:
Assun Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: Do 23.06.05 11:17 
ich bekomm ne exception ^^


Edit // Error angehängt
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von Assun am Do 23.06.05 11:32, insgesamt 1-mal bearbeitet
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Do 23.06.05 11:20 
was für eine ?
Assun Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: Fr 24.06.05 08:36 
könnte mir da vielleicht jemand helfen ?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 24.06.05 08:40 
das closeHandle mach nicht wirklich sinn, tu es mal weg

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Assun Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26


D2005 PE
BeitragVerfasst: Fr 24.06.05 10:02 
habe den Code mal umgschrieben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
  hOE: hWnd;
  s : string;
  i : integer;
begin
   hOE:=FindWindow(nil,'Unbenannt - Editor');//Finde das Fenster mit VirtualDub
   if hOE = 0 then ShowMessage('Nix gefunden');
   s := 'test';
   for i := 1 to Length(s) do
SendMessage(hOE, WM_CHAR, Word(s[i]), 0); //send Keys
end;


geht trotzdem net :wall:

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 25.06.05 14:51 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
program Project1;
{$APPTYPE CONSOLE}
uses windows, messages, sysutils;
var h : hwnd;
begin
  h:=findwindow(nil,'out.txt - Editor');
  if h <> 0 then begin
    sendmessage(h,WM_CHAR, ord('a'), 0);
  end;
end.

der code funktioniert fehlerfrei, allerdings wird 'a' nicht an den editor geschickt.
es gibt aber massig codeschnipsel um keys an andere anwendungen zu schicken, suche mal nach Suche in: Delphi-Forum, Delphi-Library SENDKEYS

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
noNeed 4 aNick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Di 12.07.05 15:25 
Ist SendKeys nicht veraltet?
Afaik sollte man stattdessen SendInput verwenden...
Oder ich verwechsel da jetzt was :)
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 12.07.05 16:32 
sendkeys gibts in delphi von haus aus gar nicht. dafür aber selbstgeschriebene prozeduren die so heissen. ausserdem kommt es oft in threads vor, in denen es um dieses thema geht, ist also somit das optimale suchwort.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...