Thanks again Paul! I am moving forward.
I am trying to bring my Flash movie that is launched on a browser to
focus by synthesizing a 'tab' followed by 'enter' key press events. But
I get an error when I do this. Am I going the right way? Please find my
code below.
[DllImport("coredll.dll", SetLastError = true)]
public static extern void keybd_event(byte bVk, byte bScan, uint
dwFlags, uint dwExtraInfo);
const byte VK_TAB = 0x09;
const byte VK_RETURN = 0x0D;
const uint KEYEVENTF_KEYUP = 0x02;
webBrowser1.Navigate(first);
keybd_event(VK_TAB, 0, 0, 0);
Thread.Sleep(100);
keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
Thread.Sleep(100);
keybd_event(VK_RETURN, 0, 0, 0);
Thread.Sleep(100);
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
if (Marshal.GetLastWin32Error() != 0)
{
MessageBox.Show(Marshal.GetLastWin32Error().ToString());
}
I get an error code of -2147483643 which seems weird.
-Krupa
The right way to handle this is to install the C++ SDK for your target
device and look at the help page for the call. Once you see that, ah, I
need to pass KEYEVENTF_KEYUP, you can easily look that up in the header
files from the SDK and find the value.
Paul T.