SendKeys question

This is a discussion on SendKeys question within the Windows Programming forums, part of the Platform Specific Boards category; so i found this on the msdn website.. Code: C++ private: // Clicking Button1 causes a message box to appear. ...

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    SendKeys question

    so i found this on the msdn website..
    Code:
    C++
    
    private:
       // Clicking Button1 causes a message box to appear.
       void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
       {
          MessageBox::Show( "Click here!" );
       }
    
       // Use the SendKeys.Send method to raise the Button1 click event 
       // and display the message box.
       void Form1_DoubleClick( Object^ /*sender*/, System::EventArgs^ /*e*/ )
       {
          
          // Send the enter key; since the tab stop of Button1 is 0, this
          // will trigger the click event.
          SendKeys::Send( "{ENTER}" );
       }
    http://msdn2.microsoft.com/en-us/lib...keys.send.aspx

    my question is, is this mfc? and can you accomplish the same thing with win32?

    thanks
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    It's not MFC, it's managed C++. To use win32, use the keybd_event() function.

  3. #3
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    hm...interesting.

    so then would it be possible to use keybd_event() to output like a string? like have it simulate me typing my name?
    Registered Linux User #380033. Be counted: http://counter.li.org

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Yeah. keybd_event() is the same function the keyboard driver uses. Calling keybd_event() is the same thing as typing the characters on the keyboard.

  5. #5
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    so then when i tell it to press a key, will it try to press a key in my program or could i have it type my name in like notepad?
    also, how would i make it type a letter? would it be like (BYTE)'t' for the key i want?
    Registered Linux User #380033. Be counted: http://counter.li.org

  6. #6
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    cluelessness?


    that doesn't happen often...
    Registered Linux User #380033. Be counted: http://counter.li.org

  7. #7
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    so then when i tell it to press a key, will it try to press a key in my program or could i have it type my name in like notepad?
    It does the same thing as pressing a key on the keyboard. That is, the input is directed to the window that has the focus.
    also, how would i make it type a letter? would it be like (BYTE)'t' for the key i want?
    You need to use the capital letters: 'T'. See virtual key codes for constants for other keys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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