SendKeys.Send half working

D

David Thielen

J

Jie Wang [MSFT]

Hi David,

SendKeys is notoriously unstable and I personally don't recommend using it
at all. It not only has timing issues, but also behaves differently across
platforms.

If you want to do some UI Automation on Office applications, I would
suggest you use the Accessibility APIs instead of SendKeys.

But for a quick fix of your current SendKeys issue, you may try split the
keys into several Send calls, and add a short pause (like 100ms) between
each calls. That may get the keys being processed by Office better.

Please kindly let me know how it goes.

Thanks,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hi David,

SendKeys is notoriously unstable and I personally don't recommend using it
at all. It not only has timing issues, but also behaves differently across
platforms.

If you want to do some UI Automation on Office applications, I would
suggest you use the Accessibility APIs instead of SendKeys.

But for a quick fix of your current SendKeys issue, you may try split the
keys into several Send calls, and add a short pause (like 100ms) between
each calls. That may get the keys being processed by Office better.

Please kindly let me know how it goes.

Ok, will try that.

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jie Wang [MSFT]

Hi David,

Good to know it's getting better.

One more thing I think you need to notice (from MSDN doc -
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx):

*** Begin Quote ***

The SendKeys class has been updated for the .NET Framework 3.0 to enable
its use in applications that run on Windows Vista. The enhanced security of
Windows Vista (known as User Account Control or UAC) prevents the previous
implementation from working as expected.

The SendKeys class is susceptible to timing issues, which some developers
have had to work around. The updated implementation is still susceptible to
timing issues, but is slightly faster and may require changes to the
workarounds. The SendKeys class tries to use the previous implementation
first, and if that fails, uses the new implementation. As a result, the
SendKeys class may behave differently on different operating systems.
Additionally, when the SendKeys class uses the new implementation, the
SendWait method will not wait for messages to be processed when they are
sent to another process.

If your application relies on consistent behavior regardless of the
operating system, you can force the SendKeys class to use the new
implementation by adding the following application setting to your
app.config file.

<appSettings>

<add key="SendKeys" value="SendInput"/>

</appSettings>

To force the SendKeys class to use the previous implementation, use the
value "JournalHook" instead.

*** End Quote ***

So you can try swtiching the SendKeys settings and test different settings
across different Windows Versions, to find out which one works best for you.

Regards,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top