add the namespace
using System.Runtime.InteropServices;
include in your class
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);
then in textbox enter event
private void textBox1_Enter_1(object sender, EventArgs e) { if (Control.IsKeyLocked(Keys.CapsLock)) // Checks Capslock is on { const int KEYEVENTF_EXTENDEDKEY = 0x1; const int KEYEVENTF_KEYUP = 0x2; keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0); keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0); } } you can use this in keyup or keydown alos
Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator