Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Delphi sending keys using virtual keys

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sat Jan 19, 2008 11:21 pm    Post subject: Delphi sending keys using virtual keys Reply with quote

I am using delphi to send keys using virtual keys but i need some help

Im using a text box to take a single character from and convert the letter or number to a virtual key so it can then be sent individually, but i cant seem to get it to work properly

this is what i got so far
Code:

i : integer;
CharScan : integer;
TempChar :  Char;

for i := 1 to Length(EditText.text) do
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);


But this doesn't seem to work, im using hookhop.dll to send it

i'm doing it like this
Code:
hhPostMessageA(h,WM_KeyDown,CharScan,0);


Im trying to figure out how i can get this all to work together


Any help appreciated!
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sun Jan 20, 2008 2:44 am    Post subject: Reply with quote

Because you use a char for a string and you loop only on the first line (TempChar := Char(...)Wink
for ... to ... do beign
tempchar := ....;
charscan := ....;
postmessage(...);
end;
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Jan 20, 2008 3:50 am    Post subject: Reply with quote

so i need begin and end after for...do

like this?
Code:
for i := 1 to Length(EditText.text) do
 begin
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);
if h<>0 then
 begin
 hhPostMessageA(h,WM_KeyDown,CharScan,0);
 end;
end;


the full code is
Code:
var
h:hwnd;
i : integer;
Name : String;
DaName : PChar;
CharScan : integer;
TempChar :  Char;
begin
Name := EditTitle.Text;
DaName := PCHAR(Name);
h:=FindWindowA(nil,DaName);
 for i := 1 to Length(EditText.text) do
 begin
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);
if h<>0 then
 begin
 hhPostMessageA(h,WM_KeyDown,CharScan,0);
 end;
end;
end;


is it looking good?
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sun Jan 20, 2008 7:27 am    Post subject: Reply with quote

AdamG62 wrote:
so i need begin and end after for...do

like this?
Code:
for i := 1 to Length(EditText.text) do
 begin
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);
if h<>0 then
 begin
 hhPostMessageA(h,WM_KeyDown,CharScan,0);
 end;
end;


the full code is
Code:
var
h:hwnd;
i : integer;
Name : String;
DaName : PChar;
CharScan : integer;
TempChar :  Char;
begin
Name := EditTitle.Text;
DaName := PCHAR(Name);
h:=FindWindowA(nil,DaName);
 for i := 1 to Length(EditText.text) do
 begin
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);
if h<>0 then
 begin
 hhPostMessageA(h,WM_KeyDown,CharScan,0);
 end;
end;
end;


is it looking good?

For a non delphi coder it looks understandable.
Maby i should learn delphi.

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Jan 20, 2008 8:25 am    Post subject: Reply with quote

maybe, it's not very hard
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sun Jan 20, 2008 8:42 am    Post subject: Reply with quote

AdamG62 wrote:
so i need begin and end after for...do

...



the full code is
Code:
var
h:hwnd;
i : integer;
Name : String;
DaName : PChar;
CharScan : integer;
TempChar :  Char;
begin
Name := EditTitle.Text;
DaName := PCHAR(Name);
h:=FindWindowA(nil,DaName);
 for i := 1 to Length(EditText.text) do
 begin
 TempChar := Char(EditText.text[i]);
 CharScan := VkKeyScan(TempChar);
if h<>0 then
 begin
 hhPostMessageA(h,WM_KeyDown,CharScan,0);
 end;
end;
end;


is it looking good?

I think it will work, but remember to use WM_KeyUP.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Jan 20, 2008 9:46 am    Post subject: Reply with quote

i still doesn't seem to work

to test the postmessage function i was doing it like this

Code:
hhPostMessageA(h,WM_KeyUp,$70,0);


its really hard to figure out where its not working if i cant even tell if any of it works
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites