I am trying to send a message to a game (to automate text commands), the problem is that I can't figure out how to use the information from spy++ to write a C# sendmessage function.
I was able to use spy++ to get
00220540 S WM_SETCURSOR hwnd:0024052C nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
Could anyone provide a breakdown of what this means, and how to send the message to the game in c#?
EDIT:
I found out that I was looking at the wrong process. Instead of looking at the javaw.exe, I was looking at the actual game.
Here is the code for pressing t:
<00919> 0038062A WM_INPUT nInputCode:RIM_INPUT hRawInput:189E0973
<00920> 0024052 P WM_KEYUP nVirtKey:'T' cRepeat:1 ScanCode:14fExtended:0fAltDown:0fRepeat:1fUp:1
So lets start with the signature for SendMessage, from Pinvoke.net:
It taks a window handle, hWnd, a message ID, Msg, and two generic parameters wParam and lParam which change meaing based on the message ID.
What spy++ is showing you is the parameters that were sent to SendMessage. As you can see it doesn't show you wParam and lParam, but hwnd, nHittest, and wMouseMsg. That's because Spy++ knows what the wParam and lParam parameters actually mean for a WM_SETCURSOR message and is decoding them for you.
So decoding each piece of the what Spy++ has sent:
00220540
- the window handle receiving the message - the hWnd parameter.S
- It means it was sent via SendMessage() and not posted via PostMessage(). See http://msdn.microsoft.com/en-us/library/aa265147(v=vs.60).aspxWM_SETCURSOR
- The message ID - the Msg parameter.hwnd:0024052C
- handle of the Window containing the cursor - the wParam parameter.nHittest:HTCLIENT
- the hit test code - the low word of the lParam parameter.wMouseMsg:WM_MOUSEMOVE
- the mouse message - the high word of the lParam parameter.The way you would go about sending the message to a window is:
For understanding what other messages mean you can do a search on Msdn.com for the messsage in the Windows documentation.
So after answering all of that I don't think this will have anything to do with sending keys to the game you are trying to control. WM_SETCURSOR doesn't have anything to do with keyboard input.