Hello,
Welcome to Micorsoft Q&A!
You need to check both VirtualKey.state and CoreVirtualKeyStates to confirm if the Caps Lock button is on.
And for another question - switch the caps lock key's states, you need to add InjectedInputKeyOptions for the InputInjector object
You could use the following code:
// detect the caps lock key state
Dim keystate = Window.Current.CoreWindow.GetKeyState(VirtualKey.CapitalLock)
Dim isNumLocked = (keystate And CoreVirtualKeyStates.Locked) <> 0
// inject a caps lock key press no matter what's the state of it.
Dim inputInjector As InputInjector = InputInjector.TryCreate()
Dim info = New InjectedInputKeyboardInfo()
info.VirtualKey = VirtualKey.CapitalLock
'press the key
info.KeyOptions = InjectedInputKeyOptions.ExtendedKey
inputInjector.InjectKeyboardInput({info})
Await Task.Delay(100)
'release the caps lock key. If you do not release the key, the cap lock will remain pressed state
info.KeyOptions = InjectedInputKeyOptions.KeyUp
inputInjector.InjectKeyboardInput({info})
Await Task.Delay(100)
Thank you!