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 


Sending Keystrokes to a process (Translate/DispatchMessage)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Wed Oct 31, 2007 2:26 pm    Post subject: Sending Keystrokes to a process (Translate/DispatchMessage) Reply with quote

Hello,

I found this thread in the forum where Liquid posted this function :

Code:
void __declspec(dllexport)__stdcall ProcessMsg(UINT Message, WPARAM wParam, LPARAM lParam)
{
   MSG Msg;
   ZeroMemory(&Msg, sizeof(MSG));

   Msg.hwnd = FindWindow("MapleStoryClass", "MapleStory");
   Msg.lParam = lParam;
   Msg.message = Message;
   Msg.wParam = wParam;

   TranslateMessage(&Msg);
   DispatchMessage(&Msg);
}


ProcessMsg(WM_KEYDOWN, 0x11, 0x1D0001);


I dont know if this method still works (it has been posted three months ago .....). But if it still works, at the first view this function looked pretty simple, but what about the lpParam? Why the hell is it 0x1D0001 (1900545)? I think it is because of maplestory, but i dont know exactly

_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Oct 31, 2007 2:59 pm    Post subject: Reply with quote

MSDN
_________________
Back to top
View user's profile Send private message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Wed Oct 31, 2007 4:13 pm    Post subject: Reply with quote

ok .. lParam = Scancode + 001 ? but .. how can i find out the scancode?

edit .. i really dont unterstand this parameter although i searched in the msdn Oo

_________________


Last edited by Deine Mutter on Wed Oct 31, 2007 5:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Oct 31, 2007 4:29 pm    Post subject: Reply with quote

I want to translate this into Delphi.

Code:
void __declspec(dllexport)__stdcall ProcessMsg(UINT Message, WPARAM wParam, LPARAM lParam)
{
   MSG Msg;
   ZeroMemory(&Msg, sizeof(MSG));

   Msg.hwnd = FindWindow("MapleStoryClass", "MapleStory");
   Msg.lParam = lParam;
   Msg.message = Message;
   Msg.wParam = wParam;

   TranslateMessage(&Msg);
   DispatchMessage(&Msg);
}


ProcessMsg(WM_KEYDOWN, 0x11, 0x1D0001);


Here's my code:

Code:


Procedure processMessage(UINT:Message; WPARAM:wParam; LPARAM:lParam);
var
Message : UINT;
PARAMW : wParam;
PARAML : lParam;
LMSG : MSG;
begin
ZeroMemory(&Msg, sizeof(MSG));

 LMSG.hwnd = FindWindow('MapleStory',nil);
   LMSG.lParam = lParam;
   LMSG.message = Message;
   LMSG.wParam = wParam;

   TranslateMessage(&LMsg);
   DispatchMessage(&LMsg);
end;

procedure button1click(sender:Tobject);
begin
ProcessMsg(WM_KEYDOWN, 0x11, 0x1D0001);
ProcessMsg(WM_KEYUP, 0x11, 0x1D0001);
end;


Did i get this right?


[/code]
Back to top
View user's profile Send private message AIM Address MSN Messenger
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Wed Oct 31, 2007 5:19 pm    Post subject: Reply with quote

i just wanna know why lParam is 0x1D0001 Confused
_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Wed Oct 31, 2007 5:25 pm    Post subject: Reply with quote

Deine Mutter wrote:
i just wanna know why lParam is 0x1D0001 Confused


MSDN:

Code:
lParam
Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.
0-15
Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16-23
Specifies the scan code. The value depends on the OEM.
24
Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28
Reserved; do not use.
29
Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
30
Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up.
31
Specifies the transition state. The value is always zero for a WM_KEYDOWN message.
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Wed Oct 31, 2007 6:26 pm    Post subject: Reply with quote

And if you still haven't noticed, MSDN is referring to the bits in the dword lparam.
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Nov 01, 2007 3:26 am    Post subject: Reply with quote

slippppppppp wrote:
I want to translate this into Delphi.

Code:
void __declspec(dllexport)__stdcall ProcessMsg(UINT Message, WPARAM wParam, LPARAM lParam)
{
   MSG Msg;
   ZeroMemory(&Msg, sizeof(MSG));

   Msg.hwnd = FindWindow("MapleStoryClass", "MapleStory");
   Msg.lParam = lParam;
   Msg.message = Message;
   Msg.wParam = wParam;

   TranslateMessage(&Msg);
   DispatchMessage(&Msg);
}


ProcessMsg(WM_KEYDOWN, 0x11, 0x1D0001);


Here's my code:

Code:


Procedure processMessage(UINT:Message; WPARAM:wParam; LPARAM:lParam);
var
Message : UINT;
PARAMW : wParam;
PARAML : lParam;
LMSG : MSG;
begin
ZeroMemory(&Msg, sizeof(MSG));

 LMSG.hwnd = FindWindow('MapleStory',nil);
   LMSG.lParam = lParam;
   LMSG.message = Message;
   LMSG.wParam = wParam;

   TranslateMessage(&LMsg);
   DispatchMessage(&LMsg);
end;

procedure button1click(sender:Tobject);
begin
ProcessMsg(WM_KEYDOWN, 0x11, 0x1D0001);
ProcessMsg(WM_KEYUP, 0x11, 0x1D0001);
end;


Did i get this right?


[/code]


Change the '=' to ':=', the '&' to '@', and put the arguments of "FindWindow" as they are in the first code.

Edit: Change the '0x' to '$'
Back to top
View user's profile Send private message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Thu Nov 01, 2007 7:27 am    Post subject: Reply with quote

Thank you all^^ i just figured out how to

and slip, remov the '&', you dont need a pointer for TranslateMessage and DispatchMessage in Delphi

But i still have one problem, i can't send capital letters to a program (for an auto-login for example ..)

_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Nov 01, 2007 9:47 am    Post subject: Reply with quote

Deine Mutter wrote:
Thank you all^^ i just figured out how to

and slip, remov the '&', you dont need a pointer for TranslateMessage and DispatchMessage in Delphi

But i still have one problem, i can't send capital letters to a program (for an auto-login for example ..)

What is your code?
Back to top
View user's profile Send private message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Tue Nov 06, 2007 12:49 pm    Post subject: Reply with quote

Ok, in the meantime i solved the problem with capital letters. But for some strange reason i can't send the enter-key (shift-key works fine ..). Ther is also one thing which confuses me, everytime i try to send a WM_KEYDOWN or WM_KEYUP messages the game recieves a WM_CHAR message, is that normal (i didn't work with this method before, so i don't know). And is it also normal, that i can only send Key (WM_CHAR) messages?
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Wed Nov 07, 2007 12:58 am    Post subject: Reply with quote

I don't know, this is really strange.. I couldn't send WM_KEYDOWN with WM_RIGHT messages, no idea why..
Back to top
View user's profile Send private message
Deine Mutter
Expert Cheater
Reputation: 1

Joined: 05 Apr 2006
Posts: 181

PostPosted: Wed Nov 07, 2007 8:19 am    Post subject: Reply with quote

you mean VK_RIGHT ... right?^^
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Wed Nov 07, 2007 9:57 am    Post subject: Reply with quote

Yes, oops.. And I have NO idea what's the difference.. maybe it is connected to the WM_CHAR message you talked about..
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