C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-13-2006, 06:40 AM   #1
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
auto log in program ....

Hi, I want to make an "auto log in" program for my gmail account. I have it so that you can input a username and a password, it will encrpyt them, and save them in a text document. Then if you want to, it will run a program that will open "www.gmail.com". It copies my username into the clipboard, and I want it to paste it there. The thing is, the webpage isn't in my console window (obviously), so I don't know how to make it paste the information to where I desire it ...

This is the code for opening the webpage ... so if anyone could add something to it to paste the username and password to the right place, it'd be great!!!!!!!

PHP Code:
[code]# include<fstream>
# include<iostream>
# include<string>
# include<conio.h>
# include<tchar.h>
# include<time.h>
# include<windows.h>
using namespace std;


BOOL SetClipboardText(LPCTSTR pszText)
{
    
HGLOBAL            hGlobal;
    
int                nBytes;
    
LPTSTR            pClipboardData;
    
unsigned int    format;

#ifdef UNICODE
    
format CF_UNICODETEXT;
#else
    
format CF_TEXT;
#endif

    
if(!OpenClipboard(NULL))
        return 
FALSE;

    
EmptyClipboard();

    
nBytes = (_tcslen(pszText) + 1) * sizeof(TCHAR);

    
hGlobal GlobalAlloc(GMEM_MOVEABLE,nBytes);
    if(!
hGlobal)
    {
        
CloseClipboard();
        return 
FALSE;
    }

    
pClipboardData =(char*) GlobalLock(hGlobal);
    if(!
pClipboardData)
    {
        
CloseClipboard();
        return 
FALSE;
    }

    
memcpy(pClipboardData,pszText,nBytes);

    
GlobalUnlock(hGlobal);

    
SetClipboardData(format,hGlobal);

    
CloseClipboard();

    return 
TRUE;
}

