.NET Process to open web page without tabs or address bar - c#

Is there a way in .NET to have a Process open the default web browser with no address bar and no tabs, WITHOUT using kiosk mode? I can't use the WebBrowser object because it uses IE7, and the pages that need to be opened use JavaScript. I can't use kiosk mode because the client needs the window to appear in a specific area of the screen. I also need to maintain access to the browser because I have to know when the page is closed.

Try this:
dynamic ie = Activator.CreateInstance(Type.GetTypeFromProgID("InternetExplorer.Application"));
ie.AddressBar = false;
ie.MenuBar = false;
ie.ToolBar = false;
ie.Visible = true;
ie.Navigate("www.google.com");
This uses automation to achieve what you want.
You can also set the position, add event handlers, etc.
The documentation for this interface is here.

If you want to acheive browser automation then you should use Selenium webdriver

Related

User data not persisting in DotNetBrowser component

Using DotNetBrowser in WPF app in Windows 10. When navigating to certain pages that typically save user data and use it in subsequent loads to restore your settings, it doesn't seem to be happening.
See example code here of a very simple implementation. If I use it to browse to Amazon's site and login, after closing and reopening app, I'll need to login again -- in a normal browser like Chrome, it retains my login. Is something missing in the code to enable this similar behavior?
To make it work, I had to set UserDataDirectory when creating engine:
engine = EngineFactory.Create(new EngineOptions.Builder
{
RenderingMode = RenderingMode.HardwareAccelerated,
UserDataDirectory = $"{Environment.ExpandEnvironmentVariables("%AppData%\\MyApp\\Chromium\\User Data")}",
LicenseKey = ConfigurationManager.AppSettings["DotNetBrowserLicenseKey"],
}
.Build());

Open customized external web browser with .NetStandard

We need to be able to open a web browser from within our application (.NetStandard 2.0). The browser should be opened as an external application, the requirement does not call for the browser to be embedded in our application, thus using the WebBroswer control is not an option. We need to be able to specify the following options:
Height of the browser
Width of the browser
Top position
Left position
Addressbar enabled or disabled
Menubar enabled or disabled
Statusbar enabled or disabled
Toolbar enabled or disabled
We initially thought that using the Process class would work, but it doesn't seem that these options can be specified with the Process class. Any articles or recommendations as to how we can achieve this would be greatly appreciated!
You could consider creating a Windows Form application or WPF application, then use the WebBrowser control to display the web page.
More detail information about using WebBrowser control, please check the following links:
WebBrowser Control Overview
How to: Add Web Browser Capabilities to a Windows Forms Application
How to show address bar in WebBrowser control
WebBrowser Control In WPF
Try to use the InternetExplorer object to control an instance of Windows Internet Explorer.
First, right click the application Reference and select Add Reference option, then in the COM tab, checked the Microsoft Internet Controls and click OK to add reference.
Then, refer to the following code to use InternetExplorer object:
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
ie.Navigate("http://www.bing.com");
ie.ToolBar = 0; //hide or display the toolbar.
ie.AddressBar = false; //hide or display the AddressBar.
ie.Left = 200;
ie.Height = 800;
ie.Width = 500;
ie.StatusBar = false; // hide or display the statusBar.
ie.Visible = true; //display IE browser.
More detail information about the properties, please check the IWebBrowser2 interface.

Embed Internet Explorer browser into Winforms using C#

I'm trying to open a IP specified webpage using IE (Why IE? Because not every Windows have Chrome or Firefox installed) and present it in a simple Winforms window.
The up-mentioned webpage is a BI (Business Intelligence) webpage that will update itself dynamically, and I want the user to sit and look at it while the page is updated with a new statistics.
Flow of events:
User will enter the specific IP address and click "Get the Web-page".
New Winform window will pop-up with the specific webpage inside.
Also, it will be great if there an option to hide IE navigation panel, because I don't want to give the option of browsing in this window.
I tried to do this using CefSharp, but I didn't get to anywhere. Every example that I saw was written in asp.
Here is was I did so far, and this is not working:
namespace BingoDesktopWindow
{
public partial class BingoWin : Form
{
public BingoWin()
{
InitializeComponent();
CefSettings settings = new CefSettings();
CefSharp.Cef.Initialize(settings);
ChromiumWebBrowser browser = new ChromiumWebBrowser("http://12.345.67.89/bingo/Default.html");
this.browserPanel.Container.Add(browser);
}
}
Thank you!
}
Why do not you use Winforms WebBrowser control. WinForms WebBrowserControl. You can manipulate it more than IE. Web browser control is itself derived from IE so, it has all its functionalities.

