How to send 'F1' key as ASCII character?

Another related question, what if I'm trying to send the key F1, which is a combination of several characters, i.e. Chr(27) & "O" & "P"?
teelingAsked:
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.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
from what I know, the function keys don't have ASCII correspondants ...
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if you want to "send" the key to the active window, then it would be:

SEND "{F1}"
0
teelingAuthor Commented:
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Guy Hengel [angelIII / a3]Billing EngineerCommented:
then, as I feared, the answer is: you cannot do that directly.
the only option is to have a coded string (like the Send function does), which needs to be interpreted ...
0
LeithauserCommented:
In VB (such as VB 6), use
SendKeys "{F1}"
to send F1 to the program and control that currently has the focus.
0
teelingAuthor Commented:
angellll: Can you show me roughly what you mean?

Lethauser: I am using VBA. Sending 'F1' does not work.
0
LeithauserCommented:
Sorry. There really should be a box to check or something on these questions that tells us what language people are using.
0
teelingAuthor Commented:
Not your fault. I should have clarified this at the beginning.
0
LeithauserCommented:
Believe me, you are not the first. I have lost count of how many times I have given a VB 6 solution to a question and then been told by the person that it does not work because they are using VBA or VB.net, or something else. I think that Experts-exchange should have some kind of check box on all programming questions so that people can (have to, in fact) specify which Visual Basic language they are using.
0
teelingAuthor Commented:
Anyone has got any idea how to solve this problem? Thanks.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
as I said: F1 key does not have an ASCII code.
so, you have to define some other ascii code combination to represent F1, aka the receiving side of the data stream has to look for this and say: this is F1 ...

for example:
sending "{F1}" is to be understood as "F1", while sending "{{}" shall be read on the receiving side as "{"

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
teelingAuthor Commented:
I found a way to get around this problem.data is obtained from the Excel sheet.

Function MySend(ByVal data As String)
'    DoEvents
    If LCase(data) = "chr(13)" Then data = Chr(13)
    
    If LCase(data) = "chr(27)" Then data = Chr(27)

    If LCase(data) = "chr(27)&o&p" Then
        wsTCP.SendData (Chr(27) & "O" & "P")
        Exit Function
    End If
    
    wsTCP.SendData data
    
End Function

Open in new window

0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
isn't that exactly what I suggested? ...
0
teelingAuthor Commented:
Yupe. Thanks for your suggestion.
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
Visual Basic Classic

From novice to tech pro — start learning today.