Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will need to interface with <code>Notepad.exe</code> via <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944%28v=vs.85%29.aspx" rel="nofollow">PostMessage</a>. You will need to use <code>P/Invoke</code> techniques to call this from <code>User32.dll</code>:</p> <pre><code>using System.Runtime.InteropServices; internal static class NativeMethods { // This method signature is derived from MSDN's PostMessage declaration. [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr hwnd, uint msg, uint wParam, uint lParam); // Other p/invoke methods go here, such as FindWindow... } </code></pre> <p>You can locate <code>Notepad</code> with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx" rel="nofollow">FindWindow</a>, allowing you to get the window's handle (<code>HWND</code>).</p> <p>Once you do so, you can post <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff468861%28v=vs.85%29.aspx" rel="nofollow">Keyboard Notifications</a> to that window. Those notifications simulate keyboard input and are only for that window, even if the window is minimized or otherwise not the foreground window.</p> <p>The messages of importance will be <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx" rel="nofollow">WM_KEYDOWN</a>, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx" rel="nofollow">WM_KEYUP</a>, and <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646276%28v=vs.85%29.aspx" rel="nofollow">WM_CHAR</a>. Many of these take in <strong>scan codes</strong> instead of <strong>virtual key codes</strong>, meaning you will need to translate back and forth. This is done with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646306%28v=vs.85%29.aspx" rel="nofollow">MapVirtualKey</a>. All of the WM commands take specific forms of their <code>LPARAM</code> and <code>WPARAM</code> values, so check the MSDN documentation of what it expects.</p> <p>There's a tool called <code>Spy++</code> that (used to?) comes with Visual Studio that lets you peek at these messages. It's a great debugging/reverse engineering tool for this type of stuff.</p> <p>Using all of the above Win32 API, you should be able to send keystrokes to an external window.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. 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