Hi.

--- In [email protected], "Sheri" <[EMAIL PROTECTED]> wrote:
> I think unlike other controls getting another program's
> status bar text is a process-related problem.

There's an API-function called VirtualAllocEx with which you can
allocate memory within the address space of another process:
http://msdn.microsoft.com/en-us/library/aa366890(VS.85).aspx

This works for me (using an Explorer-window):

local ret, wHan, stHan, len, str, pHan, mem
local WM_USER = 0x0400
local SB_GETTEXTLENGTH = WM_USER + 3
local SB_GETTEXT = WM_USER + 2
local PROCESS_ALL_ACCESS = 0x1F0FFF
local MEM_COMMIT = 0x1000
local MEM_RELEASE = 0x8000
local PAGE_READWRITE = 0x04

// explorer window handle:
wHan = win.handle("explorer")
// window handle of status bar:
stHan = dll.call("FindWindowEx|ui[2] s s!", wHan, 0,
"msctls_statusbar32", 0)
// length of text in third segment of status bar:
len = stHan.sendMessage(SB_GETTEXTLENGTH, 2, 0)
// reserve buffer:
str = "x".repeat(len)
// process handle of Explorer:
pHan = dll.call("OpenProcess|ui i ui", PROCESS_ALL_ACCESS, 0,
wHan.getProcessId)
// allocate memory:
mem = dll.call("VirtualAllocEx|ui[5]", pHan, 0, len, MEM_COMMIT,
PAGE_READWRITE)
// get text of third segment:
stHan.sendMessage(SB_GETTEXT, 2, mem)
// copy memory content to buffer:
ret = dll.call("ReadProcessMemory|ui[5]", pHan, mem,
dll.get_pointer("str"), len, 0)
// free memory:
ret = dll.call("VirtualFreeEx|ui[4]", pHan, mem, 0, MEM_RELEASE)
// free process handle:
ret = dll.call("CloseHandle|ui", pHan)
// show text:
win.debug(str)

Mockey


Reply via email to