SendKeys.SendWait

SendKeys.SendWait

am 01.10.2007 10:58:31 von boeffchen

Hello,

I am trying to send keys to a window using the method above, though I
am encountering timing issues, which msdn warned me of before.
The way I tried to fix it is polling if the window I want to send
keys
to is really the focus via:
while (GetForegroundWindow() != theHwndWeWant)
Thread.Sleep(0);
Thread.Sleep(0); // to give some extra time
SendKeys.SendWait("our keys");
SetForegroundWindow(the old one :p);
[... more stuff ...]


For windows vista the above code works fine for me. For Windows XP it
doesn't.
Does anyone have an idea of checks I could add to make sure
everything
is sent to the correct window?


Thanks in advance