matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
O.P. RE: Could someone do me a favor and run this
Got it figured out With some help from Cookie
Some of the children have children of their own
Thanks to Cookie for writing this up while I was at my girlfriend's place
js code: var sResName = GetMsgrStringResource(60052);
var IID_IAccessible = Interop.Allocate(0x10);
Interop.Call('Ole32', 'IIDFromString', '{618736E0-3C3D-11CF-810C-00AA00389B71}', IID_IAccessible);
function OnEvent_ChatWndCreated (pChatWnd) {
var oContacts = pChatWnd.Contacts;
if (oContacts.Count === 1) {
var hWnd = Interop.Call('User32', 'FindWindowExW', pChatWnd.Handle, 0, 'IM Window Class', '');
hWnd = Interop.Call('User32', 'FindWindowExW', hWnd, 0, 'DirectUIHWND', '');
var pAccessibleData = Interop.Allocate(4);
if (Interop.Call('OleAcc', 'AccessibleObjectFromWindow', hWnd, 0xFFFFFFFC, IID_IAccessible, pAccessibleData) === 0) {
var iAccessible = pAccessibleData.ReadInterfacePtr(0);
if (iAccessible) {
var bStopSearch = false;
AA_GetItems(iAccessible, new Enumerator(oContacts).item());
}
}
}
function AA_GetItems(iAccessible, oContact) {
var iAccessibleChildren = Interop.Allocate(16*iAccessible.accChildCount);
var iAccessibleChildrenFound = Interop.Allocate(4);
if (Interop.Call('Oleacc', 'AccessibleChildren', iAccessible, 0, iAccessible.accChildCount, iAccessibleChildren, iAccessibleChildrenFound) === 0){
for (var i=0; i<iAccessibleChildrenFound.ReadDWORD(0); ++i) {
if (iAccessibleChildren.ReadDWORD(i*16) === 0x9) {
var iAccessibleChild = iAccessibleChildren.ReadInterfacePtr(i*16+8);
if (iAccessibleChild) {
if (iAccessibleChild.accChildCount) {
AA_GetItems(iAccessibleChild, oContact);
} else {
if (iAccessibleChild.accRole(0) === 41) {
if (iAccessibleChild.accName(0) === sResName) {
Debug.Trace("Role: " + iAccessibleChild.accRole(0) + ", Status: " + iAccessibleChild.accState(0));
Debug.Trace("'" + iAccessibleChild.accName(0) + "' : '" + iAccessibleChild.accValue(0) + "'");
// Status/Name/PSM change cause the name to be updated
iAccessibleChild.accValue(0) = '(XX:XX) ' + oContact.Name;
Debug.Trace("'" + iAccessibleChild.accName(0) + "' : '" + iAccessibleChild.accValue(0) + "'");
bStopSearch = true;
}
}
}
}
}
if (bStopSearch) return;
}
}
}
}
// This function will read a translation string resource from Messenger located in msgslang.dll.
// If bEval (optional) is true then substrings will be filled in automatically. False by default.
function GetMsgrStringResource(nStringID, bEval) {
var hMod = Interop.Call('Kernel32', 'LoadLibraryExW', GetMsgrFullDLLName('msgslang'), 0, 2 /* LOAD_LIBRARY_AS_DATAFILE */);
var sBuffer = Interop.Allocate(2050);
Interop.Call('User32', 'LoadStringW', hMod, nStringID * 1, sBuffer.DataPtr, 1024);
Interop.Call('Kernel32', 'FreeLibrary', hMod);
sBuffer = sBuffer.ReadString(0);
if (bEval) sBuffer = sBuffer.replace(/\{(?:A\:)?(\d+)\}/g, function($0,$1){return GetMsgrStringResource($1,true)});
return sBuffer;
}
// This function will return the proper fullname of the given basename of a version dependant resource dll (eg: 'msgslang.dll', 'msgslang.8.1.0068.00.dll', 'msgslang.8.5.1302.1018.dll', 'msgslang.14.0.8089.0726.dll', etc)
function GetMsgrFullDLLName(sBaseName) {
if (Messenger.Version > 8.0) {
var sBuffer = Interop.Allocate(2050);
Interop.Call('Kernel32', 'GetModuleFileNameW', 0, sBuffer.DataPtr, sBuffer.Size / 2);
Interop.Call('Version', 'GetFileVersionInfoW', sBuffer.DataPtr, 0, sBuffer.Size, sBuffer.DataPtr);
return sBaseName + '.' + sBuffer.ReadWord(50) + '.' + sBuffer.ReadWord(48) + '.' + ('000' + sBuffer.ReadWord(54)).slice(-4) + '.' + ('0' + sBuffer.ReadWord(52)).slice(-4) + '.dll';
} else {
return sBaseName + '.dll';
}
}
This post was edited on 08-25-2010 at 02:12 PM by matty.
|
|