| View previous topic :: View next topic |
| Author |
Message |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Wed Oct 31, 2007 2:26 pm Post subject: Sending Keystrokes to a process (Translate/DispatchMessage) |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Oct 31, 2007 2:59 pm Post subject: |
|
|
MSDN
_________________
|
|
| Back to top |
|
 |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Wed Oct 31, 2007 4:13 pm Post subject: |
|
|
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 |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Wed Oct 31, 2007 4:29 pm Post subject: |
|
|
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 |
|
 |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Wed Oct 31, 2007 5:19 pm Post subject: |
|
|
i just wanna know why lParam is 0x1D0001
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Oct 31, 2007 5:25 pm Post subject: |
|
|
| Deine Mutter wrote: | i just wanna know why lParam is 0x1D0001  |
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 |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Wed Oct 31, 2007 6:26 pm Post subject: |
|
|
And if you still haven't noticed, MSDN is referring to the bits in the dword lparam.
_________________
|
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Thu Nov 01, 2007 3:26 am Post subject: |
|
|
| 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 |
|
 |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Thu Nov 01, 2007 7:27 am Post subject: |
|
|
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 |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Thu Nov 01, 2007 9:47 am Post subject: |
|
|
| 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 |
|
 |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Tue Nov 06, 2007 12:49 pm Post subject: |
|
|
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 |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Wed Nov 07, 2007 12:58 am Post subject: |
|
|
| I don't know, this is really strange.. I couldn't send WM_KEYDOWN with WM_RIGHT messages, no idea why..
|
|
| Back to top |
|
 |
Deine Mutter Expert Cheater
Reputation: 1
Joined: 05 Apr 2006 Posts: 181
|
Posted: Wed Nov 07, 2007 8:19 am Post subject: |
|
|
you mean VK_RIGHT ... right?^^
_________________
|
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Wed Nov 07, 2007 9:57 am Post subject: |
|
|
| 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 |
|
 |
|