I think what you're in need of are global mouse and keyboard hooks. I've done this in a number of programs in c, but I doubt it will be as easy in Perl.

Here is the traditional steps to take when writing a global mouse (or keyboard) hook in c

  1. Create a DLL which has an exported function (e.g. createMouseHook(HWND h)). This DLL needs to have a section of shared memory which will be used to store the HWND of the calling program. This function calls SetWindowsHookEx, using WH_MOUSE or WH_KEYBOARD as the hook type. The callback specified must also be in this DLL.
  2. Within the mouse hook callback, use SendMessage to send a WM_COPYDATA message to the window whose HWND was stored during createMouseHook. In a COPYDATASTRUCT struct, store the necessary information to be passed to the program.
  3. In your main program, in your WndProc function, when you encounter a WM_COPYDATA message, do the appropriate processing for that message

These things are fairly trivial to do, but I've never attempted anything like it in Perl. Anyone know if there is an easier way to do this?


In reply to Re: Reading keyboard input without focus by lostjimmy
in thread Reading keyboard input without focus by KovaaK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.