Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys <Esc> & <F1> not working VB6

Status
Not open for further replies.

ripps

Programmer
May 25, 2011
3
GB
Hi

I am writing some code that will automate a process used alot at my place of work, i dont want to get to much into the exact nature of it just in case but it basically gathers the required information into the VB program and then inserts it into a KEA 340 terminal.

I have most of the code running fine but at certain points I need to mimic the keyboard pressing the escape key or the F1 key.

According to the help files xxx.SendKeys "<Esc>" should work (or "<F1>" for the F1 key) but it doesnt.

I have used the <return> command with no problems at all but unfortunatley I cannot progress with out the Escape or F1 keys.

A sample of the code..

xxx.WaitForCursor 22, 29, 1
xxx.SendKeys Trim$(txtxxx.Text) & "<return>"
xxx.WaitForCursor 22, 37, 1
xxx.SendKeys Trim$(txtxxx.Text) & "<return>"
xxx.WaitForCursor 22, 19, 1
xxx.SendKeys Trim$(txtxxx.Text) & "<return>"
xxx.WaitForCursor 17, 20, 1
xxx.SendInput "<F1>" ' nothing happens, no errors but no progression

xxx is hiding any names that could give away the nature of program, im sure none of you care but I wouldnt want to get in trouble lol

I have tried many different variations including using the SendInput command but nothing has worked.

Any help much appretiated

Thanks
 
sorry to post again but I have just opened the on screen keyboard and pressed F1 and what should happen doesnt, it just displays "[11~" on the screen.

None of the F buttons on the on screen keyboard work the way they do on the physical keyboard

This may be a clue
 
You should open up the keyboard map and run the sendkeys in it rather than the key presses.
 
This might not be 100% clear. What I mean is use the keyboard map to determine the sendkeys. (e.g.; F1 = [11~, so set your code to write [11~ rather than use F1.)
 
Did you try recording a macro of key presses to find the key codes?

Also, don't know about KEA but on my system the "F" keys are prefixed with a "P"

SendKeys ("<PF8>")

and "Return" is

SendKeys ("<Enter>")
 
check your keyboard maps set up to ensure there
is a function for <F1> and if there isn't you
Can assign one.

Sess0.Screen.Sendkeys("<Ctrl+M>")
Which is an equivalent to <return>
 
Thanks for your replies.

The keyboard mapping just wouldn't work no matter what I did.

I solved this problem by creating a smart pad for escape and another for and then invoked then when needed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top