Jump to content

Need help reading a emulator


Recommended Posts

How can I read a window for the following class?

ClassNN: AfxFrameOrView421

It is a Telnet Connection. What I want to do is be able to read where the cursor (Caret) is correctly. If I could pull text off that would be better.

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

If it is a Dos Type window maybe a screen scrape would work.You could also try OCR but it won't be pretty and very time consuming to write.

P.S. also if you haven't tried ControlGetText() or WinGetText () then give them a try.

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

if window spy doesn't show the text in the control,then you may wish to try a different terminal emulator. perhaps someone knows of one w/ standard windows controls ameneable to au3 handling - I haven't had the need to look / test.

Other options that come to mind are screen copy / paste as mentioned by a previous poster, if you have money to throw at something screenOCR does a credible job

A different tactic that I have used to great effect is to base my automation on the terminal session logfile, parsing the text out of the logs, rather than the screen.

Of course, w/ the beta and the TCP functions, you could write your own from the RFCs up. Hmmm. Now that would be a great learning exercise for one of the script kiddies anxious to cut their teeth and show off their skillz... that would have real-world usefullness -- a "pure au3" RFC 854 implementation. It's a very straightforward, wellthought out and ubiquitous protocol --easier to handle and get working right than a ftp implementation.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

How can I read a window for the following class?

ClassNN: AfxFrameOrView421

It is a Telnet Connection. What I want to do is be able to read where the cursor (Caret) is correctly. If I could pull text off that would be better.

<{POST_SNAPBACK}>

I've experienced same problem as you Strate, I use a telnet session to connect to an MVbase server via an emulator (MVbase Virtual Terminal) which has a similar control class to yours. But the displayed text cannot be read with control read or anything else i've tried.

WinGetCaretPos() returns Co-ords in an array of the sessions Cursor Position ok, but i assume u actually want lines down and lines across, to acertain which field you are within.

Only work around ive managed is to send 'S' to select all & 'C' to copy to clipboard, and process the captured text for keywords using string commands. But that scope is limited.

Like someone else just suggested maybe an alternative emulator may be required.

Sorry I can't help with anymore than you already know. :)

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

I've used the STD I/O functions and Console Telnet for things like this and it worked really well.

Console Telnet is made so that the console can be redirected, but you have to set the TELNET_REDIR environment variable to 1 before you Run the Console Telnet EXE...

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

How can I read a window for the following class?

ClassNN: AfxFrameOrView421

It is a Telnet Connection. What I want to do is be able to read where the cursor (Caret) is correctly. If I could pull text off that would be better.

<{POST_SNAPBACK}>

we use a similar program at my work for collections. one thing that i've noticed with alot of telnet emulators is they most often have a status bar which shows the cursor position. i've made alot of scripts that use the cursor position to determine where the emulator is, and wait until the cursor is where i need it to be before continuing. as far as getting information to and from the emulator, most allow a copy and past with hotkeys or mouse clicks. i prefer to use mouse copy and paste for automation because you can very quickly see if you're copying from the wrong location. here is a little script i made to check amounts posted to a list of accounts in our telnet system. it won't be executable for you of course since you're not using same system etc, but i added alot of documentation for each step of the process so you can see the concepts at work...

;************************************************************************************

;this is a script to check the amount of money posted to each account from a list

;************************************************************************************

$input = fileopen("c:\accts.txt",0) ;input file defined

filedelete("c:\paid.txt") ;old output file is deleted if it exists

$old = ""

while 1

if @error = -1 or @error = 1 then ;if error was generated by file opening, no reason to continue

exitloop

endif

$acct = filereadline($input) ;one account number per line in list

if $acct = $old then ;this is a little check i threw in incase eof is not read properly

exitloop

endif

winactivate("DynaComm") ;emulator activated

$st = statusbargettext("DynaComm","",4) ;cursor position

;************************************************************************************

;select statement determines what to do based on cursor position

;************************************************************************************

select

case $st = "24, 23" ;cursor is where i want it

send($acct & "{ENTER}")

sleep(1000)

case $st = "24, 1" ;cursor is at loading position

sleep(1500)

send($acct & "{ENTER}")

sleep(1000)

case else ;cursor is anywhere else

fileclose($input)

msgbox(0,"error","dcs not ready to receive acct num" & @crlf & "acct: " & $acct)

exit

endselect

;************************************************************************************

;this copies the account number that is currently displayed in the emulator

;and assigns it to a variable from the clipboard

;************************************************************************************

mouseclickdrag("LEFT",100,457,174,457,1)

mouseclick("RIGHT",174,457)

mouseclick("LEFT",190,465)

$LAST = CLIPGET()

IF $LAST = $acct then ;makes sure that the account that is displayed is the one i want the info for

;************************************************************************************

;this copies the amount paid on the account and assigns to variable from clipboard

;************************************************************************************

mouseclickdrag("LEFT",859,381,953,381,1)

mouseclick("RIGHT",953,381)

mouseclick("LEFT",937,389)

$paid = CLIPGET()

;************************************************************************************

;this opens the output file and adds the account number and paid amount seperated by

;a comma for easy input into excel as comma seperated value text file

;i could have added code to parse the paid amount to remove any leading spaces, but

;elected to handle that in the spreadsheet

;************************************************************************************

$out = fileopen("c:\paid.txt",1)

filewriteline($out,$acct & "," & $paid)

fileclose($out)

endif

$st = statusbargettext("DynaComm","",4)

;************************************************************************************

;this select statement determines how to get back to the account lookup prompt based

;on cursor position, because a variety of information boxes could pop up that would

;have to be acknowledged before return commands would be effective

;************************************************************************************

select

case $st = "22, 12"

send("/{enter}")

case $st = "24, 66"

send("{ENTER}")

case $st = "24, 1"

sleep(1500)

case $st = "24, 23"

$old = $last

send("{ENTER}")

case $st = "15, 1"

send("{ENTER}/{ENTER}{ENTER}")

case $st = "16, 1"

send("{ENTER}/{ENTER}{ENTER}")

case $st = "24, 69"

send("C{ENTER}/{ENTER}{ENTER}")

case $st = "24, 63"

send("N{ENTER}N{ENTER}{ENTER}")

case else ;****if i encounter something i didn't expect

;****for cursor position, i have it output it

;****with a message box and stop execution

;****so i can adjust code accordingly

fileclose($input)

msgbox(0,"error","unexpected status bar text" & @crlf & "''" & $st & "''" & @crlf & "acct: " & $acct)

exit

endselect

$acct = ""

sleep(1000)

wend

msgbox(0,"done","done") ;****so i know when it's finished successfully

fileclose($input) ;****have to close the inputfile to avoid access

;****errors

Link to comment
Share on other sites

  • 2 years later...

What I'm using for Telnet and COM1 connections is Tera Term (freeware).

Its window cannot be read (nothing new here) but it can use something like Telnet's log ability with a big difference:

Telnet's log doesn't display the last line (usually the most significant line because it is the prompt line - e.g. if it displays "user" you have to send "admin" or if it displays "password" you have to send it ...) while Tera Term does and this is great because you can write all sorts of automation scripts without using copy-screen methods but only reading a text file.

I wrote a big script for automating firmware updates and configuration of network switches and this method never failed.

I've been thinking to make an UDF because many users could find a good use of but (because of using Tera Term) this condition is kinda restrictive (one cannot force another to use a particular software) ... so I decided no to. Maybe, if someone will be interrested in ... I will try to make an UDF.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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...