Is it possible for C # to catch the title of the third-party software window and rename it for the duration of the session? For example to find the process calculator.exe to catch the title "Calculator" and rename it to "Test"?
|
1 answer
First we find the window and its hWnd value by name (from here) :
IntPtr hWnd = IntPtr.Zero; foreach (Process pList in Process.GetProcesses()) { if (pList.MainWindowTitle.Contains(wName)) { hWnd = pList.MainWindowHandle; } } return hWnd; //Should contain the handle but may be zero if the title doesn't match Then set the window's value (from here) :
[DllImport("user32.dll")] static extern bool SetWindowText(IntPtr hWnd, string text); - Thank! Tell me, is it possible to make this DLL bind to throw in the folder to the program and what did it rename when starting? - Winteriscoming
- I did not understand the question, please specify what you mean. The DLL is a dynamic library, it is used just like any other library — it is included in the project and functions are called or used by the classes that are in it. - Daniel Protopopov
- wName - the name of the window you want to rename? - Winteriscoming
- Yes, this is the text in the title of the required window - Daniel Protopopov
|