Sign in to follow this  
Followers 0
NATO

TCPSend and Function keys (F1 through F12)

6 posts in this topic

Hi there,

I'm scripting an automated telnet session using TCPSend/TCPRecv. It's working beautifully enough for me to step through screens in the session, verify I'm at the screen I want to be at, etc. However, I'm running into a wall when I try to send an F key via TCPSend.

I tried using the hex code (77) generated by this script, which will output the hex code for any key pressed to the SciTE console:

#include <Misc.au3>

While 1
    Sleep(50)
    For $i = 1 To 255
       If _IsPressed(Hex($i, 2)) Then ConsoleWrite(Hex($i,2) & @LF)
   Next
WEnd

But no luck. The F8 key never gets pressed.

Here's an excerpt of the script I'm working on, including my attempt at using the hex code from above--

...lots of other code...

;trying to send the 'F8' key here--
TCPSend($MainSocket, "0x77")
sleep(500)

$Data = TCPRecv($MainSocket, $MaxLength)
If $Data = "" Then
    MsgBox(0, "Error", $Data)
EndIf

While 1
    If StringInStr($Data,"success in pressing F8") Then ExitLoop
    $Data = TCPRecv($MainSocket, $MaxLength)
WEnd

...lots more code...

Any help will be greatly appreciated!

Thanks in advance. :)

Share this post


Link to post
Share on other sites



No thoughts, guys?? These F-keys are killing me!

Share this post


Link to post
Share on other sites

Well, still no luck. I guess the TCPSend command just can't send non-printable keys.

I guess I'll just look into scripting my project using PuTTY or something instead.

Share this post


Link to post
Share on other sites

Well, still no luck. I guess the TCPSend command just can't send non-printable keys.

I guess I'll just look into scripting my project using PuTTY or something instead.

hi, try:

TCPSend ($connectedsocket,Binary (0x1b4f50)); send F1
TCPSend ($connectedsocket,Binary (0x1b4f51)); send F2
TCPSend ($connectedsocket,Binary (0x1b4f52)); send F3
TCPSend ($connectedsocket,Binary (0x1b4f53)); send F4

Share this post


Link to post
Share on other sites

hi, try:

TCPSend ($connectedsocket,Binary (0x1b4f50)); send F1
TCPSend ($connectedsocket,Binary (0x1b4f51)); send F2
TCPSend ($connectedsocket,Binary (0x1b4f52)); send F3
TCPSend ($connectedsocket,Binary (0x1b4f53)); send F4

Unfortunately, it didn't work. Growl! Thanks for the suggestion, though!

Share this post


Link to post
Share on other sites

hi, try:

TCPSend ($connectedsocket,Binary (0x1b4f50)); send F1
TCPSend ($connectedsocket,Binary (0x1b4f51)); send F2
TCPSend ($connectedsocket,Binary (0x1b4f52)); send F3
TCPSend ($connectedsocket,Binary (0x1b4f53)); send F4

Ha! Got it! You were very close, but it turns out that I needed to use this:

TCPSend ($connectedsocket,Binary("0x154f51"))

Just needed to add some quotes around my expression.

Thanks, guys!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0