Jump to content

issue in a script with loop


Recommended Posts

Hello guys

I have created an au3 script which makes a telnet session and executes some commands every 20 seconds. The problem is, if during the execution of this script, I'm opening for example Notepad, when the delay (of 20 secs) occurs, it will write the commands in this active window - Notepad. How can I avoid this ? I mean which function or code shall I use in order to make the commands from the script to be only effective in the telnet window no matter if meanwhile I'm having another active window.

Thank you for your answer.

Link to comment
Share on other sites

Hello guys

I have created an au3 script which makes a telnet session and executes some commands every 20 seconds. The problem is, if during the execution of this script, I'm opening for example Notepad, when the delay (of 20 secs) occurs, it will write the commands in this active window - Notepad. How can I avoid this ? I mean which function or code shall I use in order to make the commands from the script to be only effective in the telnet window no matter if meanwhile I'm having another active window.

Thank you for your answer.

WinActivate("The name of your window")

WinWaitActive("Same as above")

This activates your telnet window, waits a few miliseconds until it's active and then do continue to the next part of your script. :)

Link to comment
Share on other sites

But with ControlSend() you cannot send keys, only strings. I need to send keys in my telnet window.

Controlsend() works like Send() so yes you can send keys.. just look in the help file under send() and you will see how to do it.

here is an example:

Run("notepad.exe")
Sleep(5000)
Send("F5"); send as a string
Send("{ENTER}"); send the key Enter
Send("{F5}"); send as the key F5

Regards

Edited by newbiescripter
Link to comment
Share on other sites

Run telnet and use StdinWrite() and StdoutRead() to send /receive text from it. Look at the examples for either function to see how to hook up STDIO from run to these functions.

Or as someone else mentioned try using the TCP functions directly.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...