Sign in to follow this  
Followers 0
mentosan

issue in a script with loop

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



ControlSend()

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

ControlSend works in a similar way to Send but it can send key strokes directly to a window/control, rather than just to the active window.

Share this post


Link to post
Share on other sites

What about using the TCP-commands instead of telnet? That way you don't need to rely on external applications and you will be able to leave it running while using the computer.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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.

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