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?
LVL 12
HypoAsked:
Who is Participating?
 
Russell LibbyConnect With a Mentor Software Engineer, Advisory Commented:
It WILL respond to the mouse_event api though. You will just need to calculate the position (in screen coords) to issue the mouse event.

Regards,
Russell


Eg:

  SetForegroundWindow(FindWindow('IEFrame', nil));

  mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, 100, 100, 0, 0);
  mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, 100, 100, 0, 0);

0
 
pcsentinelConnect With a Mentor Commented:
Check out the thread

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21406430.html

it may provide some answers

regards
0
 
Eddie ShipmanAll-around developerCommented:
The technique in that thread won't work because WebBrowser doesn't handle clicks in the same manner as regular windows.
0
 
HypoAuthor Commented:
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... :-/
0
 
Russell LibbySoftware Engineer, Advisory Commented:
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

0
All Courses

From novice to tech pro — start learning today.