Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Get the title of a window

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Mon May 05, 2008 4:26 am    Post subject: Get the title of a window Reply with quote

I was wondering, if it is possible to get the title of a window, using the hwnd, or in any other way, get a list of all the open applictions, by the window name or class name

Prefer in delphi, but C++ would be ok aswell
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Mon May 05, 2008 4:58 am    Post subject: Reply with quote

Look in ce's source at the proces list or window list thing...

Anyway, you can use the following api's:
EnumWindows
GetWindow
FindWindow
GetActiveWindow
GetWindowText
GetWindowTextLength
SetWindowText
and probably some more..
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 05, 2008 5:01 am    Post subject: Reply with quote

Yea, you can do a lot with a window-handle.
I got this of one of my old sources, not sure if I wrote it or not, but I couldn't find it on google so I think I wrote that.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
  cap: string;
  int: integer;
begin
h := FindWindow('TApplication', NIL);
if h <> 0 then
  begin
    int := GetWindowTextLength(h)+1;
    SetLength(cap, int);
    GetWindowText(h, PChar(cap), int);
    ShowMessage(cap);
  end;
end;


Replace the TApplication to the class of the window.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 05, 2008 5:30 am    Post subject: Reply with quote

rEakW0n wrote:
Yea, you can do a lot with a window-handle.
I got this of one of my old sources, not sure if I wrote it or not, but I couldn't find it on google so I think I wrote that.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
  cap: string;
  int: integer;
begin
h := FindWindow('TApplication', NIL);
if h <> 0 then
  begin
    int := GetWindowTextLength(h)+1;
    SetLength(cap, int);
    GetWindowText(h, PChar(cap), int);
    ShowMessage(cap);
  end;
end;


Replace the TApplication to the class of the window.


nvm i figured it out XD

_________________
Stylo


Last edited by Stylo on Mon May 05, 2008 5:37 am; edited 1 time in total
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 05, 2008 5:36 am    Post subject: Reply with quote

1qaz wrote:
i couldn't find information about the setLength function on msdn
can you explain that function please? where can i find it?


You see, I declard something to int, the Length of the Window-Text(+1).
And now, before I declare the Window-Text to cab I set its length.
So, SetLength() sets the length of the string Wink
In this case I set the length of cap to int.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 05, 2008 5:39 am    Post subject: Reply with quote

rEakW0n wrote:
1qaz wrote:
i couldn't find information about the setLength function on msdn
can you explain that function please? where can i find it?


You see, I declard something to int, the Length of the Window-Text(+1).
And now, before I declare the Window-Text to cab I set its length.
So, SetLength() sets the length of the string Wink
In this case I set the length of cap to int.


yeah i've just figured that out XD
after that in GetWindowText you'll put the window text inside that string right?>

_________________
Stylo
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Mon May 05, 2008 6:06 am    Post subject: Reply with quote

rEakW0n wrote:
Yea, you can do a lot with a window-handle.
I got this of one of my old sources, not sure if I wrote it or not, but I couldn't find it on google so I think I wrote that.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
  cap: string;
  int: integer;
begin
h := FindWindow('TApplication', NIL);
if h <> 0 then
  begin
    int := GetWindowTextLength(h)+1;
    SetLength(cap, int);
    GetWindowText(h, PChar(cap), int);
    ShowMessage(cap);
  end;
end;


Replace the TApplication to the class of the window.


The reason you didn't find it on the net because you renamed the variables, uppercased some stuff and removed some lines that you probably didn't understand - http://www.swissdelphicenter.ch/torry/showcode.php?id=2143
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon May 05, 2008 6:22 am    Post subject: Reply with quote

Rot1 wrote:
rEakW0n wrote:
Yea, you can do a lot with a window-handle.
I got this of one of my old sources, not sure if I wrote it or not, but I couldn't find it on google so I think I wrote that.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
  cap: string;
  int: integer;
begin
h := FindWindow('TApplication', NIL);
if h <> 0 then
  begin
    int := GetWindowTextLength(h)+1;
    SetLength(cap, int);
    GetWindowText(h, PChar(cap), int);
    ShowMessage(cap);
  end;
end;


Replace the TApplication to the class of the window.


The reason you didn't find it on the net because you renamed the variables, uppercased some stuff and removed some lines that you probably didn't understand - http://www.swissdelphicenter.ch/torry/showcode.php?id=2143


I at least say that I'm not sure if i wrote it by myself.
Also, I'm not even sure if it's from there, it seems smiliar but not same.
I copied this out of an old project.
And these 2 lines aren't neccesarry afaik.

Rot1 wrote:
removed some lines that you probably didn't understand -

Stop being a hypocrite.


Last edited by Reak on Mon May 05, 2008 6:31 am; edited 1 time in total
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Mon May 05, 2008 6:29 am    Post subject: Reply with quote

rEakW0n wrote:
Yea, you can do a lot with a window-handle.
I got this of one of my old sources, not sure if I wrote it or not, but I couldn't find it on google so I think I wrote that.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  h: hwnd;
  cap: string;
  int: integer;
begin
h := FindWindow('TApplication', NIL);
if h <> 0 then
  begin
    int := GetWindowTextLength(h)+1;
    SetLength(cap, int);
    GetWindowText(h, PChar(cap), int);
    ShowMessage(cap);
  end;
end;


Replace the TApplication to the class of the window.


woot! ty soo much!, modifyed it a bit, now it shows all the visible windows Very Happy:

procedure TForm1.Button2Click(Sender: TObject);
var
h: hwnd;
cap: string;
int: integer;
begin
h := handle;
while h > 0 do
begin
if IsWindowVisible(h) then
begin
int := GetWindowTextLength(h)+1;
SetLength(cap, int);
GetWindowText(h, PChar(cap), int);
listbox1.Items.Add(cap);
h := GetNextWindow(h, GW_HWNDNEXT);
end;
h := GetNextWindow(h, GW_HWNDNEXT);
end;
end;
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 05, 2008 11:17 am    Post subject: Reply with quote

why when i use the GetWindowText function my application shutdown?
i have HWND to the window, empty string, and integer variable and i get no error when i compile the code

_________________
Stylo
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Mon May 05, 2008 11:22 am    Post subject: Reply with quote

1qaz wrote:
why when i use the GetWindowText function my application shutdown?
i have HWND to the window, empty string, and integer variable and i get no error when i compile the code


It did that to me aswell, but i fixed it, can i please see your source?
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Mon May 05, 2008 11:40 am    Post subject: Reply with quote

it's inside a timer and the language is C#

Code:

IntPtr hwnd = FindWindow("IMWindowClass",null);
if (hwnd != IntPtr.Zero)
{
 GetHWND.Stop(); // stops timer
 string WindowText;
 int x = 260;
 GetWindowText(hwnd,out WindowText,x);
}

_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites