Requires ACC.ahk and COM.ahk libraries found here A big thanks to Sean for this.
Set contact's Name (WLM 8.1, 8.5) or email (WLM 2009) to the variable "title". The chat history is displayed in a message box and saved in a text file.
#Include ACC.ahk #Include COM.ahk SetTitleMatchMode, 2 title = [email protected] ; In Windows Live v 8.1 - 8.5, use the contact display name. Email will work in Windows Live Messenger 2009 only WinGet, winid, ID, %title% controlid := DllCall("FindWindowEx", Uint, winid, Uint, 0, str, "DirectUIHWND", int, 0) ACC_Init() controlpacc := Acc_AccessibleObjectFromWindow(controlid) number := acc_ChildCount(controlpacc) childpacc := ACC_AccessibleChildren(controlpacc, varChildren) Loop, %number% { apacc := GetAccessibleChildFromArray(childpacc, varChildren, A_Index) name := acc_Name(apacc, _idChild_) If name = History { history := acc_value(apacc, idChild_) MsgBox, %history% FileAppend, %history%, Chat History of %title%.txt Break } } ACC_Term() ; The following function was written by Lexikos to get the Variant array data returned by AccessibleChildren, so a big Thanks to him GetAccessibleChildFromArray(pacc, ByRef array, i) { vt := NumGet(array, i*16, "ushort") val := NumGet(array, i*16 + 8) ; If array[i].vt == VT_DISPATCH, array[i].pdispVal contains an IDispatch interface pointer. if vt = 9 return acc_Query(val) ; Otherwise it should be VT_I4 and array[i].lVal should contain the child's id. ; if vt = 3 ; return acc_Child(pacc, val) ; return 0 }
Alternate version by Sean:
#Include ACC.ahk #Include COM.ahk SetTitleMatchMode, 2 title = [email protected] ; In Windows Live v 8.1 - 8.5, use the contact display name. Email will work in Windows Live Messenger 2009 only WinGet, winid, ID, %title% controlid := DllCall("FindWindowEx", Uint, winid, Uint, 0, str, "DirectUIHWND", int, 0) controlpacc := Acc_AccessibleObjectFromWindow(controlid) Acc_Init() pacc := Acc_AccessibleObjectFromWindow(controlid) penm := COM_QueryInterface(pacc, "{00020404-0000-0000-C000-000000000046}") Loop, % COM_Invoke(pacc, "accChildCount") If pobj := COM_Invoke(pacc, "accChild", A_Index) { COM_Invoke(pobj, "accName", 0)="History" ? history:=COM_Invoke(pobj, "accValue", 0):"", COM_Release(pobj) If history { MsgBox, %history% FileAppend, %history%, Chat History of %title%.txt Break } } COM_Release(penm) COM_Release(pacc) Acc_Term()