 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
planetthoughtful
Joined: 22 Feb 2006 Posts: 23
|
Posted: Wed Feb 22, 2006 12:41 pm Post subject: Automate a terminal application? |
|
|
Hi All,
Just wondering if anyone can tell me if AutoHotkey is capable of automating a terminal application?
Basically, where I work we have several mainframe apps that we access via text-based terminal software. To automate, I need to be able to send keystrokes, and I need to be able to detect when the next screen has finished loading, so that I can pull data off it, determine what the next step(s) should be, send more keystrokes, detect when the screen has loaded, and so on and so on.
Can AutoHotkey achieve this? If so, any practical examples would be very appreciated!
Much warmth,
planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org
"Urban legends, superstitions, ghost
stories and folklore"
http://www.ulblog.org |
|
| Back to top |
|
 |
robiandi Guest
|
Posted: Wed Feb 22, 2006 12:58 pm Post subject: |
|
|
- use PuTTY
- PuTTY Configuration Log file name: logfile
- send your keystrokes to the terminal
- check the output in logfile (i.e. the script checks it)
- dependent on it the next send to the terminal
...
I am building such a script where I for example intend to use sqlplus
in a terminal |
|
| Back to top |
|
 |
planetthoughtful
Joined: 22 Feb 2006 Posts: 23
|
Posted: Wed Feb 22, 2006 1:09 pm Post subject: |
|
|
Unfortunately, I don't get a choice as to the terminal app. I work in a very large company and they have their own terminal software, developed in-house. I don't think you can log screens to a file, but I'll take a look. Failing that, is it worth suggesting a future feature for AutoHotkey that it be able to search for text in the current app in a loop and exit once the search string has been encountered?
Much warmth,
planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org
"Urban legends, superstitions, ghost
stories and folklore"
http://www.ulblog.org |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Feb 22, 2006 1:20 pm Post subject: |
|
|
a) I don't know anything about putty
lets assume the connection could be managed using PsExec ... at the host there has/have to be a/several script(s) AHK which could be triggered via a respond.
| Code: | Run, psexec ...
If whatever response log/file/...
Run psexec ... | Nonsense?
| Quote: | | is it worth suggesting a future feature for AutoHotkey that it be able to search for text in the current app in a loop and exit once the search string has been encountered | Have you already checked any AHK command which contains the word get ? ControlGet..., WinGet, ... and there are others which delivers a status too eg. Process |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Feb 22, 2006 1:49 pm Post subject: |
|
|
Without knowing how your terminal app. is made, it is hard to provide hints.
If the application just draw strings on its area, AHK will not be able to search the text.
Note that you can still use ImageSearch if you search for a drawn text always in the same area.
If you have some technical data on the application, perhaps you can do finer automation. It would be best if it reacts to some messages (see SendMessage).
If the application uses some kind of standard Windows component, like [Rich]Edit, then AHK is fully able to automate it.
PS.: to show screenshots, you have to store the image(s) in a Web server. Some sites like ImageShack allows you to store images like that. I saw one user of this forum used PicTiger too. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
planetthoughtful
Joined: 22 Feb 2006 Posts: 23
|
Posted: Wed Feb 22, 2006 2:30 pm Post subject: |
|
|
| PhiLho wrote: | Without knowing how your terminal app. is made, it is hard to provide hints.
If the application just draw strings on its area, AHK will not be able to search the text.
Note that you can still use ImageSearch if you search for a drawn text always in the same area. |
Apologies, I'm not sure what you mean by "draws strings on its area". It's a text terminal - I can use my mouse to highlight text and copy it to the clipboard. It's not an 'image', as I understand the word to mean.
In operation, it's much like telnet - it's just that, as I said, it's been developed in-house, and doesn't offer a lot of ability to automatically save screen content to log files etc.
That's why it would be very useful if AutoHotkey could monitor the stream of text being sent to the application, since every screen has a predictable series of characters that indicate the screen has finished loading. If I could detect when those characters have appeared, I could then continue executing a script to react to that screen, and the next, etc etc.
In practice, it's very much like a series of web forms.
So, form1 has fields you fill in, then you click on submit, your data goes back to the host, and the host sends down the next form. Once form2 has finished loading, you fill it in, click on submit. There's no point attempting to fill in form2 before it's finished loading, so in the same way, with the terminal application I'm talking about above, I need some way to determine that a screen has finished loading, so I can manipulate fields etc on it, then submit, and so on.
Much warmth,
planetthoughtful
---
"Lost in thought"
http://www.planetthoughtful.org
"Urban legends, superstitions, ghost
stories and folklore"
http://www.ulblog.org |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Feb 22, 2006 3:37 pm Post subject: |
|
|
| Quote: | | In operation, it's much like telnet | ... where you would be able to track the processing via an real-time-created log file. So if you/a script will check that log for explicit indicators you/it could respond if found. Correct? |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Feb 22, 2006 4:03 pm Post subject: |
|
|
If you look at a Notepad window with AHK's Window Spy, under the
>>>>( TitleMatchMode=slow Visible Text )<<<<
title, you will see the content of Notepad.
If you do the same with SciTE, a text editor using the Scintilla source code editing component, you will not see the content of the window.
That's because Scintilla is made from the ground up, it draws text in its area. It looks like, say, RichEdit, because it has been made to react like it, allowing selecting with mouse, reacting to clipboard commands, etc. It even react politely to the most common messages of the Edit and RichEdit controls, to be nice to AHK (initially AutoIt ) or text readers for the blinds.
| Code: | EM_GETSEL = 0xB0
SendMessage EM_GETSEL, 0, 0, Scintilla1, A
start := ErrorLevel & 0xFFFF
end := (ErrorLevel - start) >> 16
MsgBox %ErrorLevel% - %start% / %end%
|
Side note for Chris: I tried to put start, end or &start, &end in place of wParam, lParam, but it doesn't work. Did I made an error or is that a limitation of SendMessage?
In this case, we cannot use EM_GETSELTEXT...
So, we have here a custom component that look and feel like a standard Windows component, but that may react differently. Such component, if it doesn't support standard Windows messages, can be hard to automate.
Note that Scintilla has its own set of messages, that you can use to fully control it... It can even be integrated to a AHK GUI (I didn't tried...)
A program like PuTTY (telnet application) does the same: you can see nothing with Window Spy.
The fact that you can select text and copy it is already nice.
Perhaps you can examine it with Window Spy (AU3_Spy.exe), capture the output and paste it here. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
oleg Guest
|
Posted: Fri Apr 20, 2007 11:04 am Post subject: terminal find |
|
|
Hi there,
one thing that crossed my mind, reading your post :
it looks like your terminal window is very limited in terms of interaction with the host machine. I got a similar case in the past with a mainframe, and the way I did it was to :
- since the position of characters are always the same on the screen, you can perhpas select the text with your mouse : clik on top left of the field where you think the text will come, drag until the bottom right, release.
- Now this zone is highlighted, you should be able to copy it (simple Ctrl + C) : it's now visible by your host machine, in the clipboard
- now play with the string in the clipboard
I'd recommend something like :
every few seconds, click-drag-click copy, save clipboard in a variable (is you want), and check if the variable content is the one you want. Create a function for that, that you'll call with one line in your main script, or reuse in other scripts : GrabFromMF(topX,topY,bottomX,bottomY,everyNseconds,expectedstring)
hope this helps,
cheers,
Oleg |
|
| Back to top |
|
 |
edburdo
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri Apr 20, 2007 12:47 pm Post subject: |
|
|
And remember... you can set the speed for most of the mouse commands. So if you don't want the user seeing slow mouse movements, try setting the speed to 0. _________________ ~ Eric D. Burdo |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|