Inserting text from a C# WinForms application into a web browser textbox

I'm currently working on a WinForms application that I'm hoping will allow users to enter stored passwords into a web browser without a keylogger being able to see the password. I've got the storing part completed, but I can't figure out how to insert the password into a browser without using either the clipboard or .NET's SendKeys class, both of which can be seen by most keyloggers.
I looked into using Windows messages to do this, but, from what I understand, you need to know the hWnd of a control in order to send it a Windows message. Unfortunately, it appears that web browsers do not use hWnds for individual textbox controls.
I know there has to be a way to do this. In Notepad++, for example, you can drag text into a web browser textbox and the text doesn't show up in keyloggers. Same goes for Neo's SafeKeys. Anyone have any ideas on a general approach to doing this? Thanks so much.
What you want is a WebDriver Library. Unfortunately .net does not have plenty of good ones. You can take a look at WatiN or selenium
From what I understand watin isn't supported anymore and is not multi-browser compatible.
Here is an example of what you can do with selenium
using (var driver = new ChromeDriver())
{
driver.Navigate().GoToUrl("http://testing-ground.scraping.pro/login");
var userNameField = driver.FindElementById("usr");
var userPasswordField = driver.FindElementById("pwd");
var loginButton = driver.FindElementByXPath("//input[#value='Login']");
userNameField.SendKeys("admin");
userPasswordField.SendKeys("12345");
loginButton.Click();
}
I image you can link your driver to an existing opened browser
If you are able to run ruby on the computers I would recommend using Watir
and running the ruby script doing the web manipulation from the c# using processes.

How to launch a browser and later direct it to a page?

I need to launch a browser, do some work and then make the browser navigate to a URL (in that order).
The first part is of course simple and I have a Process object. I am at a loss as to how to later direct it to the target page?
How do I treat the Process as a browser and make it navigate to the desired page?
Any help, pointers, code snippets appreciated.
Instead of launching the browser & then navigating to the page, just tell the OS that you want to run the URL. Windows will pick the correct browser, and navigate the user to the given URL.
System.Diagnostics.Process.Start("http://www.StackOverflow.com");
If you don't need to do this in production, you could use a testing library such as WatiN to do this:
using WatiN.Core;
//Placeholder page to launch initial browser
IE ie = new IE("http://www.google.com");
DoSomeWork();
//Now navigate to the page you want
ie.GoTo("http://stackoverflow.com");
My first instinct for this question was DDE, but it appears that has been decommissioned in Windows Vista so that is no good. Shame, as it was the only consistent mechanism in Windows for Interprocess Communication (IPC)...oh how I miss Arexx on the Amiga.
Anyhow, I believe the following will work but unfortunately, due to the way it works, it launches Internet Explorer irrespective of the configured browser.
If your application has a Form, then create a WebBrowser control on it. Set this to non-visible as we are only making use of its as a launching device rather than to display the web page.
In code, at the point where you want to show a web page, use the following code:
webBrowser1.DocumentText = "window.open('How to launch a browser and later direct it to a page?', 'BananasAreOhSoYummy');";
What this does is to tell the WebBrowser control, which is just the IE in disguise, to open a new window called 'BananasAreOhSoYummy'. Because we have given the window a name, we can use that line repeatedly, with different URLs, to change the page in that particular browser window. (A new window will be opened if the user has happened to close it.)
I will have a think about an approach that honours the user's default browser choice.
If you don't need the actual instance of IE, you can use the System.Windows.Forms.WebBrowser control.
I think instead of sending the browser a url you could send it javascript that would run and direct the browser to a site.
Not sure if this would work but I see no reason why it wouldn't

Categories

Resources