I want to minimize a specific window, say Discord for example. Would this be achievable easily, or would it be a large hassle? I am on Windows 10.
Asked
Active
Viewed 219 times
0
-
Related: https://stackoverflow.com/questions/9858958/sendmessage-to-3-different-processes-in-c – paddy Dec 10 '21 at 04:34
1 Answers
6
If you have the window handle, such as from FindWindow()
, you can use PostMessage
to send it a WM_SYSCOMMAND
message with an wParam
of SC_MINIMIZE
.

Remy Lebeau
- 555,201
- 31
- 458
- 770

Mark Ransom
- 299,747
- 42
- 398
- 622
-
3Or, use [`ShowWindow()`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow) with `SW_MINIMIZE` – Remy Lebeau Dec 10 '21 at 06:58
-
1Note that this is a request, and the target can choose to ignore it. – IInspectable Dec 10 '21 at 09:27
-
@RemyLebeau does that work if the window belongs to another application? If it does, you should make a separate answer. – Mark Ransom Dec 10 '21 at 13:11
-
@IInspectable yes it could ignore it, but if it does the minimize button in the upper-right corner won't work either. – Mark Ransom Dec 10 '21 at 13:12