Inspect Element Using System.Windows.Forms.WebBrowser - vb.net

Using the context menu inside internet explorer allows you to inspect the element to see styles etc attached to a html element.
Is there anyway that you enable this functionality inside the webbrowser control?
(I am guessing it is not included to make it lighter, if so is there an alternative?)
It is not my intention to make this available to the client but it would certainly help when debugging the pages sent to the control in my winform application.

As no one seemed to bite on this question I have settled with using the following solution.
https://getfirebug.com/firebuglite#Stable
Using the instructions on this page I was able to press F12 on the webbrowser control to show a "Lite" version of Firebug, this allows me to happily inspect the elements.

Related

Can you make a keyboard shortcut to select a button on a website?

This question is mostly just out of curiosity at what's possible. I'm interested to know any ideas at all.
If I'm on a website, is it possible to make a keyboard shortcut for clicking a button on that site? For example, if I'm on google.com, is it possible to write a script somewhere on my own system that will detect that I'm on google.com and make it so that if I press ctrl-g while that site is in focus, it will click Google Search?
If you know for sure that this isn't possible and have an explanation for why, I'd be interested to know that too.
Yes, it's possible.
I'll briefly describe how to do it in C# and Chrome, but it's not language-dependent and could be used in Edge or IE either.
Get the currently focused window by calling GetForegroundWindow API.
Get the process id by calling the GetWindowThreadProcessId API.
Get the process name by process id.
Proceed if it's Chrome.
Get access to UI Automation COM interface.
You will need to consume the COM interface in your language, but in C# it's quite easy: you'll need to add a reference to COM -> UIAutomationClient to your project. This will generate a wrapper for you, so the COM interface will be accessible in the code in a usual OO-style.
In Chrome, the Accessibility options must be enabled first to get access to UIA.
It could be done manually by navigating to chrome://accessibility/, but it's possible to do it programmatically as well.
Use UI Automation to detect the active URL.
You will need to find the Address bar in the UI tree using UIA by its Name or ClassName or another unique identifier.
You could first retrieve the UI Automation element for the Chrome window and then use the FindAll method to find the Address bar in the subtree to get its Value property which should contain the current URL.
Inspect tool will help you to investigate the Chrome UIA element tree and element properties (like Name or ClassName).
Do the same steps to find the Google Search button in the UI tree using UIA.
Call GetClickablePoint method to get its clickable point.
Click on the button programmatically using Win API.
To do this on a global shortcut, you could place a keyboard hook by calling SetWindowsHookEx API. Or use a library.
Here is another way.
That's it, easier than it looks.

How to generate Domino dialogboxes on traditional (non-xpages) webforms

I want to have a popup/dialogbox with an "OK" button on it that will close the dialogbox...after someone performs a task on a Domino webform. I know I used overlays in xpages before, but the current application I am maintaining was built with traditional Domino forms (lots of pass-thru HTML) and my initial attempt to build an overlay effect did not work.
I have tried using javascript code of:
var window = window.open(url, windowName, [windowFeatures]);
...but this has not been successful. No errors in debug, yet my url page does not pop up. I am hoping someone might be able to provide a snippet of what you use so I can see where I am going wrong.
The url parameter I am passing is correct, as I used an alert to show me what was going in there, but I am doing something basic wrong.
If I can answer any questions for you I can do that as well.
Thank you
The only way I know to display a dialog box in a classic Domino web application is to do just like you would on any HTML-based webpage. Either you create your own popup functionality, or you use one of the many plugins available.
When I work with classic Domino web applications, I have often added Bootstrap to it, to make things look a bit better. Then I can use either the native Bootstrap dialog boxes, or a plug-in called Bootbox.js. But there are many other ones.

Is it possible to use a textarea for a Safari extension settings?

I've made a couple small Safari extensions. For one of them, I would like to collect a set of user-entered strings (e.g., URLs or URL patterns) using a textarea in the settings screen. The only setting types offered in the documentation are one line text, check box, slider, select lists, and radio buttons. I could use a one line text field as an ugly workaround, but I'm hoping there's a better option. I've googled for hints and looked through Safari extensions in GitHub, but haven't found an example of anyone doing this yet.
Does anyone have an example of how to use a textarea for a Safari extensions setting? Is there an undocumented feature I've not been able to find? Or is there a way to trigger a custom popup window from the settings?
Thanks for any tips.
No, there is no way to build a more complex UI inside the settings dialog. What extensions typically do is add a button (checkbox, even if it's not quite the correct element) in the settings page which then launches a separate Safari page which contains the full settings UI, written in HTML.
For an example of this, install uBlock and take a look at how it launches its setting UI.

WebBrowser Control is Running into Javascript Error that IE doesn't

If I use IE I can visit the website I want and click the 'Next' button and life is good. If I open that same website using the webBrowser control and click the 'Next button I get a javascript error message.
I'm not doing anything in the code to manipulate the website. My goal, eventually, is to have some level of automation; but at this point, I get the javascript error and a pop-up and it screws everything else.
I can hide the JS error from popping up; by setting 'WebBrowser1.ScriptErrorsSuppressed = True' but the page isn't working because of the error.
The client script might be assuming a full browser is present and trying to access part of the browser outside the Document Object Model (DOM) of the page. For example, maybe the client script is trying to display something on the browser's status bar, or trying to modify a toolbar which isn't available in the WebBrowserControl. There could be numerous similar reasons.
If you do not have write-access to the web page in question to try fixing it, then play with WebBrowser Control properties such as ScriptErrorsSuppressed and ObjectForScripting
Try setting WebBrowser1 Silent property to true.
Actually, you are receiving this problem because when you run your site in IE8 or IE9 on your normal internet explorer desktop app, you are getting either IE8 or IE( rendering, depending on which you have installed. However, with the webbrowser control, unless you take the effort to change soem settings in the registry, the default rendering engine used by the webbrowser control is IE7 (if u have 7, 8 or 9 installed) and IE4 (if you have 4, 5 or 6 installed).
This is why you are having the problem, if you want help changing the rendering engine version for your webbrowser control, do a google search as there are many examples on SO, and i have provided this answer in some of my previous posts on this tag/topic. feel free to search or ask me.
Let me know how you go.

How can I navigate to different webpages in the same MSIE window in VB.NET

I have code that opens a new window but I want to be able to edit the same one.
System.Diagnostics.Process.Start("iexplore.exe", "http://www.live.com")
I'm not sure exactly but a good pointer to start off might be to get the handle of the window you're interested in:
http://www.pocketpcdn.com/articles/dotnetcf_hwnd.html
And then separately investigate what interop messages you can send to IE to change the URL in tab X
In order of increasing difficulty and increased control/power:
Send input text to your IE process. Alt-D to focus on the navigation bar, then the URL, then ENTER.
Use MSAA to find the navigation bar and send it text, as above.
Use MSAA to get IHTMLDocument access to the browser, and then programmatically drive the browser with that, and the related interfaces.
I don't know your exact scenario, but if you can host your own instance of MSHTML, or a WebBrowser control, it will make it a lot easier to get the interfaces and do the manipulations mentioned in #3 above; doing that stuff cross-process is fraught with peril.
I just did a web search and turned up a WatiN tool that apparently wraps a lot of this work; perhaps it would be useful for you.
If you are using 2008 there is a feature where you could create a second form and then add a Webbrowser control
the page could then be called by
myForm.show
The page could then be changed with the
Webbrowser1.Url = New Uri("http://www.google.com")
Use the following code:
System.Diagnostics.Process.Start("http://www.live.com")
That is: do not invoke iexplore.exe directly – just let the system figure out which default browser to open.
This may yield two behaviours:
Either it opens a new tab in an existing Internet Explorer window,
or it creates a new window.
The important point is that this depends on a preference that can be controlled within the Internet Explorer application. If a new window opens, then this is the setting chosen by the user – do not try to override it: overriding the user’s preferences is considered bad manners.
If the users don’t want a new window opened, they can simply change that in their Internet Explorer preferences.