• Support
  • Articles
  • Resources
  • Products

Test for a string on the visible screen

Moderator: boris

2 postsPage 1 of 1


Joined: Wed Mar 09, 2011 7:59 am
by Vhati » Wed Mar 09, 2011 9:46 am
;   ANSI/VT100 allows regions to be partially typed-over (eg curses menus).
;   So wait commands watching the raw stream see the edits, not the revised lines.

I like to do sanity checks before sending keystrokes, so this was irritating. It's why I gave up writing an automated client in C. I nearly rigged RealTerm with AutoHotKey. :oops: Luckily TeraTerm provides terminal emulation and slightly-kludgy screencap on top of some other features that made my life easier. :D

; waitForScreen and strOnScreen
;   Waits for a short string, pauses half a second, flushes the
;   recv buffer, then scans the visible screen for a string in context.

With these subroutines, you can delay until a menu choice is available, stall a little to let painting settle down, and then confirm the choice is in a context you were expecting. For example, when I traverse menus on a ProCurve switch I've got, the names of choices in submenus are written over the earlier menu's names. But the numbers next to the choices are left on the screen from before. So I have to do a screen dump to check that the choice I want has the number I'm about to send.

This screen dump doesn't touch a file, and it handles a corner case when the string you're looking for is partly in one 255-char buffer and partly in another.

; isScreenBlank

The switch normally starts out blank and unresponsive except for pressing enter twice. So I know to abort if I send an arrow key and the screen's no longer blank.

Example waitForScreen Usage:

Example isScreenBlank Usage:

Joined: Wed Jul 18, 2012 1:59 pm
by LuannD » Wed Jul 18, 2012 2:03 pm
Thanks for the scripts and codes shared here)
I'm really interested in them and this info was right for me.
Glad to have found this forum today)
Display posts from previous:
Sort by:

2 postsPage 1 of 1

Users browsing this forum: No registered users