keybd_event type a (period)

This is a discussion on keybd_event type a (period) within the Windows Programming forums, part of the Platform Specific Boards category; okay so i need the program to type a period " . " and thats about it... lol yeah i ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    7

    keybd_event type a (period)

    okay so i need the program to type a period " . " and thats about it... lol yeah i just dont know the code for it? if anyone can help thatd be great.

    Code:
    	      keybd_event(0x39, NULL, KEYEVENTF_EXTENDEDKEY, NULL);    // Key down
           keybd_event(0x39, NULL, KEYEVENTF_KEYUP, NULL);          // Key up
    
    
    to...
    
    
    	      keybd_event(PERIOD, NULL, KEYEVENTF_EXTENDEDKEY, NULL);    // Key down
           keybd_event(PERIOD, NULL, KEYEVENTF_KEYUP, NULL);          // Key up

  2. #2
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Well, the documentation don't mention previous uses of that but under 2000/XP, you can use VK_OEM_PERIOD.

    Oh, and you should have posted that into the Windows section, those who are there would probably give you a better answer than those you get from here.

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    7
    sorry... ha guess i dont know the difference, but can soemone still help?

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    7
    C:\Program Files\Microsoft Visual Studio\MyProjects\testing\keytest.cpp(18) : error C2065: 'VK_OEM_PERIOD' : undeclared identifier

    that doesnt work...

    Code:
    #include <windows.h>           // Win32 API function support
    
    
    
    INT APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nShowCmd)
    {
    	// TODO: Now we will perform what we want to do 
    	{
    	    HWND hParent = FindWindow(NULL, "Untitled - Notepad");  // Find window
    	    if (hParent)     // Valid window handle?
    		{
    		    SetForegroundWindow(hParent);    // Show the window
    		    SetFocus(hParent);     // Set window focus to new window
    		    // Loop through twenty-five
    		    for (int l = 0; l < 25; l++) 
    			{
    
    	      keybd_event(VK_OEM_PERIOD, NULL, KEYEVENTF_EXTENDEDKEY, NULL);    // Key down
    		         keybd_event(VK_OEM_PERIOD, NULL, KEYEVENTF_KEYUP, NULL);          // Key up
    			}
    		}
    		else 
    			return 0;      // Invalid window handle; exit
    	}
    
    
    
    	return 0;
    }

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    The hex ASCII code for a period is 0x2E. You could have found that out pretty easily using Windows Character map. And you don't need to use extended key.

    Code:
    keybd_event(0x2E, NULL, NULL, NULL);
    keybd_event(0x2E, NULL, KEYEVENTF_KEYUP, NULL);
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    7
    i know i might sound stupid but wheres the windows character map?

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    It depends on your Windows, but it should always be somewhere in Programs/Accessories. Mine is in Programs\Accessories\System Tools.

    Once you open it, select the System font, click on the character you want, and in the status bar, the hex code is displayed. Alternatively, you can just do this:

    Code:
    keybd_event('.', NULL, NULL, NULL);
    The apostrophes convert the character contained within to it's ASCII code. I don't know why I didn't remember that before. It's much better than using the hex codes, because it allows you to see which character you're actually using. So, you could do the following:

    Code:
    	      keybd_event(VK_SHIFT, NULL, NULL, NULL);    // Key down
    	      keybd_event('2', NULL, NULL, NULL);    // Key down
    		  keybd_event('2', NULL, KEYEVENTF_KEYUP, NULL);          // Key up
    		  keybd_event(VK_SHIFT, NULL, KEYEVENTF_KEYUP, NULL);          // Key up
    Note: That's the code from your other thread.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 08:59 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 01:59 AM
  3. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 01:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

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