int main()
{
    
int minutes;
    
char address[50]=" "key;
    
cout<< "\nWhat wep page do you want to go to??"
        
<< "\n\n\t"
        
<< (char)0x1a;
    for (
int i=0i<50i++)
    {
        
key getch();
        if ( (
char)key == 13 )
        {
            break;
        }
        else if ( (
char)key == )
        {
            if ( 
== )
            {
                
cout<< NULL;
            }
            else
            
i--;
            
address[i]=NULL;
            
cout<< (char)8
                
<< (char)0
                
<< (char)8;
            
i--;
        }
        else
        {
            
cout<< key;
            
address[i]=key;
        }
    }
    else if (
minutes == 0)
    
ShellExecute(NULL"open"addressNULLNULLSW_SHOWNORMAL);
    
SetClipboardText("username@gmail.com");
//Need something to paste the username
    
system ("PAUSE");
    
SetClipboardText("This isn't a password!!");
//Need something to paste the password
    
system ("PAUSE");
    return 
0;
}[/
code
Thanks!!!!

Twomers

EDIT: whoops, forgot: Windows XP and Microsoft Visual C++
__________________
I blag!

Last edited by twomers; 01-13-2006 at 06:44 AM.
twomers is offline   Reply With Quote
Old 01-13-2006, 07:19 AM   #2
Registered User
 
Join Date: Jan 2006
Posts: 5
Wow, that's cool. ... hmmm, don't have a clue though.
eagles is offline   Reply With Quote
Old 01-13-2006, 08:00 AM   #3
SSDD
 
Join Date: Jan 2005
Posts: 369
I've not tried this, so it may not work.

Maybe you could get the program to automatically hit the tab key to get it to the username and password. Then paste it in.

Or get the program to maximise the G-mail window. Then find out what the screen coordinate is for the usename. Mouse click there then paste it in... (that's a bit more iffy though and would only work on your computer).

I don't really know and may be totally wrong.
treenef is offline   Reply With Quote
Old 01-13-2006, 11:04 AM   #4
Registered User
 
Join Date: Sep 2004
Location: California
Posts: 2,845
This is quite a bit harder than you think it is. The main problem you face is that your program cannot simply paste text into the Edit boxes on the a browser. The reason is that pasting is handled by those edit controls, not by your application. The edit controls wait until they see a WM_PASTE message, then they copy the contents of the clipboard into their window.

Now you could attempt to send these controls a WM_PASTE message, but then you run into another problem. How do you get a handle to Edit controls in a web browser?

One thing you could try is a GET request in the browser itself. Instead of passing www.gmail.com to the browser, you could try something like this:
Code:
https://www.google.com/accounts/ServiceLoginAuth?Email=myemail@gmail.com&Passwd=mypasswd
I tested this, and it logged me into the user control panel. I then had to press the gmail link on the left to actually get to my gmail inbox.
As of right now, that is the only method I can think of to do what you are trying to do.
bithub is offline   Reply With Quote
Old 01-13-2006, 11:05 AM   #5
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
Well, I'd thought about both of those, but I just don't know the method of accomplishing it you see ... do you know how I can paste things into an internet explorer console ?
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-13-2006, 11:13 AM   #6
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
Quote:
Originally Posted by bithub

Code:
https://www.google.com/accounts/ServiceLoginAuth?Email=myemail@gmail.com&Passwd=mypasswd
sorry, i didn't see that post. Where did you get that address from?? that'd be really handy!!
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-14-2006, 08:13 AM   #7
adr
Registered User
 
Join Date: Dec 2005
Posts: 151
I know one way of doing it... a little more safer I think (if your scrip is encrip)1st make it bring up the web site and put focus onto the website. 2end Use Keybd_event() then set your name like so, letting the computer type it in, then make it press tab, and after that make it press in your password. It will take some time for you to put all that in but I do that with a game and it makes thing easier to log into.
adr is offline   Reply With Quote
Old 01-14-2006, 01:02 PM   #8
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
adr -

That's exactly what I'm looking for!!! I just don't know how to do that, is there any chance you could post up the source code???

twomers
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-14-2006, 01:14 PM   #9
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
Also, is there any way to disable the keyboard and the mouse for a specified amount of time??
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-15-2006, 02:07 AM   #10
adr
Registered User
 
Join Date: Dec 2005
Posts: 151
LOL I could, but I all ready did I thinkO.o; LOL I cant remember, I just ask stuff I didnt know on it, but for the most part its easy seeing as I did it and did have a clue yet on this stuffXD To use the keybd_event() you need to know that when your press something you know when yo pick it up, but the computer is not all that smart and will keep it down so you also need to make it press back up like in this code.
Code:
keybd_event(0,0,0,0);
keybd_event(0,0,KEYEVENTF_KEYUP,0);
This code press a key then lefts up on the key to simulate a keypressing. Best off looking up tho on your own, i'm not to good of a teacherXD. Then to get forcus on something I do a if(this is on) then put fouce thing on it, there is a faster way of doing it, but I like to make sure if its there or not.
Code:
if (FindWindow(NULL,"what your looking for")){
HWND pol = FindWindow(NULL,"what your looking for");
BOOL ret = SetForegroundWindow(pol);
I think thats all really. As much as I know anywaysXD LOL. Best of luck on it.

Part 2. I think there is. You have to look it up. To have like so meny sec. tho its easy. Just use
Code:
Sleep(for ever how long);
thats in millsec. So ever 1000 = 1sec.

Last edited by adr; 01-15-2006 at 02:12 AM.
adr is offline   Reply With Quote
Old 01-16-2006, 01:21 AM   #11
Registered User
 
Join Date: Oct 2005
Posts: 26
hehe I always found it easier just to use a macro
two31d is offline   Reply With Quote
Old 01-16-2006, 02:41 AM   #12
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
How do you do that??
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-16-2006, 04:45 AM   #13
Registered User
 
Join Date: Nov 2002
Posts: 249
so why dosent this press the t key
keybd_event(54,0,0,0);
keybd_event(54,0,KEYEVENTF_KEYUP,0);
__________________
Anddos is offline   Reply With Quote
Old 01-16-2006, 06:22 AM   #14
The superheterodyne.
 
twomers's Avatar
 
Join Date: Dec 2005
Location: Ireland
Posts: 2,205
Quote:
Originally Posted by Anddos
so why dosent this press the t key
keybd_event(54,0,0,0);
keybd_event(54,0,KEYEVENTF_KEYUP,0);
I'm not sure if this answers your question, but I'm not sure I really like the keybd_event() function too much. It's too keyboard-ey. The way I use it for my login program is that I use the copy to clipboard function (at the top of the very first post in this thread), alt-tab it to the window I want to go to, and then do the keyboard event thing to control-v it, to paste it to the appropriate place.

Does it print a 6 for you?? What do you want it to print? 54? It won't print what you have in the first arguement, i think. There is a table here which tells you what keys will do what, it's called a virtual key codes.

http://msdn.microsoft.com/library/de...alKeyCodes.asp

it's not great for printing off exactly what you want though, but it is a cool function.
__________________
I blag!
twomers is offline   Reply With Quote
Old 01-16-2006, 06:28 AM   #15
Registered User
 
Join Date: Nov 2002
Posts: 249
well the keycode 54 is ment to be t isnt it , so why dosent it press t
i wasnt wanting it to type the digits 54 if thats what your thinking
__________________
Anddos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get C program to respond to another softwares commands Euphorica C Programming 11 06-27-2008 03:39 PM
help with basic program JOlszewski C Programming 3 02-01-2006 04:19 PM
Dikumud maxorator C++ Programming 1 10-01-2005 06:39 AM
airport Log program using 3D linked List : problem reading from file gemini_shooter C Programming 3 03-04-2005 02:46 PM
Code: An auto expanding array (or how to use gets() safely). anonytmouse Windows Programming 0 08-10-2004 12:13 AM


All times are GMT -6. The time now is 03:34 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22