#!/usr/bin/perl $| =1; use warnings; use strict; use Data::Dumper; use Win32::GUI; use Win32::API; my $proto = 'BOOL RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk)'; Win32::API->Import('user32', $proto) or die "import RegisterHotKey: $! ($^W)"; my $mw_win32 = new Win32::GUI::Window( -title => 'This is a test!', -width => 100, -height => 100, -name => 'MainWindow'); $mw_win32->Show(); # Call: my $ret = RegisterHotKey ($mw_win32->{-handle}, 10, 11 , 41); if (not $ret) { die "RegisterHotKey: $! ($^E)"; } print "Return: $ret\n"; $mw_win32->Hook( 273, sub {print "TEST"}); while (1) { Win32::GUI::DoEvents(); my $x = [$mw_win32->PeekMessage()]; print Dumper($x) if @$x > 1; }