Well, then this is interesting to me aswell :) Wanted to be able of doing this while back... Gotta check it out more...

Found this on my hd. Not working properly.. dunno why exactly:
#!/usr/bin/env perl use Data::Dumper; use strict; use warnings; #use diagnostics; use Win32::API; use Win32::API::Callback; sub FILE_FLAG_BACKUP_SEMANTICS { 0x02000000 } sub WH_KEYBOARD { 2 } sub WH_KEYBOARD_LL { 13 } sub DWORD_SIZE { 4 } #my $kernel32 = 'kernel32.dll'; #my $advapi32 = 'advapi32.dll'; # HHOOK SetWindowsHookEx( # # int idHook, # HOOKPROC lpfn, # HINSTANCE hMod, # DWORD dwThreadId # ); # lpfn # [in] Pointer to the hook procedure. If the dwThreadId parameter +is zero or specifies # the identifier of a thread created by a different process, +the lpfn parameter must point # to a hook procedure in a dynamic-link library (DLL). Otherw +ise, lpfn can point to a hook # procedure in the code associated with the current process. # hMod # [in] Handle to the DLL containing the hook procedure pointed to +by the lpfn parameter. # The hMod parameter must be set to NULL if the dwThreadId pa +rameter specifies a thread # created by the current process and if the hook procedure is + within the code associated # with the current process. # dwThreadId # [in] Specifies the identifier of the thread with which the hook +procedure is to be associated. # If this parameter is zero, the hook procedure is associated + with all existing threads # running in the same desktop as the calling thread. # LRESULT CALLBACK LowLevelKeyboardProc( # int nCode, # WPARAM wParam, # LPARAM lParam # ); my $user32 = 'user32.dll'; my $callback = Win32::API::Callback->new( sub { my($a, $b) = @_; return $a+$b; }, "INN", "N", ); my $SetWindowsHookEx = new Win32::API($user32, 'SetWindowsHookEx', 'IPNN', 'I'); print Dumper($SetWindowsHookEx); if (!$SetWindowsHookEx) { print $^E . "\n"; print Win32::GetLastError(); exit; } my $idHook = WH_KEYBOARD_LL; my $lpfn = \&hello; #pack("L", 0); my $hMod = 0; my $dwThreadId = 0; my $ok = $SetWindowsHookEx->Call( $idHook, $lpfn, $hMod, $dwThreadId ) or die $^E; print Win32::GetLastError(); sub hello { }
"Doesn't work to set a non-local hook without a modulereferense (handle) at globalKeysWin32.pl line 79, <DATA> line 164."
Whatever that means... may be helpfull? Please tell me if you make it work!

Ace

In reply to Re^4: Windows Hotkey by Ace128
in thread Windows Hotkey by eric256

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.