4

I've been using SendMessage to send mouse clicks to a couple of windows. One being a game(everything works perfectly), but the other window, being a 3rd party tool for the game is having trouble with SendMessage. If the window is 'not minimized' everything works fine, don't matter if window is completely covered up by another. But if that same window is minimized then nothing happens, I checked with spy++ and the messages are indeed getting received but not being processed (correct term?). I've tried to solve this last couple days, doing both searches on here and Google alike, many of topics but nothing helped?

//MyImports
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

And this is how I have it wrapped

public static void LClick(string windowclass, int x, int y)
{
    IntPtr WHandle = FindWindow(windowclass, null);
    SendMessage(WHandle, (int)WMessages.WM_LBUTTONDOWN, (IntPtr)1, (IntPtr)MakeLParam(x, y));
    SendMessage(WHandle, (int)WMessages.WM_LBUTTONUP, (IntPtr)0, (IntPtr)MakeLParam(x, y));
}

I have tried focus, activate. One thing that might be useful info is that the third party program is being loaded as module("Qt5QWindowIcon") of the game.

I tried PostMessage as well, and it does the same thing as SendMessage() same problem when minimized.

This game does allow for macroing and unattended macroing, Hints the third part tool designed to execute the macros (published by the creators) I'm just trying to simulate a mouse click on the program to start the macro.

I would just use SendInput, but the entire purpose of my program is to run in background.

user247702
  • 23,641
  • 15
  • 110
  • 157
RichardP
  • 43
  • 4
  • 5
    SendMessage works just fine with "minimized windows" since it doesn't actually need to be a window at all. It is probably that other application that for some reason stops pumping messages while minimized. – Lasse V. Karlsen May 01 '14 at 17:07
  • 1
    I've seen on more that one instance that an application disables controls during minimization--which means they probably don't handle certain messages while minimized. If that's the case, I know of no way to get around that. – Peter Ritchie May 01 '14 at 17:15
  • Can you control how the third party tool is opened? If so, you could write a small service that opens it in the SYSTEM context so it has no visible UI, then you can run it maximized and send it whatever you want, without it ever displaying. – Ed Bayiates May 01 '14 at 17:20
  • I take that back, The messages was being sent when minimized(promise) but looks to be now they are not. But still works when window is not minimized. I did do a few changes ill try to back up and and try to recreate the part that was sending messages when minimized. – RichardP May 01 '14 at 17:23
  • FYI dont know why i didnt mention this earlier, the program is called UOSTEAM, In which you can find info about it from RunUO dot com. And to AresAvatar i understand the general ideal of what your saying, but how to go about doing something like that im clueless. – RichardP May 01 '14 at 17:29
  • Let's use the Socratic method. What is the size of a minimized window? What happens when you click your mouse outside of a window? – Hans Passant May 01 '14 at 17:40
  • @RichardP, here's an example of a small service: http://www.codeproject.com/Articles/3990/Simple-Windows-Service-Sample – Ed Bayiates May 01 '14 at 17:42
  • Thanks for the replies, ill read up on the service sample, because it is interesting. Sorry for being such a pain, but i dont like using code when i dont understand how it works, rhis is only for educational purposes, dont even play the game anymore (enjoyed learning something new). Just used it since it was a older game, didnt expect the 3rd party tool to be such a ninny. – RichardP May 02 '14 at 11:16

1 Answers1

-1

I 've faced same problem .Please change assembly name and project name (Changed name not started with name on that you are throwing/posting windows message)then rebuild it and check it. Now you will able to debug.

Jayesh Tank
  • 129
  • 1
  • 8