Thread: Send Key To Active Window

  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
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    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, 05: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, 10:45 PM
  5. run a program
    By goodmonkie in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2001, 11:19 AM