Thread: sending a string as keyboard keystrokes wrongly

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    sending a string as keyboard keystrokes wrongly

    sending a string as keyboard keystrokes wrongly

    as u can see from my following code, KeyBoadText() is a function that accepts a string and then type the string out as if it was typed using the keyboard. but now i am having problem when my typetext = "abc"
    instead of typing "abc", it types "123". how can i solve this?

    Code:
     void CStocksmsDlg::KeyBoardText(CString typetext)
    {
    	
    	int text_len = typetext.GetLength();
    
    
     for(int i =0; i<text_len; i++)
     {
    	    INPUT Input[2];
      KEYBDINPUT ki;
    
      ki.dwFlags = KEYEVENTF_EXTENDEDKEY | 0;
      ki.time = 0;
      ki.wScan = 0;
      ki.wVk = typetext.GetAt(i);
      Input[0].type = INPUT_KEYBOARD;
      Input[0].ki = ki;
      ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
      ki.dwFlags = KEYEVENTF_KEYUP;
      Input[1].type = INPUT_KEYBOARD;
      Input[1].ki = ki;
      SendInput( 2, Input, sizeof(INPUT) );
    }
    
    }

  2. #2
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    I just answered you here

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  5. Sending a string to C++ from VB 6.
    By VirtualAce in forum C++ Programming
    Replies: 4
    Last Post: 08-21-2001, 02:28 AM