Hints, tips and tricks for newbies
Moderators: JRL, Dorian (MJT support)
-
TheEek
- Junior Coder
- Posts: 31
- Joined: Mon Jun 22, 2009 2:53 pm
Post
by TheEek » Wed Nov 11, 2009 1:28 pm
Hi,
Using Macro Scheduler pro 11.1.17, I'm trying to get text from a window of a SSH connection using PuTTY. When I was using 11.1.15 the output at best was inconsistant, (running the same script to get text from the same PuTTY window, produced different results). Now I'm on the new version, I only get the title bar as text, at least it's consistant now...
GetTextAtPoint does work, however, I need all the text in the window collected.
Anyone have any ideas?
Thanks.
(I know this next bit isn't really necessary - but just in case. I can give you an output if that will help:)
Code: Select all
GetTextReset
GetTextInRect>0,0,585,370,strText1
messagemodal>strText1 = %strText1%
GetTextReset
GetTextAtPoint>8,292,strText2,nCharPos
messagemodal>strText2 = %strText2%
GetTextReset
GetWindowText>Server - PuTTY,strText3
messagemodal>strText3 = %strText3%
GetTextReset
GetWindowTextEx>Server - PuTTY,strText4
messagemodal>strText4 = %strText4%
-
bnc1
- Pro Scripter
- Posts: 127
- Joined: Sun Jul 31, 2005 5:10 pm
Post
by bnc1 » Wed Nov 11, 2009 2:20 pm
I would think that GetWindowTextEx might be the best option. You can parse the output with the Separate command. GetTextatPoint only gets the text on one line and may not be what you want. The older GetWindowText may not get you anything useful. You have to experiment to find out. You mentioned some inconsistent results, what OS are you using ??

-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Wed Nov 11, 2009 2:22 pm
I'm running Putty so I just gave it a go and had no problems. Ran it several times and consistently retrieved text. I'm running 11.1.17 on Windows 7 x64 with Putty 0.60 which I believe is the latest.
Sometimes these functions are time critical and I have in some cases found I needed to put the function into a loop as the exact second I request the text the app is not able to return it - perhaps because it is too busy at the time and the textout functions are not "transmitting". So you might want to try this:
Code: Select all
Let>strText=
Repeat>strText
GetWindowTextEx>Server - PuTTY,strText
Until>strText<>
MessageModal>strText
If necessary you could build a timeout into this too.
-
TheEek
- Junior Coder
- Posts: 31
- Joined: Mon Jun 22, 2009 2:53 pm
Post
by TheEek » Wed Nov 11, 2009 3:28 pm
I'm running Windows XP. I have a Vista machine at home, I can try this on. But a small example of the inconsistencies. From the script Marcus supplied, sometimes I receive the message:
Line: 4 c not appropriate
- I'm hoping that may help, it doesn't stop the script from continuing. I've had to sanitise the output a little:
Server - PuTTY
Server - PuTTY
Using username "username".
username@Server's password:
Last login: Wed Nov 11 12:18:02 2009 from WindowsPC
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
Another output:
Server - PuTTY
Server - PuTTY
Using username "username".
However the favourite output is:
Server - PuTTY
Server - PuTTY
Perhaps it may help if I tell you want I am after. There may or may not be a specific instance of text within that window. I cannot use get text at point, as the text I am after may not be in the same place. I want to check to see if "Password incorrect" is displayed or not.
Using username "username".
username@Servers's password:
Last login: Wed Nov 11 15:15:42 2009 from WindowsPC
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
Authorized access for employees only
NOTICE - PROPRIETARY SYSTEM
MoTD etc...
[username@Server(tcsh):1] kinit
Password for
[email protected]:
kinit(v5): Password incorrect while getting initial credentials
[username@Servers(tcsh):2]
-
bnc1
- Pro Scripter
- Posts: 127
- Joined: Sun Jul 31, 2005 5:10 pm
Post
by bnc1 » Wed Nov 11, 2009 3:57 pm
The imbedded " " marks in the window text can cause problems for Macro Scheduler. If you insert a
StringReplace>strText,",*,strText
after the GetWindowTextEx the script should work. The reason I asked about the OS you are using is that I am getting "consistently inconsistent" results with some of these text commands (GetWindowTextEx and GetTextinRect) when using Windows 7. I get consistent results when using the same application, script, and version of Macro Scheduler on Vista
-
TheEek
- Junior Coder
- Posts: 31
- Joined: Mon Jun 22, 2009 2:53 pm
Post
by TheEek » Thu Nov 12, 2009 8:24 am
Sorry, that didn't work either. It does replace the quotation marks (as expected) but the rest of the window text isn't available. I'll see if I can get myself on the Windows 7 test group, and make some further tests.
If you're currently running Windows 7, can I ask you to test this using compatability mode please? That may produce the same errors (one can hope)...
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Thu Nov 12, 2009 8:56 am
That error is in the Until line. Try this variation instead:
Code: Select all
Let>strText=
Label>getText
GetWindowTextEx>Server - PuTTY,strText
If>strText=,getText
MessageModal>strText
The idea is to loop until text is received.
As stated before I'm running Windows 7 here and I haven't had any problems. Both the above and the code I sent earlier work great with the latest version of Putty. Works fine on my Windows 7 x64 desktop as well as my Notebook running Win 7 x86. So I'm not convinced this is an operating system issue.
-
TheEek
- Junior Coder
- Posts: 31
- Joined: Mon Jun 22, 2009 2:53 pm
Post
by TheEek » Thu Nov 12, 2009 9:49 am
Marcus, you are a genius. Before I posted this, I made sure I was using the lastest version of Macro Scheduler, and that my laptop was as up to date as corporate policy would allow, but I neglected to check PuTTY...
After upgrading to v0.60, it works. Many thanks for your help.