Hi
I have a simple situation, and complicated for me problem.
I have an event that is raised if data receive to RS port.
This event calls few api functions
Here is the code:
case "Alt":
{
if (!isAltPressed)
{
keybd_event(18, 0, 0, UIntPtr.Zero);
isAltPressed = true;
notifyIcon1.ShowBalloonTip(1, "", "Alt is now
active", ToolTipIcon.Info);
System.Threading.Thread.Sleep(500);
break;
}
isAltPressed = false;
keybd_event(18, 0, 0x0002, UIntPtr.Zero);
notifyIcon1.ShowBalloonTip(1, "", "Alt is no more
active", ToolTipIcon.Info);
System.Threading.Thread.Sleep(500);
break;
}
case "Tab":
{
if (isAltPressed)
{
keybd_event(9, MapVirtualKey(9, 0), 0,
UIntPtr.Zero);
keybd_event(9, MapVirtualKey(9, 0), 0x0002,
UIntPtr.Zero);
}
break;
}
This code simulates pressing alt+tab.
And the problem is that in 1/5 of situations, when i try to deactivate ALT
key,alt+tab menu is still visible.
Algorithm is simple. Alt -> n-times TAB -> Alt again. Alt tab menu doesn't
wanish every time i do it this way.
I think that maybe it's threading problem or somthing of this kind.
For any help thanks.