If your aiming for a cross-platform solution, I doubt that there is an easy answer to this.

If your aiming at the Windows platform, then you may be able to do something with the latest version of dada's Win32API and use it to call user32.dll:RegisterHotkey and/or possibly user32.dll:RegisterShellHookWindow. You would need to get the system to call your code when your chosen hotkey is pressed. The latest version (0.41) of Win32::API purports to allow you to call win32 native APIs that require a callback address, though I haven't used that functionality yet.

You would probably need to create a gui window to act as the windowproc for callback. You might look at Win32::GUI to do that. There are also many useful functions in the Win32::GUITest module that would be useful for giving your window the focus etc. if and when you can get the system to call you.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller



In reply to Re: hotkey...again by BrowserUk
in thread hotkey...again by Foggy Bottoms

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.