 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Nemroth Guest
|
Posted: Mon Jun 21, 2004 11:23 pm Post subject: GetMessage |
|
|
As there are the PostMessage and SendMessage commands, is it possible to have a GetMessage command to listen to certain messages sent to a window or control ?
I'd like to be able, for example, to see witch characters are sent by network to the edit window of a program and to take a decision in fonction of the characters that are received by the control.
This command should be less "dangerous", too, than the two primer ones... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Tue Jun 22, 2004 12:21 am Post subject: |
|
|
I don't think you can listen to the messages sent to another app without a system-wide hook -- and for the moment, that type of hook is probably outside the scope of what AHK is envisioned to do.
If you gave an example of something you are trying to automate, some of us here might be able to suggest an existing method to achieve it. |
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Tue Jun 22, 2004 8:45 pm Post subject: |
|
|
Yes it is possible that this must be done with a system-wide hook...
I will explain why I like to have such a command.
At my work I have an Attachmate EXTRA! prog, witch is an emulation of an IBM 390 (?) terminal of a mainframe, on witch CICS (using a DB2 database) is implemented.
All the work is done by entering commands on a command line whitch is in a window witch seems to be almost an edit window.
I tried, to automate certain tasks, to have a name or an ID of the window on witch the different screens are diplayed. The screens are like edit windows but have parts in witch you can enter characters and a command line, and other parts which are used only to display textual information but that are not editable.
With Window Spy I try to have a name for this control but I get a strange name (I don't remember exactly but something like "gs400:00954:4562") and when I used it with the WinGetText command, there was no return, I did'nt got the text displayed in the window.
I tried with MouseGetPos to obtain the ID of the window placing the mice over it. I obtained an ID but when I tried to display the contents of the control who owns this ID, I got the text of the status bar !!!
The only way I have to get the text of the window is to do a "select all" and then copy the screen.
It works well but it is tiring for the eyes and not very discrete... More, due to the speed of EXTRA! (?), the copy is about one second each. For the number of screens I want to verify the content, it's too slow.
So I think that if I had a function to "listen" to the messages witch are received by the app (or to listen to certain messages), may I can identify the message witch send the information on the screen as I know what is displayed when I run a command.
I hope I wasn't confuse in my explanations.
I know that my problem is very specific, but after all, any idea will bve welcome...
Thanks a lot. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Tue Jun 22, 2004 10:58 pm Post subject: |
|
|
Thanks beardboy,
I didn't know Winspector. It's look great !!! I will try it as soon as possible.
But if I can with it get the (type of) messages witch are sent to the control window to display screens, there is nothing in AHK for the moment to watch after these messages. I can send commands with Send, there is no problem (I don't realy need PostMessage or SendMessage to do that), but i'd like to capture the text content of the screens one after one as they are displayed to see if there is the one I'm waiting for or not...
If I can know witch message is concerned with Winspector, after I need a command (if it's possible) th see either there is this message or not to be able to see the contents of the screens without the need to copy it to the clipboard...
May be with a system wide hook ? I don't know...
Thanks a lot for your answer. |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Jun 22, 2004 11:09 pm Post subject: |
|
|
| Is it correct that you want to catch/read/listen to the STDOUT of a running process ? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Wed Jun 23, 2004 12:20 am Post subject: |
|
|
The text in some controls cannot be easily retrieved, e.g. if it is "drawn" (I believe). In addition, some programs send no text-info messages to create such text, they just copy it in there directly or draw it. But use Winspector to find out for sure.
| Quote: | | The only way I have to get the text of the window is to do a "select all" and then copy the screen. ... due to the speed of EXTRA! (?), the copy is about one second each. For the number of screens I want to verify the content, it's too slow. |
Perhaps the copy process can be accelerated. For example, here is a fast way to copy text:
| Code: | SetKeyDelay, 0 ; To make it extra fast.
clipboard =
Send, ^c ; Replace this with whatever key sequence you need.
ClipWait, 2
if ErrorLevel <> 0
return
MsgBox This is probably the fastest possible copy:`n%clipboard% |
|
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Wed Jun 23, 2004 6:00 am Post subject: |
|
|
The 3970 computer and CICS OS is, in use, like a DOS program : the programm is controled by a command line. It is usually (and I think in my firm too) prgrammed in COBOL.
I'm not shure the problem is with CICS, but perhaps with the emulator EXTRA!.
It's sure that I don't understand why I can't have a valid control name to get the text that is in the control.
As the CICS systrem is probably of the same period than MS DOS, the information delivred should be only text with probably control characters to say what section of the screen can be edited or not, but I can't belive the the text is originally "drawn" like in windows, because of the age of the CICS system.
For the copy I will try the code. The main difference with mine is
because I alredy coded
But the inconvenience of the "Select All then Copy", that make the screen "flash", will remain.
If I can't do by an other way, I will do by this one, of course, but it isn't very comfortable for the user...
May be the way to | Quote: | | catch/read/listen to the STDOUT of a running process | is the way to achieve a good result. But how to do that in AHK ?
Thanks all of you for the advices. |
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Wed Jun 23, 2004 9:12 am Post subject: |
|
|
Some news :
I found the same problem with SuperEdi (http://www.wolosoft.com/en/superedi/)
When I use Window Spy to know the name of the control (the Edit window) under cursor, I get :
>>>>>>>>>>>>( Window Title )<<<<<<<<<<<<<
SuperEdi - [Autoexec.bat]
ahk_class Afx:00400000:8:000014BE:00000000:0000805F
>>>>>>>>( Last Control Under Mouse )<<<<<<<
Afx:00400000:81
So the name of the edit control is Afx:00400000:81, wich is like what I get with EXTRA! : an "Afx:" and something like that... (I seen the name of the control seems to be always the same, but not the class of the window)
With this little prog :
| Code: | WinGet, active_id, ID, A
MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl
MsgBox %OutputVarWin%
MsgBox %active_id%
ControlGetText, OutputVar, , ahk_id %active_id%
MsgBox %OutputVar% |
I obtain the unique ID number, whitch is the same with WinGet and MouseGetPos (usually for this type of search, I prefer to use a command not related to the mouse position as of course it can change, but in this case the pointer was over the control...)
I alternatively use (in this case...) :
| Code: | | WinGet, active_id, ID, ahk_class Afx:00400000:8:000014BE:00000000:0000805F |
The output of the two first MsgBox is the same, but the output of the last MsgBox (after the ControlGetText command, as I want to get the text in the control) give ... nothing, like with EXTRA!.
With NotePad, the name of the control is Edit1 and with the ControlGetText command, I got the text witch is in the Edit control.
Why does it not work with and "Afx:etc" control ?
Probably th answer to this question is the answer to my problem... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
Posted: Wed Jun 23, 2004 12:32 pm Post subject: |
|
|
| Quote: | catch/read/listen to the STDOUT of a running process
is the way to achieve a good result. But how to do that in AHK? |
If it's a console program, you might be able to catch its text output using some kind of 3rd party utility. I wrote one that might help:
http://www.autohotkey.com/misc/PipeSplit.exe
Instructions:
Reads from stdin and writes it to both stdout and the specified file.
Example usage: dir |pipesplit filename.txt A
Where A, if specified, causes append rather than overwrite.
| Quote: | | Why does it not work with and "Afx:etc" control? |
ControlGetText can't fetch text from a control unless that control is designed to respond to the standard get-text query. Usually, only edit controls will respond, but some others might also. In this case, the control appears to be entirely custom, so there might be no way to get its text directly.
Last edited by Chris on Wed Sep 13, 2006 2:07 pm; edited 1 time in total |
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Wed Jun 23, 2004 10:21 pm Post subject: |
|
|
No doubt CICS is a console programm, whtch works with a command line, pre formated screens (I don't remember but almost 80 chars by 24 lines, forms and so on, but I'm not shure it will work. I'll try and see.
Concerning the "Afx:xxxxx:xxxx" controls, there are almost in two apps whitch have noting in common, but both they correspond to the (almost for EXTRA!-CICS and completly for SuperEdi) equivalent of an edit control. Perhaps these controls are not entirely custom as they have the same begining of name, Afx: (essentialy the numbers differs from on control to the other and the number of numbers...). May be is an undocumented figure of Windows.... I don't know...
If it doesn't work with pipesplit, I will come back to the "Select All & Copy" method witch, even if it's not pleasant (It makes the screen "flaxhing"), it's effective....
But please, Chris, considers using in the (not necessary near) future the system wide hooks with a dll. I'm not a programmer and I begin in C+, but I know for example there are, on www.codeproject.com, free sources code for hooks. Perhaps it can be a good way to extend more the AutoHotkey's capabilities, witch are already very important.
Thanks again for your work and your answers. |
|
| Back to top |
|
 |
Nemroth Guest
|
Posted: Thu Jun 24, 2004 5:14 pm Post subject: |
|
|
Just a little info.
I tried pipesplit but, it don't work at all under CICS... I think it's normal because CICS commands are send on the mainframe and not localy to a DOS window... |
|
| Back to top |
|
 |
Beastmaster
Joined: 15 Apr 2004 Posts: 182
|
Posted: Thu Jun 24, 2004 6:28 pm Post subject: |
|
|
Hi Chris,
would you mind to include/compile that instruction to the PipeSplit.exe so it can be called via a standard /?
Thx.
| Quote: | Instructions:
Reads from stdin and writes it to both stdout and the specified file.
Example usage: dir |pipesplit filename.txt A
Where A, if specified, causes append rather than overwrite. |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10463
|
|
| Back to top |
|
 |
WhiteCloud
Joined: 19 Jun 2004 Posts: 68
|
Posted: Fri Jun 25, 2004 6:16 am Post subject: |
|
|
Nemroth, I use SmarTerm for terminal emulation and it comes with a very extensive macro language that would do what you wanted and much much more. Make sure you check out all the documentation that goes with your terminal program. I work with the ibm 3270 form based session type which i think is what you're using. I had no idea that investigating what the program called "macros" would uncover a 580 page VBA-based macro language manual.  _________________ AHK = Hella fun |
|
| 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
|