How to recognize a single char in a cmd window?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Igor
Newbie
Posts: 3
Joined: Wed Mar 31, 2004 5:32 pm

How to recognize a single char in a cmd window?

Post by Igor » Wed Mar 31, 2004 6:06 pm

Hi to everybody, this is my first post :D

I have done a Macro Scheduler script that:
1) opens a telnet session
2) makes some changes to a router settings
3) exits

OS: Windows XP

In the active telnet window that it opens, I need to recognize a single character.
The script changes a value from "Yes" to "No" by pressing the Space Bar, so I need to recognize if the current character (under the cursor) is 'Y' or 'N', a sort of "getChar()" as usual in C++ , BEFORE making any changes.

How to do this?
I use Macro Schedule 7.2.043

Lumumba

Post by Lumumba » Wed Mar 31, 2004 10:24 pm

Well I had to accomplish something similar.
I've enabled the Telnet Client to log the session.

During the session the script read that log (which is a plain text file) line by line and was able to identify such triggers as eg. that Y char.

Igor
Newbie
Posts: 3
Joined: Wed Mar 31, 2004 5:32 pm

Post by Igor » Wed Mar 31, 2004 11:12 pm

Lumumba wrote:Well I had to accomplish something similar.
I've enabled the Telnet Client to log the session.

During the session the script read that log (which is a plain text file) line by line and was able to identify such triggers as eg. that Y char.
thanks Lumumba.
Where is collocated the log?
on the telnet Client or on the host PC that has called the telnet?
The idea seems god, but the log file must be avalaible for ALL the lan computers, so they can control it everytime they run the script for changing (or not) the value.

So, no "getChar()" command for Macro Scheduler? It would be better... :roll:

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Mar 31, 2004 11:41 pm

Any chance of using WaitRectChanged?

From the Help file:
WaitRectChanged>TLX,TLY,BRX,BRY,Timeout

This command causes Macro Scheduler to wait until the image bound by the specified pixel coordinates changes. If it doesn't change within the number of seconds specified in Timeout, the command stops waiting and the variable WRC_RESULT is set to FALSE. WRC_RESULT is TRUE if the command terminated because the image changed within the specified time. if Timeout is set to 0, the command will wait indefinitely.
You already have the mouse in the area, and I suspect that this could be a small rectangle to be monitored, so it may process quickly enough. Or, if you can be more specific, you could also consider using WaitPixelColor.

From the Help file:
WaitPixelColor>ColorCode,X,Y,Timeout

This command causes Macro Scheduler to wait until the pixel colour at the specified pixel coordinates changes to the colour specified in ColorCode. If it doesn't change to that colour within the number of seconds specified in Timout, the command stops waiting and the variable WPC_RESULT is set to FALSE. WPC_RESULT is TRUE if the command terminated because the colour changed to the specified colour within the specified time. if Timeout is set to 0, the command will wait indefinitely.
You could determine if value is Y or N by looking at the color of a specific pixel that is different for each of them.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Lumumba

Post by Lumumba » Thu Apr 01, 2004 7:13 am

OK, WPC> + WRC> would have been my second choice :wink:
Well, I seem to remember the logging is clientside (and btw. its the GUI telnet, cause the cmdline won't provide that option, isn't it ?).

Have you checked if that command will be able to detect the text within the box?

-----

FindWindowWithText>text_to_find,setfocus_flag,result_variable

Label>Loop
FindWindowWithText>Y,1,WindowName
Wait>2
If>WindowNameMyTelnetWindowTitle, Loop

Lumumba

Post by Lumumba » Sat Apr 03, 2004 7:56 am

I found this, which should work with Macro Scheduler
WordGrab 1.4 Quick Guide
Copies Words From DOS Screen to Command Line
Copyright (c) 1995-1996 by David M. Wincelberg


Overview

WordGrab provides mouse-based copy and paste for the DOS screen.
In other words, with this program installed you will be able to
use your mouse to copy a filename or other text on the screen to
the command line. If you select a filename that is on the left
margin of a directory listing, WordGrab will paste it in the DOS-
usable form: FILENAME.EXT. For DOS 7.0, which comes with Windows
95, a long filename can be used at the command line if you
enclose it in double-quote marks.

Uses for WordGrab include selecting two files to compare,
renaming files, running a program, and choosing a file to edit or
word-process without using the file-open menu item. This program
would be especially helpful to slow or inaccurate typists. A
custom hotkey can be specified in the initialization file
WRDGRB.INI.

To use this program, copy the files in WRDGRB.ZIP to a
single directory. Type WRDGRB and press . Then, when
there is a filename or other text on the screen that you wish to
copy to the command line, press --W (hold down
the first two keys, tap W, and then release all three keys.)

Next, use the mouse cursor to highlight text on the screen
by positioning it over the leftmost character you want to copy,
holding down the left mouse button, and moving the mouse to the
right one space past the word or other text. You may also double
left-click on a word to highlight it quickly. Double clicking on
a basename in a directory listing will highlight the entire
filename. (Basename is the part of a filename before the
optional dot and extension.) Then release the button and click
the left mouse button to paste the text or click the right mouse
button to cancel the selection. If you double click either
button, the cursor will reappear after the program performs the
desired action. See the table below. You may type characters
before and after highlighting, even if you have not clicked a
mouse button.

Lumumba

Post by Lumumba » Wed Apr 07, 2004 11:37 am

Console Telnet for Win32 v2.0

Console telnet is a full screen (console) telnet client for MS Win32 environments. It can be run in full screen text mode (a DOS session) or in a graphic window. It supports ANSI colors, and has (almost) all the keys customizable. The latest version gets a score of 91 on vttest, which means you shouldn't experience any terminal emulation problems unless you're running a really weird application (compare: Windows 2000 Telnet gets a score of 39). You can also redirect the telnet session to STDIN and STDOUT for use with other programs. Telnet will communicate the number of lines and line width to the host, and can operate in any console mode.



Download (17k bytes)

Lumumba

Post by Lumumba » Wed Apr 07, 2004 11:39 am

Ooops,
173k bytes. :wink:

Igor
Newbie
Posts: 3
Joined: Wed Mar 31, 2004 5:32 pm

Post by Igor » Wed Apr 07, 2004 6:47 pm

Thanks Lumumba, nice job!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts