NAME
Win32::GlobalHotkey - Use System-wide Hotkeys independently
VERSION
Version 0.01
SYNOPSIS
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;
DESCRIPTION
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.
The stored callback is executed in the context of the thread.
METHODS
new
Constructs a new object.
You can pass a parameter warn
with your own callback method to the constuctor. Defaults to:
Win32::GlobalHotkey->new(
warn => sub {
carp $_[0];
}
);
Beware! The callback is executed in thread context at the time the EventLoop is running.
PrepareHotkey( parameter => value, ... )
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.
StartEventLoop
This method starts the MessageLoop for the (new) hotkey thread. You must stop it to change registered hotkeys
StopEventLoop
Stops the MessageLoop. Currently, it only detachs and kill the hotkey thread.
GetConstant( name )
Static utility method to return the appropriate constant value for the given string.
AUTHOR
Tarek Unger, <tu2 at gmx.net>
BUGS
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.
TODO
SUPPORT
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)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
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:
- Around line 108:
You can't have =items (as at line 112) unless the first thing after the =over is an =item