Closing Programs/ Windows by a Middle-click on the Taskbar
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Closing Programs/ Windows by a Middle-click on the Taskbar
Does anyone know what commands can be used to close a program/ window by middle-clicking on its icon in the taskbar?
(Previously, I used the application Taskbar Tweaker to close programs by middle-clicking on their icons in the taskbar. But since Taskbar Tweaker does not work in Windows 11, I am seeking an alternative. Perhaps it is possible to write an AutoHotkey script.)
(Previously, I used the application Taskbar Tweaker to close programs by middle-clicking on their icons in the taskbar. But since Taskbar Tweaker does not work in Windows 11, I am seeking an alternative. Perhaps it is possible to write an AutoHotkey script.)
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
I have my taskbar at the top edge. You can adjust as needed.
Code: Select all
SysGet, mwa, MonitorWorkArea
#If mousePos("y") < mwaTop
MButton::
Click, R
Sleep, 300
Send {Up}`n
Return
#If
mousePos(xy) {
CoordMode, Mouse
MouseGetPos, xpos, ypos
Return xy = "y" ? ypos : xpos
}
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
Thank you.mikeyww wrote: ↑01 Jul 2022, 13:10I have my taskbar at the top edge. You can adjust as needed.
Code: Select all
SysGet, mwa, MonitorWorkArea #If mousePos("y") < mwaTop MButton:: Click, R Sleep, 300 Send {Up}`n Return #If mousePos(xy) { CoordMode, Mouse MouseGetPos, xpos, ypos Return xy = "y" ? ypos : xpos }
If I want to put this script within a file with many other scripts, should the line SysGet, mwa, MonitorWorkArea be put immediately before this script or at the very beginning of the file, before all the other scripts within the file?
I have tried running the script but do not understand what needs to be changed in it so that it may close programs/ windows when I middle-click on their taskbar icons.
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
Top of script. The file is the script.
Could try:
Or:
Could try:
Code: Select all
#If mouseOutside()
MButton::
Click, R
Sleep, 300
Send {Up}`n
Return
#If
mouseOutside() {
SysGet, mwa, MonitorWorkArea
CoordMode, Mouse
MouseGetPos, x, y
Return x < mwaLeft || x > mwaRight || y < mwaTop || y > mwaBottom
}
Code: Select all
#If mouseOverTaskbar()
MButton::
Click, R
Sleep, 300
Send {Up}`n
Return
#If
mouseOverTaskbar() {
CoordMode, Mouse
WinGetPos, x, y, w, h, ahk_class Shell_TrayWnd
MouseGetPos, mx, my
Return mx >= x && mx < x + w && my >= y && my < y + h
}
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
Thank you for the scripts. Now I understand what the scripts do. They open the context menu by right-clicking on an icon and then send the Up arrow keystroke in order to select the Close command in the context window.
Is it impossible to retrieve the name of a window/ program by clicking on its taskbar icon? (This will make it possible to close the window by using the WinClose command.)
Is it impossible to retrieve the name of a window/ program by clicking on its taskbar icon? (This will make it possible to close the window by using the WinClose command.)
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
I imagine that someone did it! Would search forum for "taskbar".
- A Keymaker
- Posts: 455
- Joined: 31 May 2022, 13:46
- Location: Donjon du Château de Mérovingien
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
The 7+ Taskbar Tweaker? Or some other Taskbar Tweaker?
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
7+ Taskbar Tweaker. The website of the program states that it does not support the Windows 11 taskbar.
I used 7+ Taskbar Tweaker on Windows 10, which was convenient, because the program made it possible not to group taskbar icons but to keep them separate. It also made it possible to close programs by middle-clicking on their taskbar icons.
- A Keymaker
- Posts: 455
- Joined: 31 May 2022, 13:46
- Location: Donjon du Château de Mérovingien
Re: Closing Programs/ Windows by a Middle-click on the Taskbar
That is yet another reason for me to keep running as long as possible on Windows 10Alexander2 wrote: ↑08 Jul 2022, 10:037+ Taskbar Tweaker. The website of the program states that it does not support the Windows 11 taskbar.
[...]