<p>Using VB.NET, how do I toggle the state of Caps Lock?  </p>

[{'answer_id': 58941, 'author': 'GEOCHET', 'author_id': 5640, 'author_profile': 'https://Stackoverflow.com/users/5640', 'pm_score': 4, 'selected': True, 'text': '<p>From: <a href="http://www.vbforums.com/showthread.php?referrerid=61394&amp;t=537891" rel="noreferrer">http://www.vbforums.com/showthread.php?referrerid=61394&amp;t=537891</a></p>\n\n<pre><code>Imports System.Runtime.InteropServices\n\nPublic Class Form2\n\n    Private Declare Sub keybd_event Lib "user32" ( _\n        ByVal bVk As Byte, _\n        ByVal bScan As Byte, _\n        ByVal dwFlags As Integer, _\n        ByVal dwExtraInfo As Integer _\n    )\n    Private Const VK_CAPITAL As Integer = &amp;H14\n    Private Const KEYEVENTF_EXTENDEDKEY As Integer = &amp;H1\n    Private Const KEYEVENTF_KEYUP As Integer = &amp;H2\n\n    Private Sub Button1_Click( _\n        ByVal sender As System.Object, _\n        ByVal e As System.EventArgs _\n    ) Handles Button1.Click\n\n        \' Toggle CapsLock\n\n        \' Simulate the Key Press\n        keybd_event(VK_CAPITAL, &amp;H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)\n\n        \' Simulate the Key Release\n        keybd_event(VK_CAPITAL, &amp;H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)\n    End Sub\n\nEnd Class \n</code></pre>\n'}, {'answer_id': 58942, 'author': 'Rob Rolnick', 'author_id': 4798, 'author_profile': 'https://Stackoverflow.com/users/4798', 'pm_score': 3, 'selected': False, 'text': '<p>Try <a href="http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/718c0860-ab1a-4a0a-98af-a101cdfecf4e/" rel="noreferrer">this</a>:</p>\n\n<pre><code>Public Class Form1\n    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)\n    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\n            Call keybd_event(System.Windows.Forms.Keys.CapsLock, &amp;H14, 1, 0)\n            Call keybd_event(System.Windows.Forms.Keys.CapsLock, &amp;H14, 3, 0)\n        End Sub\nEnd Class\n</code></pre>\n'}, {'answer_id': 33616002, 'author': 'Ben', 'author_id': 5543707, 'author_profile': 'https://Stackoverflow.com/users/5543707', 'pm_score': 0, 'selected': False, 'text': '<p>I use this</p>\n\n<pre><code>Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)\nPrivate Const KEYEVENTF_EXTENDEDKEY As Integer = &amp;H1\nPrivate Const KEYEVENTF_KEYUP As Integer = &amp;H2\n\'put this where you want to turn caps lock on or off\nkeybd_event(VK_NUMLOCK, &amp;H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)\nkeybd_event(VK_NUMLOCK, &amp;H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/58937', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/133/']