Link to home
Start Free TrialLog in
Avatar of Hypo
HypoFlag for Sweden

asked on

Simulating mouse events on a TWebBrowser

Hi, I'm writing an application that has some similarities with the RemoteDesktop function in windows.

In application A, we have a TWebBrowser control that I want to be able to control from application B, (which should be runing on a different computer) Ā 

A and B communicates via TCP network... (Indy10)
My plan was to make an imagecapture from the TWebBrowser component in A, and send that Image to B. The Image is then painted to a TCustomControl descendant in B, from which I also record all the WM_Mouse messages.

All WM_Mouse messages are sent over from B to A, and upon reception, they are posted to the TWebBrowser control.

I thought this would make it possible for me to control the TWebBrowser in A from B... but the WebBrowser control doesn't seem to react at all when I post the messages.

Any ideas why this doesn't work? or How this could be acheived in a better way?
SOLUTION
Avatar of pcsentinel
pcsentinel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eddie Shipman
The technique in that thread won't work because WebBrowser doesn't handle clicks in the same manner as regular windows.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hypo

ASKER

I didn't intend to use the mouse_event functions since I wanted to simulate the mouse events on a minimized window... But after giving it some thought I realized that I can't have a minimized window, mostly because of popupwindows and question/notification dialogs.

The mouse_event functions works fine, but the SetForegroundWindow makes it impossible to click any buttons in the window, I think that's because SetForegroundWindow changes focus from the button, link or whatever; between the LEFTDOWN and LEFTUP calls.

Removing the SetForegroundWindow makes it work fine.

(A notification to all you others who reads this question: The coordinates that's passed in the mouse_event function IS NOT pixels. the range of the coordinates are from 0..65535, where 0,0 is top-left corner, and 65535,65535 is bottom right corner of the screen or desktop)

I still dont understand why PostMessage doesn't work tho... :-/
Hypo,
One thing you should understand is that the controls in the IE window (buttons, links, edit fields, etc) are not true windowed controls (those with a handle). They are owner drawn / handled controls, and as such do not handle messages in the same way as a windowed control would.

Regards,
Russell