c# outlook vsto add-in with webbrowser control. How do I get a handle on the browser control and Send keystrokes to it?

Outlook does not pass through certain key stokes (backspace, ctrl-c etc) to the web browser control on my outlook vsto add-in pane. I have created a keyboard hook that works and I can intercept the back space for example but I have been unable to send the back space command to the web browser control. Here is my code that does NOT work...

SendMessage(webBrowser1.Handle.ToInt32(),
               WM_KEYDOWN, ((int)kbDllHookStruct.vkCode), 0);

Any ideas?
oberon99Asked:
Who is Participating?
 
oberon99Connect With a Mentor Author Commented:
Thanks roshmon,
Okay so I have resolved this I think. Purely by accident whilst investigating.
This is an odd one and I've yet to do more testing but right now it is working.

On the add-in pane I created the events
 
  _PreviewKeyDown
  _KeyUp
  _KeyDown

by double clicking on these events via the property editor. This creates the stubs.
I put no code into these events (well initally I put in messageboxes to show me the keys pressed) and this seems to be what makes it work. I've taken out my keyboard hook as well.

So I dunno if this is a resolution or not but for now I'll take it.
Thanks
0
 
Roshan DavisCommented:
few options
- Can you try control.SendKeys("{BS}") ?
- Can you try PostMessage instead of SendMEssage?
- Is the Keyboard hook is holding the BackSpace are you sending? can you check it is passing back the value to the actual window after your hook logic?
0
 
brianw2212Commented:
oberon99:
So how did this turn out? i have the same problem but i cannot catch  
 _PreviewKeyDown
  _KeyUp
  _KeyDown

without using low level hookup, even with low level hookup to catch the backspace key events, still cannot forward it to browser control to make it work.

I'd appreciate it if you can let me know how this was resolved in details?

Thanks
0
 
oberon99Author Commented:
No sorry this is still only working intermittantly.
You're not catching the events but instead just creating them via the property edtior (events for the webbowser control).
0
All Courses

From novice to tech pro — start learning today.