Get the text from statusbar

Windows specific forum
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Get the text from statusbar

Post by Le Soldat Inconnu »

Hello,

I have a matter to get the get the text of a statusbar.
i hope to get the statusbar text from another windows (not get the statusbar text from my window but get the statusbar text from the purebasic editor for example)

Code: Select all

Delay(1000)

; Get the Foreground Window
WindowE = GetForegroundWindow_()

; Get the handle of the statusbar
hwndStatus = FindWindowEx_(WindowE, 0, "msctls_statusbar32", 0)

; get the number of field
NbField = SendMessage_(hwndStatus, #SB_GETPARTS, 50, 0)

Debug "Type of operation used To draw the text :"
Debug Str(0) + " : The text is drawn with a border to appear lower than the plane of the window."
Debug Str(#SBT_NOBORDERS) + " : The text is drawn without borders."
Debug Str(#SBT_POPOUT) + " : The text is drawn with a border to appear higher than the plane of the window."

Debug ""

Debug "Number of parts  = " + Str(NbField)

Debug ""

For n = 0 To NbField - 1
  
  ; Get the text length
  length.l = SendMessage_(hwndStatus, #SB_GETTEXTLENGTH, n, 0)
  
  Low = length & $FFFF
  High = length >> 16 & $FFFF
  
  Debug "Text length = " + Str(Low)
  Debug "Text draw with = " + Str(High)
  
  ; get the Text
  Text.s = Space(Low)
  r = SendMessage_(hwndStatus, #SB_GETTEXT, n, Text)
  
  Debug "Text = " + Text
Next
I can get the number of parts of the statusbar, the text lenght but when I get the the text, my function returns ""

Could you help me, thanks :wink:
LSI
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Post by Le Soldat Inconnu »

No idea ???
LSI
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Hi,

Did you get this working? I've been trying to do something very similar and have come up against the same problem. Does anyone know why the code above doesn't get the text?

Thank you very much,
Mat
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

To answer my own question, it looks like SB_GETTEXT doesn't work across processes, but WM_GETTEXT does so using that will do for my needs :-)
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Get the text from statusbar

Post by BarryG »

Request done as I need to get the StatusBar text too -> https://www.purebasic.fr/english/viewtopic.php?t=86486
Post Reply