I am an intermediate c++ programmer and currently using Visual C++. I want to write a program which could receive real-time information from the currently running applications and process that information to perform its respective task.
for example: How can I receive the characters written on the title bar of an application to be able to process that information("the string" of the title bar)?
Could anyone post a simple example on that fact... I'll be really obliged.
GetWindowText() will get you the text associated with any window (for main windows this means the title bar text). All you need is the handle to the window in HWND form.
If the window belongs to your own program, then getting the HWND should be easy.
If the window belongs to another program, you can try looking for it with FindWindow
well if you'd done WinAPI programming before, you must've seen "HWND", right?
An HWND is a "handle" to your window (basically, it is your window). Whenever you create a window (with CreateWindow, or DialogBox, or CreateDialog, or whatever), you get an HWND. You can use that HWND to manipulate the window.
But before I go any further, I want to make sure we're on the same page. If you've never done any WinAPI programming before then I don't know if I'll really be able to help you (sorry, I just don't have the time). Maybe someone else can give you a link to a tutorial or something. =x
I don't want to learn the whole thing. I want to do just that particular thing of getting the title bar.
I got the handle of the title bar as "0x00A30130" .(using TaskManagerEx) I'm not able to put this data into the function GetWindowsText().
What I'm doing is - GetWindowText(0x00A30130, x , 20);
This is giving me error:
error C2664: 'GetWindowTextA' : cannot convert parameter 1 from 'const int' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
That error is because you are entering a constant integer value in where the function GetWindowTextA() is looking for a Handle data value type.
First of all Disch is right you haven't done WinAPI programming before and it is unlikley anyone here will teach you. But I have a few hours to kill so I'll step up and help with one or two things it may be enough to get you started.
The reason that your query failed is that it seems you were trying to pass a memory address of some application instead of the handle to the Window. Also it says right in the description of the GetWindowText Function that it cannot retrieve the text of a control in another application, so if this is your goal then you're going about it wrong. So if you don't mind I would like to help you but I need to know what you are trying to do, your above posts are too vauge for my taste.