I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
See example on how you can do this with full source code here:
http://www.csharphelp.com/2006/08/get-current-window-handle-and-caption-with-windows-api-in-c/
Edited with @Doug McClean comments for better correctness.
If you were talking about WPF then use:
If it happens that you need the Current Active Form from your MDI application: (MDI- Multi Document Interface).
Based on GetForegroundWindow function | Microsoft Docs:
It supports UTF8 characters.
you can use process class it's very easy. use this namespace
if you want to make a button to get active window.
Use the Windows API. Call
GetForegroundWindow()
.GetForegroundWindow()
will give you a handle (namedhWnd
) to the active window.Documentation: GetForegroundWindow function | Microsoft Docs