two useful windows functions

G

George Mpouras

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top