auto log in program ....

This is a discussion on auto log in program .... within the C++ Programming forums, part of the General Programming Boards category; Hi, I want to make an "auto log in" program for my gmail account. I have it so that you ...

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

    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++
    Last edited by twomers; 01-13-2006 at 05:44 AM.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    5
    Wow, that's cool. ... hmmm, don't have a clue though.

  3. #3
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    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.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    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.

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    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 ?

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    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!!

  7. #7
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    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.

  8. #8
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    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

  9. #9
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Also, is there any way to disable the keyboard and the mouse for a specified amount of time??

  10. #10
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    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 01:12 AM.

  11. #11
    Registered User
    Join Date
    Oct 2005
    Posts
    26
    hehe I always found it easier just to use a macro

  12. #12
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    How do you do that??

  13. #13
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    so why dosent this press the t key
    keybd_event(54,0,0,0);
    keybd_event(54,0,KEYEVENTF_KEYUP,0);

  14. #14
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    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.

  15. #15
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    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

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 06-27-2008, 03:39 PM
  2. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 03:19 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Code: An auto expanding array (or how to use gets() safely).
    By anonytmouse in forum Windows Programming
    Replies: 0
    Last Post: 08-10-2004, 12:13 AM

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