简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM