-1

I have an exe file and I want to run it and close it by pressing a mouse button or a keyboard button. For eg. say it is a music.exe and I want to open it while I am gaming/doing spread sheet by pressing the key 'm' or mouse button.

I have access to a logitech macro supported mouse. Also a no macro generic microsoft mouse. I am thinking about some kind of macro , or tasker or some script that can do this easily. ( not that I dont want to directly click the exe file or close the exe file by clicking x on the window)

Any suggestion would be helpful ;)

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Alfas MP
  • 79
  • 1
  • 10
  • Are you allowed to code some C++ with [FLTK](https://fltk.org/) or [Qt](https://qt.io/) ? Do you have admin access to your Windows laptop? Can you install then use some [X11](https://en.wikipedia.org/wiki/X_Window_System) server? – Basile Starynkevitch Jun 25 '22 at 10:23
  • it is my personal computer. Yes, I have admin access. I only have basic knowledge about c++. It's been a while since I did any coding. But you can direct me to anything. I will try to learn ;) – Alfas MP Jun 25 '22 at 10:35
  • Consider installing [Debian](https://debian.org/) then coding using [GCC](https://gcc.gnu.org/) with [FLTK](https://fltk.org/) or [Qt](https://qt.io/) – Basile Starynkevitch Jun 25 '22 at 11:42
  • On LGS/GHUB Logitech software you can start any exe file by clicking a mouse button, but there is no command to close existing window. You can start your own program (exe/bat/...) that closes the window you need. AHK recognizes only 5 mouse buttons, while LGS/GHUB can handle all Logitech mouse buttons. – Egor Skriptunoff Jun 26 '22 at 22:21

1 Answers1

1

I did it with AutoHotKey software. If anyone is interested , here is the code

XButton2:: if WinExist("WindowName") WinClose ; else Run *runas "%directory%\Music.exe" return

This code will run and close the Music app with admin previlages. ( Change "Run *runas" to "run" if you want it to run normally)

Alfas MP
  • 79
  • 1
  • 10