Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to Create a button once i click it The user canlogin automatically login certain website like "Facebook" by stored user name and password in text file

I make search and came up with this simple code but it not work!!

can any one Explain the problem!!

<pre lang="c#">

private void button2_Click(object sender, EventArgs e)
  {
     System.Diagnostics.Process.Start("http://www.facebook.com/");

     int flag = 1;

     while (flag == 1)

     {


       SendKeys.Send("Username.Txt");

       SendKeys.Send("{TAB}");

       SendKeys.Send("Password.Txt");

       SendKeys.Send("{TAB}");

       SendKeys.Send("{ENTER}");

       flag = flag + 1;

     }

 
}


Thank U.
Posted

Please do not do it this way, you or the users of your application will thank you.

Facebook offers a special API for these actions: See here[^] for more info.
 
Share this answer
 
Comments
Ohoud_Yahya 17-Apr-12 20:59pm    
The main idea is Automatic login to any website by send stored user name and password NOT by cookies !! so what can i do?! :(
Henning Dieterichs 18-Apr-12 10:11am    
You shouldn't send the password via SendKeys. Not only because it will be very easy to write a Key Logger (simply watch the windows messages), but also because the password will be sent in plain text and if the browser-window looses and an editor gets the focus, everyone can read the password.
There are only some rare cases, in which this method can be useful, e.g. in a digital password safe like KeePass.
Maybe you should consider writing a browser extension.
use the DOM.
webbrowser.document.getelementbyid("usernameinputboxid").innerText = 
textbox1.textl;

webbrowser.document.getelementbyid("passwordinputboxid").innerText = textbox2.textl;

webbrowser.document.getelementbyid("loginbuttonid").invokemember("click");

then you can create an xml file that maitains the element ids, what values to put in them, wich button to click and automate the whole thing.


my 2 cents anyway
 
Share this answer
 
v2
Try OneClickLogin tool (Just one click to login the website)

http://oneclicklogin.net[^]
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 23-Apr-12 2:56am    
Link Formatted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900