This works ok.
Code: Select all
Nb=SendMessage_(Handle_statusbar,#SB_GETPARTS,0,0)
len=SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
Code: Select all
text.s=Space(len)
SendMessage_(Handle_statusbar, #SB_GETTEXT, 0, @text)
Thank you!
Code: Select all
Nb=SendMessage_(Handle_statusbar,#SB_GETPARTS,0,0)
len=SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
Code: Select all
text.s=Space(len)
SendMessage_(Handle_statusbar, #SB_GETTEXT, 0, @text)
Code: Select all
If OpenWindow(0, 100, 150, 300, 100, "PureBasic - StatusBar Example", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(50)
AddStatusBarField(100)
EndIf
num=Random(999)
StatusBarText(0, 0, "Area 1")
StatusBarText(0, 1, Str(num), #PB_StatusBar_BorderLess)
StatusBarText(0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised)
text.s=Space(999)
SendMessage_(StatusBarID(0), #SB_GETTEXT, 1, @text)
Debug text ; Should be same as "num" variable.
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
Nb=SendMessage_(Handle_statusbar,#SB_GETPARTS,0,0)
len=SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
; But this is causing crash in the program i want to read.
; Code:
text.s=Space(len)
SendMessage_(Handle_statusbar, #SB_GETTEXT, 0, @text)
Code: Select all
len=SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
len=len&FFFF
Sendmessage_(... etc.
Oh...I will try to find some example on the forum.hallodri wrote:The external program can only write their own memory. Try with VirtualAllocEx and ReadProcessMemory.
Code: Select all
Prototype.l ProtoAccessibleObjectFromPoint(x.l,y.l,*ia,*var)
Global AccessibleObjectFromPoint.ProtoAccessibleObjectFromPoint,r.RECT, hdll,name.string
CoInitialize_(0)
hdll=OpenLibrary(#PB_Any,"Oleacc.dll")
AccessibleObjectFromPoint=GetFunction(hdll,"AccessibleObjectFromPoint")
Procedure TextFromWindowPosition(*Name.String)
Define vt.VARIANT,*pIAcc.IAccessible,pName.l,len.l
If AccessibleObjectFromPoint(r\left+20,r\top+20,@*pIAcc,@vt)=#S_OK ;Use the coordinate of the proper StatusBar Part
*Name\s=""
If *pIAcc\get_accName(vt, @pName) = #S_OK
len = SysStringLen_(pName)
*Name\s = Space(len)
CompilerIf #PB_Compiler_Unicode
PokeS( @*Name\s,PeekS(pName))
CompilerElse
WideCharToMultiByte_(#CP_ACP, 0,pName, -1, @*Name\s, len, 0, 0)
CompilerEndIf
SysFreeString_(pName)
EndIf
EndIf
ProcedureReturn #True
EndProcedure
Repeat
hwnd = FindWindow_(0,"WZebra")
Until hwnd
Repeat
hwnd2 = FindWindowEx_(hwnd,0,"msctls_statusbar32",0)
Until hwnd2
GetWindowRect_(hwnd2,r.RECT)
SetForegroundWindow_(hwnd)
TextFromWindowPosition(@name)
Debug name\s
SetClipboardText(name\s)
CoUninitialize_()
CloseLibrary(hdll)
Code: Select all
hWin = FindWindow_(0, "WZebra")
Handle_statusbar = FindWindowEx_(hWin,0,"msctls_statusbar32",0)
sBufferSize = SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
sBufferSize = (sBufferSize &$FFFF)
sBuffer.s = Space(sBufferSize)
GetWindowThreadProcessId_(Handle_statusbar, @ProcID)
hProc = OpenProcess_(#PROCESS_ALL_ACCESS, 0, ProcID)
Result = VirtualAllocEx_(hProc, 0, SizeOf(sBufferSize), #MEM_COMMIT, #PAGE_READWRITE)
SendMessage_(Handle_statusbar, #SB_GETTEXT, 0, @Result)
Code: Select all
hWin = FindWindow_(0, "WZebra")
Handle_statusbar = FindWindowEx_(hWin,0,"msctls_statusbar32",0)
sBufferSize = SendMessage_(Handle_statusbar, #SB_GETTEXTLENGTH, 0, 0)
sBufferSize = (sBufferSize &$FFFF)
sBuffer.s = Space(sBufferSize)
GetWindowThreadProcessId_(Handle_statusbar, @ProcID)
hProc = OpenProcess_(#PROCESS_ALL_ACCESS, 0, ProcID)
*Result = VirtualAllocEx_(hProc, 0, SizeOf(sBufferSize), #MEM_COMMIT, #PAGE_READWRITE)
SendMessage_(Handle_statusbar, #SB_GETTEXT, 0, *Result)
ReadProcessMemory_(hProc, *Result, sBuffer, sBufferSize, 0)
Debug sBuffer
Code: Select all
ReadProcessMemory_(hProc, *Result, sBuffer, sBufferSize, 0)