Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 20:12

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# - SendMessage/PostMessage

Discussion on C# - SendMessage/PostMessage within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
C# - SendMessage/PostMessage

Hello, I have recently started to toy around with the idea of sending a mouse click, or other events, to a conquer client that is minimized, or just not in focus. I have been using Spy++ to help along in all the messages the client receives and what not. I have got it kind of working and was wondering if anyone here could give me a hand.
Code:
//WM_PARENTNOTIFY-SendMessage-ParentWindow
bool seven = MouseClickHandler.SendMessage(new IntPtr(0x004F04CA), (int)0x0210, new IntPtr(0x00000201), new IntPtr(MouseClickHandler.getHiLoWord(730, 719)));

//WM_SETCURSOR-Sendmessage-"Macromdia" window
bool two = MouseClickHandler.SendMessage(new IntPtr(0x00140210), (int)0x0020, new IntPtr(0x00140210), new IntPtr(0x02000001));

//WM_MOUSEMOVE-PostMessage-"Macromedia" window
bool four = MouseClickHandler.PostMessage(new IntPtr(0x00140210), (uint)0x200, IntPtr.Zero, new IntPtr(MouseClickHandler.getHiLoWord(730, 719)));

//WM_MOUSEACTIVATE-SendMessage-"Macromedia" window
bool one = MouseClickHandler.SendMessage(new IntPtr(0x00140210), (int)0x021, new IntPtr(0x004F04CA), new IntPtr(0x02010001));

//WM_LBUTTONDOWN-PostMessage-"Macromedia" window
bool three = MouseClickHandler.PostMessage(new IntPtr(0x00140210), (uint)0x201, new IntPtr(0x00000001), new IntPtr(MouseClickHandler.getHiLoWord(730, 719)));

//WM_MOUSEMOVE-PostMessage-"Macromedia" window
bool six = MouseClickHandler.PostMessage(new IntPtr(0x00140210), (uint)0x200, new IntPtr(0x00000001), new IntPtr(MouseClickHandler.getHiLoWord(730, 719)));

//WM_LBUTTONUP-PostMessage-"Macromedia" window
bool five =  MouseClickHandler.PostMessage(new IntPtr(0x00140210), (uint)0x202, IntPtr.Zero, new IntPtr(MouseClickHandler.getHiLoWord(730, 719)));
This is what I have so far, I haven't worried about finding the hWnd of any of the necessary windows yet because I don't want to spend the time if it doesn't work. So basically I open the client then my windows form and click the button. I have the simulated mouse click click the "enter" button so there is a pop up. If I send the messages multiple times rapidly the button gets clicked. When I don't send it rapidly you can just see the enter button get highlighted so I know the SETCURSOR and MOUSEMOVE messages are moving.

I'm not sure if anyone has messed with this before, and actually got it working, but the other threads I have found didn't provide any good information. Any help appreciated.

Edit: So I still have not figured it out but I logged in and did a mouse click in game and it works. Would still be interested in if anyone has a reason why the above code only works when its sent repeatedly. thanks.

Thanks
Santa is offline  
Old 12/07/2013, 13:48   #2
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 991
Received Thanks: 1,107
The reason you have to send the message rapidly/repeatedly is that the message you are sending is not the only message the client is expecting/waiting for to process..
There are hundreds of internal messages that the client has to handle and since you are an intruder sneaking through the backdoor your message is most likely being lost and not reaching its destination...

Now i could be wrong since that is not the only reason your messages are not being processed right away..


However all you need to send is...
WM_LBUTTONDOWN -> WM_LBUTTONUP On the desired X/Y the rest is useless... And if by "button" you mean the Enter button on the login screen then follow the mouse clicks with a WM_KEYDOWN with a VK_RETURN for the wParam.

Edit..
And by the way the client pretty much sleeps when its minimized and the sleeping states also includes/restricts many messages from being processed.. So don't get your hopes up unless you are planing something simple.
{ Angelius } is offline  
Old 12/08/2013, 01:40   #3
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
Quote:
Originally Posted by { Angelius } View Post
The reason you have to send the message rapidly/repeatedly is that the message you are sending is not the only message the client is expecting/waiting for to process..
There are hundreds of internal messages that the client has to handle and since you are an intruder sneaking through the backdoor your message is most likely being lost and not reaching its destination...

Now i could be wrong since that is not the only reason your messages are not being processed right away..


However all you need to send is...
WM_LBUTTONDOWN -> WM_LBUTTONUP On the desired X/Y the rest is useless... And if by "button" you mean the Enter button on the login screen then follow the mouse clicks with a WM_KEYDOWN with a VK_RETURN for the wParam.

Edit..
And by the way the client pretty much sleeps when its minimized and the sleeping states also includes/restricts many messages from being processed.. So don't get your hopes up unless you are planing something simple.

I figured it was because I was missing some of the messages, I tried sendinge every message received around the time of the click in all windows.

Either way its working when logged into the game, and mouse clicks work just fine when screen is minimized.

Thanks
Santa is offline  
Old 12/21/2013, 03:16   #4
 
elite*gold: 0
Join Date: Nov 2013
Posts: 1
Received Thanks: 0
I'm actually working on a bot that uses sendmessage/postmessage as well. Currently it pathfinds and jumps to specified coordinates, uses xp skill automatically when the bar reaches 100, and autopots. As of right now, I don't know how to read memory structures or have in-depth knowledge of memory so I can't scan for monsters and their coordinates to automate accurate attacks so I have done a horrible way to just click in circular motions around the player to attack mobs that surround and then jump to the next spawn spot.
Kid Nieh is offline  
Reply


Similar Threads Similar Threads
PostMessage / SendMessage (C#)
06/23/2013 - CO2 Programming - 2 Replies
I am trying to send key presses & mouse presses to the conquer window using PostMessage in C# but Conquer doesn't seem to respond to anything I send it. I am able to send key presses correctly to windows calculator though. Just wondering if anyone has had success using PostMessage / SendMessage and would be kind enough to share. Is there any other way to send key presses / mouse clicks while the conquer window is minimized? Thanks for any help :)
SendMessage or PostMessage ?
01/26/2013 - Perfect World - 4 Replies
How do i simulate keypress in C++ Builder ? SendMessage or PostMessage ? A Example would be really nice, im new to this all :o
SRO SendMessage API
02/26/2012 - SRO Coding Corner - 5 Replies
Hello. I want make simple clicker on vSRO. but I can't do so would only click on SRO I know I need to use SendMessage API but I do not know how to do it Can someone show me it on this code: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start()
[Help] C# SendMessage()
05/11/2010 - CO2 Programming - 19 Replies
I'm currenty trying to use the SendMessage Function with CO. According to msdn I need to use this: static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); My question is: How do I find the hWnd? What are the wParam and lParam? And what can I use as wParam and lParam? Any help will be greatly appreciated.
sendmessage?
12/26/2008 - CO2 Programming - 0 Replies
just wondering how it works in C# tried few tutorials with notepad in it and it doesnt send the letters/close it even it finds the window this is how i got it so far (pretty much copypasted, just to see how it works...) private static extern IntPtr FindWindow(string winClass, string WinName); private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); private static extern IntPtr PostMessage(IntPtr hWnd,...



All times are GMT +2. The time now is 20:12.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.