two useful windows functions

Discussion in 'Perl Misc' started by George Mpouras, Apr 4, 2014.

  1. Many people are searching a method to find if the "Caps Lock" key is
    pressed at Windows. Here is working solution.
    useful when automating stuff using the Win32-GuiTest to send keys ,
    control windows and mouse



    use Win32::API;

    # If the caps lock is pressed
    $function = Win32::API::More->new('user32', 'GetKeyState', "I", "N");
    die "Error: $^E" if ! $function;
    print $function->Call(20) ,"\n"; # VK_CAPITAL is 20


    ## Get current keyboard layout
    my $function = Win32::API::More->new('user32', "GetKeyboardLayout", '',
    'N');
    die "Error: $^E" if ! $function;
    print sprintf("%x", $function->Call) ,"\n"; #408 0408 Greek , 409 0409
    United States, etc
     
    George Mpouras, Apr 4, 2014
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.