Hey guys I'm really stuck in this very urgently needed solution, been working for 3 weeks plus and still can't come up with a working solution! Help needed asap.

ISSUE:
The problem is simple. I have 2 PCs. One is 'master', second is 'slave'. On 'master', I have my .NET software installed and on 'slave' a third party software, let's call it B. This 'slave' PC is hooked into a industry machine for inspection, and this software B is supposed to handle the mechanical movement of the units checked, while my .NET software is supposed to inspect the unit with the help of a camera mounted on the machine, and will give result PASS or FAIL. 'Master' and 'slave' PC are connected by serial port and I'm using RS232 null cable modem. The goal is simple, I need to send a keyboard F4 key signal from 'master' to 'slave' PC so that the software B will automatically 'click' F4 on it's PC after every inspection result of PASS to move to the next unit. If it's a FAIL, we supposed to enter the reject code (2 digit number) and this I got no problem sending as the function SerialPort.Write() I can use to send byte array of the ASCII characters of any numbers. But the problem comes when I need to send Function keys, say any of F1-F12. I'm aware that Function keys don't have ASCII equivalent of characters and can only be sent through keyboard scan codes, but I really don't know how to send scan code through SerialPort.Write as it only supports String, Byte array and Char array. I hope my explanation is clear here. Please help guys ! Thanks in advance!

Regards,
Limepebblez

Have a look at THIS link.

The coding will be something like -

Private Sub Form1_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles MyBase.KeyDown
If e.KeyCode = Keys.F2 Then
MsgBox("F2 pressed!")
End If
End Sub

You will then have something like -

MSComm1.output = chr$(26) 'Ctrl and Z in this case.

Have a look at THIS link.

The coding will be something like -

Private Sub Form1_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles MyBase.KeyDown
If e.KeyCode = Keys.F2 Then
MsgBox("F2 pressed!")
End If
End Sub

You will then have something like -

MSComm1.output = chr$(26) 'Ctrl and Z in this case.

-------


I appreciate your help but I guess there is just NO way to send function keys over serial port RS232 because they only support string, byte array and char array.
So what I had done to solve this problem is, to write a small software in the target PC which captures the string data that I send from the host PC, and use the SendKeys.Send() method to send the data to the keyboard. For eg: If I send the string F4 from the host PC, my target PC will read it as F4 and use that variable in the Sendkeys function to become SendKeys.Send("{F4}"). Of course I have handled some situations where I send ordinary characters like A,B,1,2, and so on. It's working properly now.

The only downside in this method is that we are forced to work with the target PC whereby we need to install a small software into that PC to read the data sent from the host PC and this makes the process inflexible, and I had no choice but to resort to this method because of time constraint of my project. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.