AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Afx: ...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Nemroth
Guest





PostPosted: Wed Aug 18, 2004 6:18 pm    Post subject: Afx: ... Reply with quote

In a precedent wish topic I was asking to a GetMessage function, as I tried to get screens from a Windows CICS (IBM 3270) emulator.

The class of the view control, as given by Windows Spy, was :

Afx:400000:202b:10008:6:01

I tried to use the ControlGetText Function with the class
Afx:400000:202b:10008:6:01
and with the class
Afx`:400000`:202b`:10008`:6`:01

... Nothing to do to get the text of the control.

So I searched what can be an "Afx" control, as I saw an other Afx control on SuperEdi (same problem same failure...) and so I thinked they can be other controls of this type on other programs.

on MSDN, I found this page :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/vccontn070mfcwindowclassnames.asp

An Afx control is a view/split control of a program developped in MFC under Visual C++, if I understand well (I know AHK is developped in Visual C++ too, I don't know if the MFC are used).

Perhaps there may be a big amount of programs developped in MFC...

In this MSDN page there are too some explanation :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfcnotes_tn020.asp
in wich you can read : "The MFC library also uses the "IDW_" prefix as a specialized form of control IDs (that is, instead of "IDC_"). These IDs are assigned to child windows such as views and splitters by the framework classes. MFC implementation IDs are prefixed with "AFX_"."

And on these pages too !!!....
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_afxregisterwndclass.asp

And these ones too !!!!!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.createex.asp

I don't know how to program in C++, nor in Visual C++, and no more with MFC. If I can extend AHK this way that may be usefull, and I would be happy. But I don't know how to do that (for the moment I hope) ....

I understand very well that to handle the Afx controls with AHK must be considered to have a very low priority, but as in the Planned Features there is
Quote:
"Enhance ControlGetText or ControlGet to work on ListView controls"
this enhancement to these functions may be considered. It can be usefull if someone (as me !!!!!.....) has to get the text of an MFC application view control...

Thanks to consider this wish....
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Wed Aug 18, 2004 9:47 pm    Post subject: Reply with quote

Thanks for researching that. I explored your links and some did some other web searches.

First of all, AutoHotkey does not use MFC -- and even if it did, I doubt that doing so would give it any special access to the controls of other apps that use MFC.

Based on my research and yours, its seems that enhancing ControlGetText to get text from these controls would be extremely difficult. However, the research also indicates that often Control-c will copy the text from some of these controls. Have you tried this approach? It might require that the control momentarily get focus -- but maybe not. Perhaps you can do a ControlSend of ^c directly to the control in question (perhaps first sending a Control-a to "select all", if appropriate).

I would normally suggest using Winspector Spy as discussed in Rajat's Message Tutorial, but the info below suggests that is unlikely to work in this case. It seems that the Control-c technique is the most likely approach. If that fails, you might consider using a tool such as Kleptomania to OCR the graphics into text format. I've tried this program in the past and it does seem to work pretty well if the text is in a standard font.


Below are quotes from the only relevant link discovered on Google at
http://visualbasicforum.com/showthread.php?t=149804
Quote:

Those Afx window classes were custom classes distributed with early versions of MFC, before the "Common Controls" concept was introduced.

Many people have tried to "read" text from them but you CAN'T, not with messages anyway!

They're almost certainly owner-drawn - the text is not delivered by messages, it's "hand-drawn" into the window's DC

...

Messages are a dead-end I think - those who have pursued this problem must have already clocked up several hundreds of hours of monitoring message traffic between them!

There is a way to read owner-drawn text, but it requires more sophisticated tools. When the handler that finally draws the text does its thing, it will call one of the GDI text-drawing functions. It's possible to monitor those calls, much like cross-process window subclassing, but in both cases you really have to know what you're doing, and/or have some very smart tools.

Theory is discussed here (examples are all in "C", of course, you'll find few people have ventured into this area in VB)

http://www.codeproject.com/system/a...g_unleashed.asp

...

Here's another possibility: is it possible to do a lockwindow on the app, then set the focus to the child, then do a keyboard event to do the copy, then set the focus back to whatever had it, then paste from the clipboard. Has anyone tried a sequence like this? 1) Would it work? 2) Would the user see flashing or windows popping into the foreground? (hopefully the lockwindow would prevent this?) 3) Would it interrupt the user's work in any way?

Sounds like a stretch, but it's probably one of my best hopes...<argh>
Back to top
View user's profile Send private message Send e-mail
Nemroth
Guest





PostPosted: Wed Aug 18, 2004 10:26 pm    Post subject: Reply with quote

OK. It's a pity but never mind.

I use Select All - Copy and it works fine but it's a little slowly (The problem comes from the emulator, not from AHK) and makes the screen "flashing"

The information in quotes is very interesting, thanks.

I think I will wait until my boss buy a most recent version of the emulator to use an other way to take teh screen content than by the clipboard...

The Afx controls seems to be old ones...

Top get the screen content, I use the following code :

Code:
TakeScr:                     ; Recup ‚cran
   clipboard =
   Send, !en^c
   ClipWait
   return

VerScr1:                  ; Verif présence 1 chaine ds Ecran (Inclure temporisation)
   Loop, 4
      {
      Sleep 1000
      Gosub, TakeScr
      IfInString, clipboard, %VerScr1%
         {
         VerScrRet = 1
         break
         }
      else
         VerScrRet = 0
      }
   return

VerScr2:                  ; Verif présence 2 chaines ds Ecran (Inclure temporisation)
   Loop, 4
      {
      Sleep 1000
      Gosub, TakeScr
       IfInString, clipboard, %VerScr1%, IfInString, clipboard, %VerScr2%
         {
         VerScrRet = 1
         break
         }
      else
         VerScrRet = 0
      }
      return

VerScr1 copy the screen in the clipboard and watch if the string passed in the VerScr1 variable exists or not.
VerScr2 is the same but watch after two strings.

Chris, thanks for your answer and thanks a lot for your great job on AHK.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group