Jump to content

batch file that minimizes one window or closes a window with out killing the processes

idkpc

hello,

I've been trying to make a batch file that minimizes a certain window or close a window but doesn't kill the task so I can use it on an app like discord so that it doesn't completely quit out of it

 

plz help if you can, also I don't know a lot about batch files so sorry for the stupid question in advance.

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, idkpc said:

hello,

I've been trying to make a batch file that minimizes a certain window or close a window but doesn't kill the task so I can use it on an app like discord so that it doesn't completely quit out of it

 

plz help if you can, also I don't know a lot about batch files so sorry for the stupid question in advance.

Doesn't discord have an open to close to system tray?

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, vorticalbox said:

Doesn't discord have an open to close to system tray?

yeah.... my discord doesnt really ever close unless i specifically tell it to

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know how to do it in batch but if you know a little bit of C++ then with the win32 API its pretty easy with GetForgroundWindow() and then subsequently making a call to ShowWindow(HWND, SW_HIDE); 

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    PSTR lpCmdLine, INT nCmdShow)
{
	HWND handle = GetForgroundWindow(void); // Get the handle to which ever window is in the forground.
    ShowWindow(handle, SW_HIDE); // the SW_HIDE is how you achieve the app tray
    return 0; // return to close the program.
}

 

This should compile and in theory work but I haven't tested it as this is completely off the top of my head.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Sakuriru said:

I think he means he wants to make other programs of his choosing like Discord.

ye basically i just want to minimized an app or have it minimize back into system tray, and then map the bat file to a marco from a software I'm using  (clavier +, cause i don't know how to use autohotkey)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×