• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

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.
0
JAMES
Asked:
JAMES
1 Solution
 
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
 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now