Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So I managed to get it working myself, here's what I found.</p> <p>DOSBOX is an <a href="http://www.libsdl.org/" rel="nofollow noreferrer">SDL application</a> and so runs in OpenGL. Sending messages to OpenGL applications has been <a href="https://stackoverflow.com/questions/8544271/how-can-i-send-keyboard-input-to-a-opengl-directx-game-window">discussed before</a> and is done using the <a href="http://msdn.microsoft.com/en-gb/library/windows/desktop/ms646310(v=vs.85).aspx" rel="nofollow noreferrer"><code>SendInput()</code> method</a>. This is apparantly what <code>SendKeys</code> calls under the hood so I'm not sure why that wasn't working for me but it looks like I'm not the only one.</p> <p><a href="http://inputsimulator.codeplex.com/" rel="nofollow noreferrer">This unmaintained library</a> seems to work fine, or a custom implementation can be done <a href="http://www.ownedcore.com/forums/mmo/warhammer-online/186390-sendinput-example-c.html" rel="nofollow noreferrer">like this</a>.</p> <p>The other option as discussed in the stack overflow link above is to write a C or C++ library and call it through the C# application. This is what I ended up doing, here's the code.</p> <p>Down.h</p> <pre><code>extern "C" __declspec(dllexport) void PressDownKey(); </code></pre> <p>Down.cpp</p> <pre><code>#include &lt;Windows.h&gt; #include "Down.h" extern "C" __declspec(dllexport) void PressDownKey() { KEYBDINPUT KeybdInput; ZeroMemory(&amp;KeybdInput, sizeof(KeybdInput)); KeybdInput.wVk = VK_DOWN; KeybdInput.dwExtraInfo = GetMessageExtraInfo(); INPUT InputStruct; ZeroMemory(&amp;InputStruct, sizeof(InputStruct)); InputStruct.ki = KeybdInput; InputStruct.type = 1; int A = SendInput(1,&amp;InputStruct,sizeof(INPUT)); Sleep(10); ZeroMemory(&amp;KeybdInput, sizeof(KeybdInput)); KeybdInput.wVk = VK_DOWN; KeybdInput.dwFlags = KEYEVENTF_KEYUP; KeybdInput.dwExtraInfo = GetMessageExtraInfo(); ZeroMemory(&amp;InputStruct, sizeof(InputStruct)); InputStruct.ki = KeybdInput; InputStruct.type = 1; A = SendInput(1,&amp;InputStruct,sizeof(INPUT)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload