|
-
April 5th, 2009, 05:07 PM
#1
keyboard input problems
I amtrying to send ALT + 1 Key to the active application but the problem i am having is when i use SendKeys.SendWait("%1") the program ignores the alt key and jsut enters the 1. is there a way i can get this done?
Thanks
-
April 5th, 2009, 10:37 PM
#2
Re: keyboard input problems
Search for posts by TT(n). He has a few links in his signature that will help.
-
April 7th, 2009, 11:42 AM
#3
Re: keyboard input problems
I have tried his Send Keys method and it does not work either. I am using VB 2008 and the problem is with it's SendKeys.SendWait("%1") it sends the keys too fast and unfortunately the program ignores the alt key
-
April 7th, 2009, 04:21 PM
#4
Re: keyboard input problems
Try using a SLEEP command
-
April 7th, 2009, 06:21 PM
#5
Re: keyboard input problems
yea that doesnt work all that will do is slow down the time in between each keypress. which works fine for sending sentences and stuff but for this particular key combination that does not work.
-
April 7th, 2009, 07:06 PM
#6
Re: keyboard input problems
The SendWait method doesn't always wait as long as you might want it to.
It only waits for the key messages to be processed, not the processes that might be initialized by the key combo.
That's why my module also includes a function called WaitForWindow,
which will wait for any new window that may be initialized by a keyboard stroke.
There may be other reasons to wait, but this is probably the most common.
Automation usually continues, with keyboard focus on the new window.
I think you should be able to use the module for what you need, but if not then try MS Sendkeys inside parenthesis.
Code:
Windows.Forms.SendKeys.SendWait("%(1)")
What exactly are you waiting for, before moving onto what?
-
April 7th, 2009, 09:01 PM
#7
Re: keyboard input problems
it doesnt need to wait on anything SendKeys is just simply sending the keystrokes too fast so the program does not recognize them all. I have gotten around this issue for everything else i need to send by doing as below:
SendKeys.SendWait("H")
Sleep(1)
SendKeys.SendWait("e")
Sleep(1)
SendKeys.SendWait("l")
Sleep(1)
SendKeys.SendWait("l")
Sleep(1)
SendKeys.SendWait("o")
But for the ALT, CTRL, and Another Key Combo that method does not work since it has to be in the form
SendKeys.SendWait("%1")
So when it does that it ignores the alt and just inputs a one into the program. so this method
SendKeys.SendWait("%")
Sleep(1)
SendKeys.SendWait("1")
does not work because it needs to Hold the ALT Key While Pressing the 1 Key
I am stumped at this point.
-
April 7th, 2009, 11:45 PM
#8
Re: keyboard input problems
One site didn't let you use send keys at all, nor would it let you paste in words.
It did let us send keystrokes 15ms apart, though. There should be some validation keys that are valid that you are using...
-
April 8th, 2009, 12:19 AM
#9
Re: keyboard input problems
Is it a common program?
EDIT: What does the key combo(Alt + 1) do?
If you use my module, you can open it up, and change the KeyEvent function from Private to Public,
so that you can press the menu key down separately, then lift it.
Here is your key combo:
Code:
SendKeys.KeyEvent(Keys.Menu, True, False)
SendKeys.KeyEvent(Keys.D1)
SendKeys.KeyEvent(Keys.Menu, False, True)
I don't think you'll need any Sleeps, in here but you could try SendKeys.Sleep(), if that doesn't work.
Last edited by TT(n); April 8th, 2009 at 12:29 AM.
-
April 8th, 2009, 10:42 AM
#10
Re: keyboard input problems
Thanks so much that worked perfectly.
I had to do it as so
SendKeys.KeyEvent(Keys.Menu, True, False)
SendKeys.Sleep(50)
SendKeys.KeyEvent(Keys.D1)
SendKeys.Sleep(50)
SendKeys.KeyEvent(Keys.Menu, False, True)
Except there are a couple keys i noticed are not working for example. Subtract I assumed would do the - key but it did not and i cant find a key for =
Thanks
-
April 8th, 2009, 12:45 PM
#11
Re: keyboard input problems
Thanks so much that worked perfectly.
Except there are a couple keys i noticed are not working for example.
Subtract I assumed would do the - key but it did not and i cant find a key for =
The keys that don't work, are the ones that do not have a value 0-255.
For example Keys.Alt = 262144, and so the keyboard API will not recognize it.
However, just about all keys are represented by some value 0-255.
Use the function called Sendkeys.GetCommands, for all values.
Keys.OemMinus is the subtract key next to zero.
Keys.Oemplus is the add key next to zero, and OemMinus.
You have to press/hold shift down, while the OemPlus key is pressed, just like normal.
EDIT:
To get the = key, just press Keys.Oemplus
Last edited by TT(n); April 8th, 2009 at 12:50 PM.
-
April 8th, 2009, 01:45 PM
#12
Re: keyboard input problems
ok Thanks. I have sent you a PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|