Win32::GlobalHotkey - Use System-wide Hotkeys independently
Version 0.01
use Win32::GlobalHotkey; my $hk = Win32::GlobalHotkey->new; $hk->PrepareHotkey( vkey => 'B', modifier => Win32::GlobalHotkey::MOD_ALT, callback => sub { print "Hotkey pressed!\n" }, # Beware! - You are in another thread. ); $hk->StartEventLoop; #... $hk->StopEventLoop;
This module let you create system wide hotkeys. Prepare your Hotkeys with the PrepareHotkey method. StartEventLoop will initialize a new thread, register all hotkeys and start the Message Loop for event receiving.
PrepareHotkey
StartEventLoop
The stored callback is executed in the context of the thread.
Constructs a new object.
You can pass a parameter warn with your own callback method to the constuctor. Defaults to:
warn
Win32::GlobalHotkey->new( warn => sub { carp $_[0]; } );
Beware! The callback is executed in thread context at the time the EventLoop is running.
Prepares the registration of an hotkey. Can be called multiple times (with different values). Can not be called after StartEventLoop.
The following parameters are required:
vkey
The pressed key. Currently only the letter keys (a-z) are supported.
modifier
The Keyboard modifier (ALT, CTRL, SHIFT, WINDOWS). Use the following. Can be combinated with a Bitwise OR ("|").
Win32::GlobalHotkey::MOD_ALT
Win32::GlobalHotkey::MOD_CONTROL
Win32::GlobalHotkey::MOD_SHIFT
Win32::GlobalHotkey::MOD_WIN
callback
A subroutine reference which is called if the hotkey is pressed.
This method starts the MessageLoop for the (new) hotkey thread. You must stop it to change registered hotkeys
Stops the MessageLoop. Currently, it only detachs and kill the hotkey thread.
Static utility method to return the appropriate constant value for the given string.
Tarek Unger, <tu2 at gmx.net>
<tu2 at gmx.net>
Sure.
Please report any bugs or feature requests to bug-win32-globalhotkey at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Win32-GlobalHotkey. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-win32-globalhotkey at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Win32::GlobalHotkey
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Win32-GlobalHotkey
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Win32-GlobalHotkey
CPAN Ratings
http://cpanratings.perl.org/d/Win32-GlobalHotkey
Search CPAN
http://search.cpan.org/dist/Win32-GlobalHotkey/
Copyright 2012 Tarek Unger.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
1 POD Error
The following errors were encountered while parsing the POD:
You can't have =items (as at line 112) unless the first thing after the =over is an =item
To install Win32::GlobalHotkey, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::GlobalHotkey
CPAN shell
perl -MCPAN -e shell install Win32::GlobalHotkey
For more information on module installation, please visit the detailed CPAN module installation guide.