Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 08:45

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Window Title herausfinden

Discussion on Window Title herausfinden within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
Whaaat?'s Avatar
 
elite*gold: 43
Join Date: Sep 2013
Posts: 161
Received Thanks: 27
Window Title herausfinden

Hey
Ich möchte gerne den Window Title von einem Programm herausfinden.
Mein Code bis jetzt:
Code:
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <ostream>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{	
	HWND hWnd = FindWindow(NULL, L"VLC Media Player");
	cout << hWnd << endl;
	int length = GetWindowTextLength(hWnd);
	string WndwTitle[sizeof(length)];
	GetWindowText(hWnd, (LPWSTR)WndwTitle, length);
	cout << WndwTitle << endl;
	cin.get();
	
	return 0;
}
Nun ich bekomm aber bei dem cout nur ein Pointer heraus anstatt den Text bzw. Inhalt vom Window Title.
Das soll mal ein Programme werden, dass mir den Song in eine .txt datei schreibt der grade abgespielt wird also wundert euch nicht über die Includes und warum ich den Title herausfinden will.
Whaaat? is offline  
Old 06/24/2014, 22:50   #2

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
std::vector<wchar_t> windowTitleBuffer{ length, '\0' };
GetWindowText(hWnd, reinterpret_cast<LPWSTR>(windowTitleBuffer.data()) );
std::wcout << std::wstring{ reinterpret_cast<LPWSTR>(windowTitleBuffer.data()) } << std::endl;

so ungefähr sollte es funktionieren, ich habe gerade keinen C++ Compiler offen, kann es also nicht testen.
Du legst ein Array von strings an, dessen Größe sizeof(length) = 4 beträgt, damit kannst du hier nicht wirklich was anfangen. Was du brauchst, ist ein Buffer mit length * sizeof(wchar_t) Bytes Platz, den du GetWindowText übergeben kannst. Um einen std::wstring auszugeben, musst du übrigens auf std::wcout zurückgreifen.
snow is offline  
Old 06/24/2014, 23:04   #3
 
Thr!ce's Avatar
 
elite*gold: 20
Join Date: Aug 2005
Posts: 652
Received Thanks: 189
PHP Code:
int main()
{
    
HWND hWnd FindWindow(NULLL"VLC Media Player");
    
cout << hWnd << endl;
    
int length GetWindowTextLength(hWnd);
    
wchar_t *WndwTitle = new wchar_t[length];
    
GetWindowText(hWndWndwTitlelength);
    
wcout << WndwTitle << endl;
    
cin.get();

    return 
0;


Wieso willst du bei GetWindowText den WndwTitle casten?
Machs einfach gleich richtig.

sizeof(length) gibt übrigens immer 4 zurück.


Ob das alles was bringt, ist übrigens fraglich.
Afaik musst du schon den genauen WindowTitle bei FindWindow übergeben, und wenn du diesen schon weißt, brauchste ihn mit GetWindowText nicht auszulesen.
Thr!ce is offline  
Old 06/25/2014, 06:54   #4
 
Whaaat?'s Avatar
 
elite*gold: 43
Join Date: Sep 2013
Posts: 161
Received Thanks: 27
Quote:
Originally Posted by Thr!ce View Post
PHP Code:
int main()
{
    
HWND hWnd FindWindow(NULLL"VLC Media Player");
    
cout << hWnd << endl;
    
int length GetWindowTextLength(hWnd);
    
wchar_t *WndwTitle = new wchar_t[length];
    
GetWindowText(hWndWndwTitlelength);
    
wcout << WndwTitle << endl;
    
cin.get();

    return 
0;


Wieso willst du bei GetWindowText den WndwTitle casten?
Machs einfach gleich richtig.

sizeof(length) gibt übrigens immer 4 zurück.


Ob das alles was bringt, ist übrigens fraglich.
Afaik musst du schon den genauen WindowTitle bei FindWindow übergeben, und wenn du diesen schon weißt, brauchste ihn mit GetWindowText nicht auszulesen.
Ja ich möchte ihn aber wenn ein Song abspielt nochmal den Title herauslesen lassen, da beim VLC Player sich der Window Title zum Song Name ändert.
Und somit kann ich den dann in eine Datei ausgeben.
Whaaat? is offline  
Old 06/25/2014, 20:48   #5
 
KingwondA's Avatar
 
elite*gold: 312
Join Date: May 2013
Posts: 449
Received Thanks: 45
Warum 2x iostream?
#include <iostream> <------
#include <ostream>
#include <iostream> <----
KingwondA is offline  
Reply


Similar Threads Similar Threads
[C#] Getting PID from window title
01/10/2013 - .NET Languages - 11 Replies
I searched everywhere and can not find anything useful on this topic. Is this even possible? I have multiple process. Each have the same process name, but different window titles. I want to use the window title to find out the process ID. Any suggestions? Thank you.
How to change window title
01/05/2013 - Flyff Private Server - 1 Replies
how to change the window title of all program .exes from accountserver.exe to worldserver.exe in source???
Window Title
04/22/2008 - Perfect World - 3 Replies
anybody knows how to change the window title of pwo? maybe with olly or smth... ? thx in advance!
Rename CO2 window title (any window actually)
05/13/2006 - CO2 Exploits, Hacks & Tools - 4 Replies
I have seen a few posts requesting this. It is a simple autohotkey macro nothing fancy here. You will notice also that the UPX packer detection is not triggered. If you use autohotkey and want to know how to remove the packer PM me it is rather simple. To use this little tool thingie it is very simple: Execute the code. Focus your window. Press Hotkey CTRL+WIN+w Change the Title. Apply



All times are GMT +1. The time now is 08:46.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.