<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; SendInput()</title>
	<atom:link href="http://weseetips.com/tag/sendinput/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>How to blink LED&#039;s in Keyboard?</title>
		<link>http://weseetips.com/2009/03/12/how-to-blink-leds-in-keyboard/</link>
		<comments>http://weseetips.com/2009/03/12/how-to-blink-leds-in-keyboard/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 17:53:13 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[blink keyboard LED]]></category>
		<category><![CDATA[enable capsLock]]></category>
		<category><![CDATA[enable NumLock]]></category>
		<category><![CDATA[enable scrollLock]]></category>
		<category><![CDATA[keybd_event()]]></category>
		<category><![CDATA[send keyboard input]]></category>
		<category><![CDATA[SendInput()]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=924</guid>
		<description><![CDATA[Do you remember those golden DOS days, where we access the video RAM directly and set the status of NumLock, ScrollLock etc and blink the LED of keyboard. Now in modern windows environment we are no more allowed to access the video RAM directly. But is there any way to blink the keyboard LEDs as [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
Do you <span style="color:#0000ff;">remember those golden DOS days</span>, where <span style="color:#0000ff;">we access the video RAM directly</span> and set the status of NumLock, ScrollLock etc <span style="color:#0000ff;">and blink the LED of keyboard.</span> Now <span style="color:#0000ff;">in modern windows environment</span> we are <span style="color:#0000ff;">no more allowed to access the video RAM directly.</span> But is there any way to blink the keyboard LEDs as we did before?</p>
<p><img class="alignnone size-full wp-image-930" title="keyboardblinking" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/03/keyboardblinking.jpg" alt="keyboardblinking" width="492" height="378" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
Yes. The trick is to <span style="color:#0000ff;">send NumLock keystroke event</span> by using <span style="color:#0000ff;"><strong>keybd_input()</strong></span> function. See the sample code snippet from MSDN.</p>
<pre>// Set NUMLOCK Status.
void SetNumLock( BOOL bState )
{
    BYTE keyState[256];

    GetKeyboardState((LPBYTE)&amp;keyState);
    if( (bState &amp;&amp; !(keyState[VK_NUMLOCK] &amp; 1)) ||
        (!bState &amp;&amp; (keyState[VK_NUMLOCK] &amp; 1)) )
    {
        // Simulate a key press
        keybd_event( VK_NUMLOCK,
                     0x45,
                     KEYEVENTF_EXTENDEDKEY | 0,
                     0 );

        // Simulate a key release
        keybd_event( VK_NUMLOCK,
                     0x45,
                     KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                     0);
    }
}

// Blink NUMLOCK.
void BlinkNumLock()
{
    // Blink status.
    bool bBlink = false;

    // Blink the NUMLOCK periodically.
    while( true )
    {
        SetNumLock( bBlink );
        bBlink = !bBlink;
        Sleep( 100 );
    }
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /></p>
<p>You can also use <span style="color:#0000ff;"><strong>SendInput()</strong></span>, which is the latest version of keybd_event() to simulate keystrokes.</p>
<p>And one more thing, I was searching for an image for this post, but couldn&#8217;t find a suitable one. And <span style="text-decoration:underline;"><span style="color:#0000ff;">this image is suggested by my wife.</span></span> <img src='http://weseetips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  How is it? <span style="color:#0000ff;">Did you like it? She would like to hear from you</span> <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-medium wp-image-53" title="intermediateseries" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg?w=248" alt="" width="248" height="32" /><br />
Targeted Audiance &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/03/12/how-to-blink-leds-in-keyboard/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

