473,785 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendKeys.SendWa it

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 (GetForegroundW indow() != theHwndWeWant)
Thread.Sleep(0) ;
Thread.Sleep(0) ; // to give some extra time
SendKeys.SendWa it("our keys");
SetForegroundWi ndow(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 7705
Hi,

at work we had a similar problem, only we had to programmaticall y
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*******@googl email.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 (GetForegroundW indow() != theHwndWeWant)
Thread.Sleep(0) ;
Thread.Sleep(0) ; // to give some extra time
SendKeys.SendWa it("our keys");
SetForegroundWi ndow(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
1619
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 all the keys are sent at one time without waiting. I've used the process.WaitForInputIdle method in conjunction with sendwait and it does the same thing. Example: Dim test As Process = System.Diagnostics.Process.Start("test.exe") 'log in...
1
7720
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 sendkeys. I hate using SendKeys, but I am forced to use them. Anyway, I have written a function that will unprotect the VBA code in the current work book. It works about 60% of the time. For some reason it gets out of sync and the SendKeys don't...
1
2178
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 RTF but it treats the formatting information as standard text and displays it as normal. How do I tell word that I am sending RTF instead of regular text with SendKeys? Is it even possible to send RTF to word without cutting and pasting? Thanks...
2
11601
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 morning. I am trying to write an .exe file that is essentially a script. It will open an application, send it some commands via the keyboard, then wait for the results and close the application.
0
1534
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 for loop is able to generate the filenames.
0
1408
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
3324
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 the Control does prevent the Beep, but
1
2243
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 - System.Security.SecurityException: Hook cannot be created. Is there a way to workaround this problem? I'm logged-in as the system administrator.
5
13052
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 textbox keypress event. I got the following error msg: {"SendKeys cannot run inside this application because the application is not handling Windows messages. Either change the application to handle messages, or use the SendKeys.SendWait...
0
1583
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 execute this application like. To run that application some shorcut key is there SendKeys.SendWait("(%)rs"); SendKeys.SendWait("{DOWN}"); SendKeys.SendWait("{TAB}"); SendKeys.SendWait("{ENTER}");
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.