# Win32/api GetWindowText

**URL:** <https://www.ruby-forum.com/t/win32-api-getwindowtext/132330>\
**Category:** Ruby\
**Created:** [March 19, 2008, 6:51am UTC](https://www.ruby-forum.com/t/win32-api-getwindowtext/132330 "2008-03-19T06:51:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyleh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a9a28c/32.png) [@kyleh](https://www.ruby-forum.com/u/kyleh)\
**Post date:** [March 19, 2008, 6:51am UTC](https://www.ruby-forum.com/t/win32-api-getwindowtext/132330/1 "2008-03-19T06:51:22Z")

</div>

Hello all,

I’m using win32/api. I was using GetForegroundWindow to get the window  
on top. Then I wanted to use GetWindowText to get the ‘title-bar’ text.  
I just couldn’t figure it out.

So, I google for win32/api documentation, and found one where it  
enumerates through all processes and returns the GetWindowText. My  
browser - Mozilla Firefox - as well as quite a few other applications  
didn’t show up properly. A few did, though.

How can I

1. Get the current ‘caption’ or ‘title-bar’ text of the foreground  
window.
2. Is there a better way than GetWindowText? It doesn’t work for many  
applications so I’m wondering.

Thanks!
