Send Key To Active Window

This is a discussion on Send Key To Active Window within the C++ Programming forums, part of the General Programming Boards category; im tryign to send a key to the active window it just doesnt seem to be working Code: #include <windows.h> ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    2

    Send Key To Active Window

    im tryign to send a key to the active window it just doesnt seem to be working

    Code:
    #include <windows.h>
    #include <Winuser.h>
    int main()
    {
    	while ( 1 == 1) {
    	HWND Window;
    	Window = GetActiveWindow();
    	SendMessage(Window, WM_KEYDOWN, VkKeyScan('c'), 0);
    	SendMessage(Window, WM_CHAR, VkKeyScan('c'), 0);
    	SendMessage(Window, WM_KEYUP, VkKeyScan('c'), 0);
    	Sleep(1000);
    	}
    }

  2. #2
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    Try using

    Code:
    keybd_event(0x43,0,0,0);

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    2
    xD thanks wow i was overworking my self

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. Function to check memory left from malloc and free?
    By Lechx in forum C Programming
    Replies: 4
    Last Post: 04-24-2006, 06:45 AM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 11:45 PM
  5. run a program
    By goodmonkie in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2001, 12:19 PM

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