Need to know when the terminal window I'm running my scripts against returns a different value than the default. For example, in the first screen capture below, the terminal gives a COMMENTS: prompt and my script can just start entering data:
Select EQUIPMENT INV. ENTRY NUMBER: 40563
PHYSICAL INVENTORY DATE: APR 16,2020// 7/2/2020 (JUL 02, 2020)
COMMENTS:
1>new comment goes here
2>cr on a blank line exits this mode
3>
EDIT Option:
In this example, because there are already comments against this record, the terminal returns the prompt "EDIT Option" (and I then have to script editor commands):
Select EQUIPMENT INV. ENTRY NUMBER: 39772
PHYSICAL INVENTORY DATE: JUL 2,2020// 7/2/2020 (JUL 02, 2020)
COMMENTS:
1>old comment here
EDIT Option: i
Insert after line: 0
1>new comment here
2>^ to exit this mode
1 line(s) inserted....
EDIT Option:
How do I detect what text prompt is currently on the screen next to the cursor? A user would see it and know how to proceed. I could use GetTextAtPoint or GetTextinRect and try to predict the screen coordinates where the cursor is appearing, but that seems kludgy. I could screen scrape and try to find the prompt text in the bottom of the scrape - also kludgy. Appreciate any ideas. Thanks - KLM
Retrieving text from a terminal window
Moderators: Dorian (MJT support), JRL
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Retrieving text from a terminal window
I don't know if you could use the pipe " | " to pipe the terminal output to a file or the clipboard. I use this all the time but I don't know if your particular use case apply.
Re: Retrieving text from a terminal window
@ kmarlowe,
You could use the Screen OCR Wizard to get the text from the console window. You could then process the text info as you see fit. Screen OCR is easy to use because of the wizard that helps you create the command.
I used VLC with the console window and then grabbed the text from that window.
As far as where the cursur is, wouldn't the cursur be on the last line?
Good Luck,
PepsiHog
You could use the Screen OCR Wizard to get the text from the console window. You could then process the text info as you see fit. Screen OCR is easy to use because of the wizard that helps you create the command.
I used VLC with the console window and then grabbed the text from that window.
Code: Select all
//GetWindowList>wl
//mdl>%wl%
//C:\Program Files (x86)\VideoLAN\VLC\vlc.exe
OCRWindow>C:\Program Files (x86)\VideoLAN\VLC\vlc.exe,strText
mdl>%strText%
Good Luck,
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
Re: Retrieving text from a terminal window
Ok, Here's more on the last idea.
Use sendtext to send some "text" that there is no way would be there otherwise. Then use OCRWindow to get all the text. By processing the text, the sent text will tell what the prompt before it is.
Once you know the prompt you need to answer, you can use Press> to send the needed number of backspaces to remove the sent text.
Now you can proceed with answering the prompt.
PepsiHog
Use sendtext to send some "text" that there is no way would be there otherwise. Then use OCRWindow to get all the text. By processing the text, the sent text will tell what the prompt before it is.
Once you know the prompt you need to answer, you can use Press> to send the needed number of backspaces to remove the sent text.
Now you can proceed with answering the prompt.
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!