I'm having a few issues trying to pull text from a status bar of an external program. Long story short, if anyone has heard of Open Broadcasting Software, at the bottom of the program it shows exactly how long your stream has been "live" within a status bar. I just need a way to pull this out so I can save it to a text file. So far I've managed to find the window using Spy++ and using SendMessage I've been able to find how many "parts" the status bar has but beyond that i'm having no joy. Here's what I have:
For Each p As Process In Process.GetProcessesByName("OBS") Dim hOBS As IntPtr = IntPtr.Zero hOBS = FindWindow("OBSWindowClass", vbNullString) If hOBS = IntPtr.Zero Then MsgBox("Open Broadcaster Software is not running.") Exit Sub End If MsgBox(hOBS) Dim bag As IntPtr = FindWindowEx(hOBS, New IntPtr(0), "msctls_statusbar32", vbNullString) ' sets intLength as an int equal to the spotify windows title length MsgBox(bag) Dim nParts As String nParts = SendMessage(bag, SB_GETPARTS, 0, 0) MsgBox(nParts) Dim nLength As String nLength = SendMessage(bag, SB_GETTEXTLENGTH, 0, 0) MsgBox(nLength)
I've also tried get GetWindowText but have been told it only works if the status bar is within the same app, which i couldn't figure out ¬_¬ so gave it a go anyway.
Dim lpText As String lpText = New String(Chr(0), 100) Dim intLength As Integer = GetWindowText(bag, lpText, lpText.Length) Dim strTitle As String = lpText MsgBox(strTitle)
Oh I have all the FindWindow and FindWindowEx functions defined correctly and whatnot. And -
Const WM_USER = &H400& Const WM_GETTEXT As Integer = &HD Const SB_GETTEXTLENGTH = (WM_USER + 3) Const SB_GETPARTS = (WM_USER + 6) Const SB_GETTEXT = (WM_USER + 2)
all set.. I've read somewhere it's something to do with sharing memory in order to pull the text from the external status bar but I was hoping there was a simpler method to do this. Any assistance would be appreciated. Thanks! If there's any more information needed I will do my best to supply it.