473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SendKeys.SendWait

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

Oct 1 '07 #1
1 7610
Hi,

at work we had a similar problem, only we had to programmatically
activate the target window. This involved a whole bunch of code, as
Windows 2000 and XP don't always act as you'd expect.

Basically we called ActivateWindow and related API in a loop and checked
for the foreground window handle like you do. What happens if you don't
use Thread.Sleep(0) but Thread.Sleep(10) for example?

Regards
Thorsten

bo*******@googlemail.com schrieb:
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
Oct 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: AaronB | last post by:
I've been using the sendkeys.sendwait method in my application to right to another. This works great on some of the systems we have but we have a couple newer Dell laptops that it seems that the...
1
by: Bryan | last post by:
I am writing a C# Windows App that updates out Excel reports' modules. The app is complete, but has a problem. The only way MS allows you to unprotect the VBA code in Excel is to do it by hand or...
1
by: Logan McKinley | last post by:
I have an application that uses SendKeys.SendWait(...) to send RTF (formatting and all) to a word. I was hoping it would parse the formatting, therefore retaining the original formatting of the...
2
by: David Kanter | last post by:
Hi, I am relatively inexperienced with VB.Net, but I am familiar with many concepts from programming; I have some basic level of competence with C/C++ and Perl, but I just started using VB this...
0
by: Austin | last post by:
Hello: I have written a very simple vb program (using the new .net interface). I have a website to which I must upload many files. The filenames are incremented in such a way that a simple...
0
by: a.theil | last post by:
Hello! First, I´m greenhorn to vb.net. I do - proIDKernel = Shell(txtKommandozeile, vbMinimizedFocus) AppActivate(proIDKernel) SendKeys.SendWait(strK) SendKeys.SendWait("{ENTER}")
6
by: Michael Maes | last post by:
Hello, I'm invoking successive SendKeys.SendWait("{BACKSPACE}") SendKeys.SendWait("{DELETE}") in a loop. The issue is that it causes a Beep on every Pass. Setting the 'Handled = True' on...
1
by: Glenn Palomar | last post by:
Hi, I have a beta Vista system and I'm running a program (created in VB.net) that sends keystroke to an application using System.Windows.Forms.SendKeys.SendWait. In Vista it throws an exception...
5
by: =?Utf-8?B?U3JpbWFu?= | last post by:
Hi, We are launching .net window from vb6 form. In .net form tabbing(tab out from one control to another control) was not working. for that i have written a code like Sendkeys.send("{TAB}") in the...
0
by: jairathore | last post by:
Hi, I m working on a project on which my requirment is like that remotely i control another application by using sendkey.sendwait method, i m sending some keystroke to that application and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.