I have a small application with a webbrowser in it. in this webbrowser a webpage is loaded with a JAVA applet. this java applet has input prompts like the one shown in the image

i would need to be able to type a text inside this input dialog over a vb.net button. but i am unable to set the focus onto this input programmatically.

any help appreciated!

enter image description here

有帮助吗?

解决方案

There a few way to do that by using hooks. First one is to create local hook with SetWindowsHookEx

SetWindowsHookEx(WH_CALLWNDPROCRET, NativeMethods.HookProc,
                        IntPtr.Zero, (uint)AppDomain.GetCurrentThreadId());

and listen to WM_INITDIALOG windows messages, then find input textbox and insert required text. Sample code in Suppressing Hosted WebBrowser Control Dialogs

Second way is to use SetWinEventHook function and hook EVENT_SYSTEM_DIALOGSTART events and rest of processing is the same. You can find sample code in https://github.com/jsulak/Switcheroo/blob/master/ManagedWinapi/AccessibleObjectListener.cs

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top