Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

catching ctrl+key combination

by maurice_chevalier (Initiate)
on Jul 30, 2013 at 08:04 UTC ( #1046967=perlquestion: print w/replies, xml ) Need Help??
maurice_chevalier has asked for the wisdom of the Perl Monks concerning the following question:

hail thee, monks.
platform is windows with active perl.
what i'd like to do is the following:
main part will be a perl tray-application sitting there waiting.
whenever a user marks something in another application and presses a ctrl+key combination ( i.e. "ctrl+a+b" )
i'd like to pass the marked string to the tray app for further computings.
question is how to "catch" the ctrl+key combination and how to reference the marked text ?
any tips greatly appreciated.

Replies are listed 'Best First'.
Re: catching ctrl+key combination (hotkey)
by Anonymous Monk on Jul 30, 2013 at 08:24 UTC
Re: catching ctrl+key combination
by samwyse (Scribe) on Jul 30, 2013 at 18:19 UTC
    Skip Perl, use AutoHotKey instead. To quote their home page:

    AutoHotkey is a free, open-source utility for Windows. With it, you can:
    • Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.
    • Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
    • [and a lot more that isn't relevant to your needs]
    The only "problem" is that it's syntax is like nothing you've ever seen. OTOH, (a) you can launch external programs, such as Perl scripts, without much effort, and (b) there's a forum that's always willing to help.

      I'll second that. AHK is specifically targeted for the OP use case. You can do the key monitoring, the selection grab and the pass-on-to-perl script in about one line each.

      The syntax and commands are certainly unique, so you'll want to have the AHK help file open at all times.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046967]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-06-20 23:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.