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
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