I\'m working on a project, a Web Bot, that makes use of a WebBrowser control.
My aim is to programmably open the webBrowsers ContextMenu on a desired element in the
It depends on your concrete requirement. If you want to operate particular HTML element, you can access it via DOM. IMO, you can do everything that WebBrowser can do.
If you want to use the context menu (to avoid writing extra code or to pretend an user operation), you can send a mouse click at desired position and then block context menu popup temporary. Here is my sample code in Delphi for your reference.
function TTrident.ShowContextMenu(const dwID: DWORD; const ppt: PPOINT; const pcmdtReserved: IUnknown;
const pdispReserved: IDispatch): HRESULT;
begin
if FDontShowContextMenuThisTime then
begin
FDontShowContextMenuThisTime := False;
Exit(S_OK);
end
else
Exit(S_FALSE);
end;
ShowContextMenu
is one method of the interface IDocHostUIHandler
. In other words, you have to extend the WebBrowser control by implementing at least IDocHostUIHandler
. See also MSDN.