AutoHotkey Community

It is currently May 27th, 2012, 11:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: September 1st, 2009, 8:31 am 
Offline

Joined: February 24th, 2005, 8:45 am
Posts: 278
I have been trying to get the text from the chat window of Windows Live messenger, without any luck. But after some googling, a guy had found a way through AccessibleObjectFromEvent and IAccessible to make it work, but his code is in VB and I am not familiar with that.

Can someone tell how to make it work in DllCall in AHK?

Code:
Dim ObA As IAccessible 'core element for getting UI info
    Dim v As Variant
    Dim LRet As Long

    Dim topPositionObject As Long
    Dim leftPositionObject As Long
    Dim widthObject As Long
    Dim heightObject As Long

    Dim MSN_CHAT_MESSAGE as string



    'hWnd is the handle of the window

   'Get the IAccessible object from evet to get the position information
   LRet = AccessibleObjectFromEvent(hWnd, idObject, idChild, ObA, v)

   If (LRet = 0) Then

       'Get the location of the the window
       Call ObA.accLocation(leftPositionObject, topPositionObject, widthObject, heightObject, v)

       'Get the location using  AccessibleObjectFromPoint
       LRet = AccessibleObjectFromPoint(leftPositionObject,topPositionObject, ObA, v)


      MSN_CHAT_MESSAGE = ObA.accValue(v)

   End If


From page : http://social.msdn.microsoft.com/Forums ... ec48feaec4

_________________
My small "thanks" to AHK in shape of these dedicated 3d images
Image


Last edited by sosaited on September 1st, 2009, 11:12 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2009, 10:00 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
Can't help with the conversion, but I can suggest an alternative.

Here is a script that captures the information of the active window, with the window spy program that comes with AHK.

Run this script (change the hotkey to suit you)

Bring up the WLM window so it is the active window.

Hit the hotkey and it will bring up the spy, which will copy the target's data
the script then copies the data from the spy to the clipboard.

With the resulting information, and maybe some help :wink: you should be able to capture the WLM data that you want w/o resulting to DLL.

Post the resulting data in this thread, :arrow: please be kind enough to use quote tags to format the data.
Code:
;==================================================================
; active the AHK window spy and take a snapshot of the spy's date
;==================================================================
; if the spy is not already, open it. leave the spy open when done
;==================================================================

#singleinstance force
#Persistent
settitlematchmode 2
return

#q::
;WinGetActiveTitle, Target
;msgbox %Target%


ifWinNotExist ahk_class AU3Reveal
{
  Run, %A_AhkPath%\..\AU3_Spy.exe, , min
}

WinWait, ahk_class AU3Reveal,, 12
if (errorlevel<>0)
{
  msgbox Couldn't start AU3_Spy.exe`n`nPress Ok to exit.
  return
}

  sleep, 500


; get the body of text that Window Spy has about current window
ControlGetText, OutputVar ,Edit1, ahk_class AU3Reveal


;msgbox % OutputVar

clipboard= %OutputVar%
  msgbox Data from AU3_Spy.exe copied to clipboard`n`nPress Ok to exit.

;msgbox % clipboard

return


Leef_me


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2009, 11:11 pm 
Offline

Joined: February 24th, 2005, 8:45 am
Posts: 278
I have already tried that, but none of ControlGet, Winget etc work.

Live messenger uses a custom UI element of MSAA (Microsoft Active Accessibility). Just like IE and Firefox use MSAA to display webpages.

_________________
My small "thanks" to AHK in shape of these dedicated 3d images
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 12:16 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Your code is incomplete, missing SetWinEventHook which call-back the function you posted. Anyway, I already wrapped MSAA, even the SetWinEventHook and the Callback procedure, as you found out by searching.
http://www.autohotkey.com/forum/viewtopic.php?t=24234

The code you posted is like this. (Download again the ACC.ahk which was updated to remove the usage of Global variables)
Code:
;acc_Init()   ; don't forget to call it at the startup of the script!

If   pacc := acc_AccessibleObjectFromEvent(hWnd, idObject, idChild, _idChild_)
{
   acc_Location(pacc, _idChild_, l, t, w, h), COM_Release(pacc), pacc:=_idChild_:=0
   If   pacc := acc_AccessibleObjectFromPoint(l, t, _idChild_)
      MSN_CHAT_MESSAGE := acc_Value(pacc, _idChild_), COM_Release(pacc)
}


PS. BTW, don't use PM for questions about codes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 6:16 am 
Offline

Joined: February 24th, 2005, 8:45 am
Posts: 278
Thanks for the clarification and the code Sean. I am not that familiar with DLLcalls, so I will have to spend some time on msdn and reading your acc script to get something working. Though I think just getting the windows hwnd and then classNN of the control should get it working.

Sorry if you mind the PM, but I didn't think you'll get to see this topic unless I did that :oops:

_________________
My small "thanks" to AHK in shape of these dedicated 3d images
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 8:23 am 
Offline

Joined: February 24th, 2005, 8:45 am
Posts: 278
I was messing around with the codes, but I couldn't get any text from it for some reason.... I could get the pointer to the window, but its child controls were not getting show no matter what I tried. Of course this most probably is because I was doing something wrong.

Fortunately I tried your code in the ACC topic, to get the info of window and child controls under the cursor, and it worked flawlessly.

Now the problem is that I want to get the "value" text of the child control. It has a name "History". So is there any way it can be done with the name or something else which is static (like its id), instead of screen coords? I checked from MSDN, and there isn't a function of sort "AccessibleObjectFromName"

Thanks a lot.

_________________
My small "thanks" to AHK in shape of these dedicated 3d images
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 3rd, 2009, 1:23 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
sosaited wrote:
I checked from MSDN, and there isn't a function of sort "AccessibleObjectFromName"
You can write your own. Use the class name of the control. Then obtain the window handle of it and use AccessibleObjectFromWindow.

BTW, I'll not reply anymore on this thread. Seriously learn about Accessibility and try to figure it out yourself. IMO it'll become more and more important realm, at least in Windows, although the emphasis is somehow shifted toward UIAutomation than MSAA itself. A lot of new controls might not work with old methods like ControlGet etc, then Accessibility may be the only way to interact with them.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 7:08 am 
Offline

Joined: February 24th, 2005, 8:45 am
Posts: 278
The solution was not that hard, but for some reason I got stuck with it. But finally got it working:
http://www.autohotkey.com/forum/viewtopic.php?t=48629

_________________
My small "thanks" to AHK in shape of these dedicated 3d images
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group