Is it possible to sendkeys / Post Message directly to a HtmlElement rather than to a C# webbrowser

Posted by Jakub on Stack Overflow See other posts from Stack Overflow or by Jakub
Published on 2010-04-19T01:44:47Z Indexed on 2010/04/19 1:53 UTC
Read the original article Hit count: 675

I would like to send keys to a c# web browser control element directly, not just the window with the correct focus.

Right now I am able to send a key using PostMessage and documentHandle and focus like this

i.e. Pseudo Code HtmlElement el = getelement(); el.Focus(); IntPtr docptr = browser.Handle; PostMessage(docptr,WM_KEYDOWN,1,0); .... KEYCHAR, KEYUP..

I was wondering if anyone knows of any way to be able to do this in a background, so that the focus is not on the element. Basically is there a way to get a IntPtr to the HtmlElement itself, than use that instead in the PostMessage or SendKeys API rather than the browser handle/ptr.

© Stack Overflow or respective owner

Related posts about webbrowser

Related posts about sendkeys

  • .NET sendkeys to calculator

    as seen on Stack Overflow - Search for 'Stack Overflow'
    The sendkeys code below works well for Notepad but it doesn't work for Calculator. What is the problem? (It's another problem compared to what I sent here http://stackoverflow.com/questions/2604486/c-sendkeys-problem) [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr… >>> More

  • C# sendkeys to calculator

    as seen on Stack Overflow - Search for 'Stack Overflow'
    The sendkeys code below works well for Notepad but it doesn't work for Calculator. What is the problem? (It's another problem compared to what I sent here http://stackoverflow.com/questions/2604486/c-sendkeys-problem) [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr… >>> More

  • Cisco Configuration backup with Windows Script.

    as seen on Server Fault - Search for 'Server Fault'
    We have a client with a lot of Cisco Devices and we would like to automate the backups of these devices through telnet. We have both 2003 and 2008 servers and ideally use tftp to back it up. I wrote this: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso Set fso = CreateObject("Scripting… >>> More

  • C# sendkeys problem

    as seen on Stack Overflow - Search for 'Stack Overflow'
    THe code below I copied from MSDN with a bit of modification: [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); DllImport("User32")] public static extern bool SetForegroundWindow(IntPtr hWnd); int cnt = 0; private… >>> More

  • Sendkeys problem from .NET program

    as seen on Stack Overflow - Search for 'Stack Overflow'
    THe code below I copied from MSDN with a bit of modification: [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); DllImport("User32")] public static extern bool SetForegroundWindow(IntPtr hWnd); int cnt = 0; private… >>> More