Qusetion about sending VK_CONTROL

This is a discussion on Qusetion about sending VK_CONTROL within the Windows Programming forums, part of the Platform Specific Boards category; Problem: My friends CTRL key sends the "insert" button for whatever reason on her laptop Solution: Write a program that ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    66

    Qusetion about sending VK_CONTROL

    Problem: My friends CTRL key sends the "insert" button for whatever reason on her laptop
    Solution: Write a program that will send the ctrl message to everything whenever insert is pressed

    (At least that's the hope, the main thing is for WC3 when she is creating ctrl groups, aka: you select a few units and press ctrl + 1, but for her it does insert + 1 which does nothing, and we can't remap the in-game ctrl key to something else, so we're trying to remap the insert to ctrl for anything (for general use) )

    Anyways, so I wrote some code and it works...sorta. When my program sends the VK_CONTROL command it like closes programs and stuff? o.O

    Any idea what I'm ........ing up on?

    Code:
    int runthread = 0;
    
    unsigned __stdcall FixThread( void* pArguments )
    {
    	while ( runthread == 0)
    	{
    		if ( GetAsyncKeyState(VK_INSERT) )
    			SendMessage(HWND_BROADCAST, VK_CONTROL, NULL, NULL);
    	}
    
        _endthreadex( 0 );
        return 0;
    } 
    
    ...
    
    
    // at some point start the thread
    _beginthreadex( NULL, 0, &FixThread, NULL, 0, NULL );
    Oh, and is there any way I can keep it constantly checking for insert, but without running at 100% cpu? I'm guessing a timer, but I don't know for sure. (I'm waiting to address that problem until it actually works, but I figured now I might as well ask it here as well just in case anyone knows )

    Sorry in advanced if it's something stupid.
    Last edited by tjpanda; 12-04-2008 at 05:01 AM.
    "When your work speaks for itself - don't interrupt!"

    -Samantha Ingraham.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,642
    You could try a keyboard hook, but that probably won't effect the game at all since many game interact with the keyboard at a lower level (through direct input).

    Easiest thing to do is to buy a new USB keyboard and use it instead.

    gg

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    66
    Hm...well I'll try that and if it doesn't work out then oh well ^^
    "When your work speaks for itself - don't interrupt!"

    -Samantha Ingraham.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,642
    Try this out: http://webpages.charter.net/krumsick/
    Googling revealed other similar programs.

    gg

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    66
    edit:

    Great thanks ^^ That program did just the trick XD
    Last edited by tjpanda; 12-04-2008 at 02:21 PM.
    "When your work speaks for itself - don't interrupt!"

    -Samantha Ingraham.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending data - line by line?
    By tuckker in forum C Programming
    Replies: 0
    Last Post: 02-21-2009, 08:31 PM
  2. signal sending and waiting
    By eva69 in forum C Programming
    Replies: 1
    Last Post: 10-03-2008, 12:03 PM
  3. a doubt about sending an array to a function
    By louis_mine in forum C Programming
    Replies: 13
    Last Post: 05-14-2005, 11:50 PM
  4. Sending an Array to a function
    By bizounce in forum C Programming
    Replies: 2
    Last Post: 04-08-2003, 05:40 PM
  5. Sending text to an edit box
    By ColdFire in forum Windows Programming
    Replies: 1
    Last Post: 09-24-2002, 07:46 PM

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