SendKeys.Send always uses the case set on the keyboard!

Hi,

I am successfully using SendKeys.Send to send strings to an application but when this is entered into the destination (third party) application the case will depend on what the current state of the CAPS LOCK key is on the keyboard and I need it to preserve the case I send it.

I know I can send CAPS LOCK and SHIFT via SendKeys but that will simply toggle the case which is of no use as I don't know what it will be in the first place - if you see what I mean?!

I need a way of either finding out what the current state of the CAPS LOCK key is or forcing the SendKeys method to use my exact string - including upper and lower case letters.

Using LOWERCASE / UPPERCASE type methods (as I have read elsewhere) obviously wont work as the important factor here seems to be physical CAPS LOCK key on the keyboard!

Any thoughts?

Thanks.

James.
JAMESAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bruintjeCommented:
Hello JAMES,

you could look at the blogentry dealing with this issue and solving it through a winapi call to getkeystate
source: http://blogs.msdn.com/michkap/archive/2006/03/29/562606.aspx

hope this helps a bit
bruintje
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SystemExpertCommented:

Hi,

textBox1.Focus();  

// Here something is intresting

// iF caps lock IS ON THEN IT WILL SEND 'a' AND IF OFF THEN IT WILL SEND 'A'

SendKeys.SendWait("A");
                  
// and check the ascii of the key and you will know whether CAPS LOCK is ON or OFF

Thanks
0
JAMESAuthor Commented:
Thanks System but the blog suggested by bruintje is fine for me.

Regards.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.