Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
114 views
in Technique[技术] by (71.8m points)

c# - Get Window Title Using Class With Same Class Name?

ANSWER: Get the processes currently running using Process.GetProcesses(); and wants you got all the processes filter through them checking if they include anything that might link to the media player using and if statement and Process.MainWindowTitle.Contains("something about media player");

Hello Stack Overflow Users!

I am currently running into a problem developing my program. I am trying to grab the current window text from Clementine - A Media Player. The way I usually grab window titles is like this:

IntPtr ClementineWindow = FindWindow("QWidget", null);
string CurrentSong = new string((char)0, 100);
int WindowTitle = GetWindowText(ClementineWindow, CurrentSong, CurrentSong.Length);

But after looking into it, it will either return a number (0) or nothing. I noticed in WinSpy++ that a lot of the child windows are using the same class name "QWidget" an image can be seen below showing this:

https://i.imgur.com/ss6qCi8.png

Currently, I tried grabbing the window title using handle but I don't quite think I got the hang of that. Any help would be greatly appreciated. Thank you all!

I should also note that the way I usually grab window handles uses the FindWindow and GetWindowText things from user32 DLL.

question from:https://stackoverflow.com/questions/65865771/get-window-title-using-class-with-same-class-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...