Hi Dave,
i am trying to create a ingame brower window. for this my dll is creating bmp's of the embedded browser which present on a win
form. This DLL is loaded by my proxy directx 9 dll which is called by the game. this give me real time render. I can watch youtube
video's in game without a single frameskip. the next step for me is the recreate a ingame click on a location x, y in my browser.
so that the navigation happens seamlessly. they are both one below each other in placement(start x and y for both ingame and out
of game is 0,0 for now).
below are the two functions that should be able to handle this. the mouse_event work perfectly when the browser is visible on
screen.but otherwise it down not. which is why i wanted to know if you can pass the handle of the browser like in SendMessage so
that the click happens in that.
In sendmessage the form becomes formost but no click happens.
private const int MOUSEEVENTF_LEFTDOWN = 0x2;
private const int MOUSEEVENTF_LEFTUP = 0x4;
private const uint WM_LBUTTONUP = 0x202, WM_LBUTTONDOWN = 0x201;
public unsafe void createleftclick() {
int x = 8, y = 8;
int point = x + (y << 16);
SetCursorPos(8, 8);
SendMessage(axWebBrowser1.Handle, WM_LBUTTONDOWN, 0, point);
SendMessage(axWebBrowser1.Handle, WM_LBUTTONUP, 0, point);
SendMessage(axWebBrowser1.Handle, WM_LBUTTONDOWN, 0, point);
SendMessage(axWebBrowser1.Handle, WM_LBUTTONUP, 0, point);
}
public void SendClick(int px, int py)
{
SetCursorPos(25, 25);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new System.IntPtr(0));
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new System.IntPtr(0));
}
My directx dll will just call the function directly
Regards
Abhishek
Dave Sexton said:
Hi Abhishek,
Is your 'game' by any chance tying up the UI Thread? You'd have to call Application.DoEvents() in that case to allow the Control
some time to process your mouse notifications, however a better program architecture would be more appropriate.
Actually, after reviewing your post a second time I'm not so sure I fully understand the situation.
Do you have two applications running simultaneously and you are attempting to get one application to send a mouse notification to
the other? If so, are both apps managed code?
Do you have a single, managed application with two visible Forms and you are attempting to send a mouse notification to a control
on the unfocused Form?
Please clarify. I'd like to help if I can.
--
Dave Sexton
Abhishek said:
Hi All
Getting the handle of the contol is not the problem. if I have a game running then the mouse event does not function (with
mouse_event). the sendmessage is not working at all, the application gets focus but the click event is not happening.
SendMessage(axWebBrowser1.Handle, WM_LBUTTONDOWN, 0, point);
SendMessage(axWebBrowser1.Handle, WM_LBUTTONUP, 0, point);
This is the mouse_event
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new System.IntPtr(0));
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new System.IntPtr(0));
regards
Abhishek
Hi Abhiishek,
Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt
this will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows or
EnumChildWindows Win32 API functions.
private void SimulateClick(Control ctrl)
{
if (ctrl == null)
throw new ArgumentNullException("ctrl");
int x = 8, y = 8;
int point = x + (y << 16);
SendMessage(ctrl.Handle, WM_LBUTTONDOWN, 0, point);
SendMessage(ctrl.Handle, WM_LBUTTONUP, 0, point));
}
private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, uint msg, int wparam, int lparam);
--
Dave Sexton
Hi,
how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that
application only even if there is any other window in front of it. I dont what to set focus. I just want the click event to
happen in that window directly.
Regards
Abhishek