<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Simulating Keyboard presses in games.' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Simulating Keyboard presses in games.' posted on the 'Beginner C/C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2008 Programmers Heaven</copyright>
    <pubDate>Thu, 21 Aug 2008 16:21:11 -0700</pubDate>
    <lastBuildDate>Thu, 21 Aug 2008 16:21:11 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Simulating Keyboard presses in games.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/367574/367574/simulating-keyboard-presses-in-games/</link>
      <description>Hey I need some help. Using Borland C++Builder 6&lt;br /&gt;
&lt;br /&gt;
I just programmed a sort of autotyper. I tell the program what to type then I activate it and it'll start typing that.&lt;br /&gt;
&lt;br /&gt;
My problem is that the program works fine for example notepad or msword but doesn't work when playing some games.&lt;br /&gt;
&lt;br /&gt;
Currently I'm using the code&lt;br /&gt;
&lt;pre class="sourcecode"&gt;keybd_event(90,0,0,0);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
My program was made to simulate keypresses so it should be exactly the same as pressing the keyboard. The game responds to presses on the keyboard but not to my program, why?&lt;br /&gt;
&lt;br /&gt;
Is there a diffrence between using "keybd_event(90,0,0,0);" and actually pressing a key on the keyboard?&lt;br /&gt;
&lt;br /&gt;
Im trying to simulate the letter "z" value equals 90&lt;br /&gt;
&lt;br /&gt;
Also I have a Saitek P990 joypad plugged in that can "simulate" keypresses. Why can't my program do the same?</description>
      <pubDate>Sat, 24 Nov 2007 23:27:51 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
    <item>
      <title>Re: Simulating Keyboard presses in games.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/367574/367575/re-simulating-keyboard-presses-in-games/#367575</link>
      <description>: Hey I need some help. Using Borland C++Builder 6&lt;br /&gt;
: &lt;br /&gt;
: I just programmed a sort of autotyper. I tell the program what to &lt;br /&gt;
: type then I activate it and it'll start typing that.&lt;br /&gt;
: &lt;br /&gt;
: My problem is that the program works fine for example notepad or &lt;br /&gt;
: msword but doesn't work when playing some games.&lt;br /&gt;
: &lt;br /&gt;
: Currently I'm using the code&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;: keybd_event(90,0,0,0);&lt;/pre&gt;: &lt;br /&gt;
: &lt;br /&gt;
: My program was made to simulate keypresses so it should be exactly &lt;br /&gt;
: the same as pressing the keyboard. The game responds to presses on &lt;br /&gt;
: the keyboard but not to my program, why?&lt;br /&gt;
: &lt;br /&gt;
: Is there a diffrence between using "keybd_event(90,0,0,0);" and &lt;br /&gt;
: actually pressing a key on the keyboard?&lt;br /&gt;
: &lt;br /&gt;
: Im trying to simulate the letter "z" value equals 90&lt;br /&gt;
: &lt;br /&gt;
: Also I have a Saitek P990 joypad plugged in that can "simulate" &lt;br /&gt;
: keypresses. Why can't my program do the same?&lt;br /&gt;
&lt;br /&gt;
There are 3 different kinds of keyboard events: key_down, key_up, and key_pressed. Most games use the first 2 to store the keyboard state and then allow the game loop to perform the necessary actions. This is because then they can detect how long you're holding the key instead of just knowing that you pressed it. The keybd_event() might generate the last 1 (ie key_pressed). Since games don't necessarily watch for that event, it goes by unnoticed.</description>
      <pubDate>Sun, 25 Nov 2007 01:25:06 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
    <item>
      <title>Re: Simulating Keyboard presses in games.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/367574/367580/re-simulating-keyboard-presses-in-games/#367580</link>
      <description>: There are 3 different kinds of keyboard events: key_down, key_up, &lt;br /&gt;
: and key_pressed. Most games use the first 2 to store the keyboard &lt;br /&gt;
: state and then allow the game loop to perform the necessary actions. &lt;br /&gt;
: This is because then they can detect how long you're holding the key &lt;br /&gt;
: instead of just knowing that you pressed it. The keybd_event() might &lt;br /&gt;
: generate the last 1 (ie key_pressed). Since games don't necessarily &lt;br /&gt;
: watch for that event, it goes by unnoticed.&lt;br /&gt;
&lt;br /&gt;
I changed the code to&lt;br /&gt;
&lt;pre class="sourcecode"&gt;keybd_event(90,0,0,0);
keybd_event(90,0,2,0);
keybd_event(90,0,1,0);&lt;/pre&gt;&lt;br /&gt;
The game did notice the first two 'z' but then not. There is a possibility that the game is blocking programs like mine, but if my program is simulating a keystroke then there shouldn't be anyway it could notice the diffrence.&lt;br /&gt;
&lt;br /&gt;
Thanks for your help&lt;br /&gt;
&lt;br /&gt;
I googled a bit.&lt;br /&gt;
"keybd_event Function&lt;br /&gt;
Windows NT/2000/XP/Vista:This function has been superseded. Use SendInput instead." Does that mean anything? Heres a link.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/ms646310.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms646310.aspx&lt;/a&gt;</description>
      <pubDate>Sun, 25 Nov 2007 06:57:51 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
    <item>
      <title>Re: Simulating Keyboard presses in games.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/367574/367632/re-simulating-keyboard-presses-in-games/#367632</link>
      <description>How would I program it so that there is absolutly no diffrence from actually pressing the "z" key?&lt;br /&gt;
&lt;br /&gt;
If ya think about how windows interprets a key press what message do my keyboard actually send when I press a key?&lt;br /&gt;
&lt;br /&gt;
Please help.&lt;br /&gt;</description>
      <pubDate>Tue, 27 Nov 2007 04:46:53 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
  </channel>
</rss>