The followers of the old school and those who like native solutions :) may adopt the following ages old code (which illustrates original Helen's suggestion):
'-------------------------------------------------------------------------------
Sub SetCapsLock(AState)
'Subroutine toggles the CAPS LOCK light.
'It takes a Boolean value that indicates whether the light should be turned off (FALSE) or on (TRUE).
' An application can simulate a press of the PRINTSCRN key in order to obtain a screen snapshot
' and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT.
' Windows NT: The keybd_event function can toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.
' Windows 95: The keybd_event function can toggle only the CAPS LOCK and SCROLL LOCK keys.
' It cannot toggle the NUM LOCK key.
If (AState And Not ((Win32API.GetKeyState(VK_CAPITAL) And 1) > 0)) Or _
(Not AState And ((Win32API.GetKeyState(VK_CAPITAL) And 1) > 0)) Then
' Simulate a key press
Call Win32API.keybd_event(VK_CAPITAL, VK_CAPITAL, KEYEVENTF_EXTENDEDKEY, 0)
' Simulate a key release
Call Win32API.keybd_event(VK_CAPITAL, VK_CAPITAL, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End If
End Sub
'-----------------------------------------------------------------------------
'-------------------------------------------------------------------------------
' The code simulates the Windows + R shortcut
Sub PressWindowsR
Call Win32API.keybd_event(VK_LWIN, 0, 0, 0)
Call Win32API.keybd_event(82, 0, 0, 0)
Call Win32API.keybd_event(82, 0, KEYEVENTF_KEYUP, 0)
Call Win32API.keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub
'-------------------------------------------------------------------------------