Manage other windows from a C # application

I am writing a C # application that will aggregate the management of several applications (WMP, Google Earth, etc.). For applications that I don’t write myself, I start as a process, so I have their descriptors (handle = Process.Start ("C: \ whatever.exe"), I think this is code).

In order for it to work smoothly, I need to be able to control the minimized / maximized state of each window, including the ones that I started using Process.Start (). I have seen several methods that claim this, usually requiring import of user32.dll and applying ShowWindow (handle, state).

I ask two questions. Is this the best way to do this? I am new to .NET / Windows programming (coming from * nix). Also, I couldn't get it to work, so are there any quirks that will catch the newbie?

(FYI: VS 2008 for Windows 7 RTM)

+3
source share
3 answers

You can also check the Windows Accessibility API . They are widely used at Microsoft to automate user interface tests.

+1
source

Getting the process handle is most likely the wrong handle if you are looking for a window handle.

VB6 , , min/max/close/activate .., .Net, , .Net

:
, , GetMainWindowHandle, . Windows, "" . , , .

+2

API , , . ( API- Windows Accessibility, ), . . , - :

var application = Application.Attach(processID);
var window = application.GetWindow(windowName);
window.DisplayState = DisplayState.Minimized;
+1
source

Source: https://habr.com/ru/post/1719752/


All Articles