 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Ivan Guest
|
Posted: Wed Jul 26, 2006 9:40 am Post subject: Close windows by middle clicking on task bar |
|
|
Just a small script to close windows by middle clicking on their button in the task bar:
http://ludios.org/media/code/taskbar-middle-close.ahk - please read the comments at the top.
It can be used standalone but I really recommend it with Taskbar Shuffle. Unless several people test it, I can't claim it is bug-free enough to not send Alt-F4 to the wrong place. Don't use it with unsaved work open.
If anyone has any ideas on how to improve it (it's only 8 lines of actual code), let me know. |
|
| Back to top |
|
 |
Ivan Guest
|
Posted: Thu Jul 27, 2006 3:59 am Post subject: |
|
|
| In case anyone was interested: the Taskbar Shuffle author says he'll include the functionality in the next version. |
|
| Back to top |
|
 |
azure
Joined: 07 Jun 2007 Posts: 296
|
Posted: Wed Jun 13, 2007 6:58 am Post subject: |
|
|
can you tell me please how to close a window by right clicking on its taskbar tab
thanks |
|
| Back to top |
|
 |
TK Guest
|
Posted: Mon Jul 21, 2008 3:54 pm Post subject: Re: Close windows by middle clicking on task bar |
|
|
| Ivan wrote: |
If anyone has any ideas on how to improve it (it's only 8 lines of actual code), let me know. |
Try this one
enablePosCheck = 1
taskBarHeight = 23
StartY = % A_ScreenHeight - taskBarHeight
CoordMode, Mouse, Screen
~MButton::
MouseGetPos, x, y, window, control
If (y > StartY or enablePosCheck == 0) {
StringGetPos, pos, control, ToolbarWindow
if ErrorLevel {
} else {
Click
Click
Send {RButton}
Sleep, 100
Send, c{ENTER}
}
}
return  |
|
| Back to top |
|
 |
TK Guest
|
Posted: Mon Jul 21, 2008 8:43 pm Post subject: Re: Close windows by middle clicking on task bar |
|
|
| Ivan wrote: | | If anyone has any ideas on how to improve it (it's only 8 lines of actual code), let me know. |
EVen better version i guess would be this
| Code: | enablePosCheck = 1
taskBarHeight = 23
StartY = % A_ScreenHeight - taskBarHeight
CoordMode, Mouse, Screen
~MButton::
MouseGetPos, x, y, window, control
If (y > StartY or enablePosCheck == 0) {
StringGetPos, pos, control, ToolbarWindow
if ErrorLevel {
} else {
Send, {RButton}
Sleep, -1
Send, c
}
}
return |
As this doesn't send Alt+F4
And just missed to appreciate ur initial work in the last post dude
Fantabulous keep it up!!
 |
|
| Back to top |
|
 |
k3ph
Joined: 21 Jul 2006 Posts: 123
|
Posted: Tue Jul 22, 2008 5:23 am Post subject: |
|
|
this is more secure, using ControlFromPoint by Lexikos and similar menu closing method by TK. Enjoy!
| Code: | #NoEnv
SetBatchLines, -1
CoordMode, Mouse, Screen
~$MButton::
MouseGetPos, X, Y, win, control
if (control == "ToolbarWindow322") {
WinGetPos, wX, wY,,, ahk_id %win%
X -= wX, Y -= wY
hwnd := ControlFromPoint(X, Y, "ahk_id " win,"", cX, cY)
PostMessage, 0x204, 0x2 | 0x1, cX & 0xFFFF | (cY & 0xFFFF) << 16,, ahk_id %hwnd%
PostMessage, 0x205, 0x0, cX & 0xFFFF | (cY & 0xFFFF) << 16,, ahk_id %hwnd%
WinWait,ahk_class #32768,,1
PostMessage,0x100,0x43,0x002E0001,,ahk_class #32768
PostMessage,0x101,0x43,0xC02E0001,,ahk_class #32768
}
return
ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText="")
{
if !(hwnd := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText))
return false
VarSetCapacity(pt,8)
VarSetCapacity(wi,60), NumPut(60,wi)
DllCall("GetWindowInfo","uint",hwnd,"uint",&wi)
NumPut(X + (w:=NumGet(wi,4,"int")) - (cw:=NumGet(wi,20,"int")), pt,0)
NumPut(Y + (h:=NumGet(wi,8,"int")) - (ch:=NumGet(wi,24,"int")), pt,4)
Loop {
child := DllCall("ChildWindowFromPointEx","uint",hwnd,"int64",NumGet(pt,0,"int64"),"uint",0x5)
if !child or child=hwnd
break
DllCall("MapWindowPoints","uint",hwnd,"uint",child,"uint",&pt,"uint",1)
hwnd := child
}
cX := NumGet(pt,0,"int")
cY := NumGet(pt,4,"int")
return hwnd
} |
_________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
TK
Joined: 22 Jul 2008 Posts: 1 Location: INDIA
|
Posted: Tue Jul 22, 2008 3:32 pm Post subject: |
|
|
good job, thanks
secure but lil lengthier  _________________ AHK = A hot keyboard |
|
| Back to top |
|
 |
k3ph
Joined: 21 Jul 2006 Posts: 123
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Wed Jul 23, 2008 7:55 am Post subject: |
|
|
| k3ph wrote: | | this is more secure, using ControlFromPoint by Lexikos and similar menu closing method by TK. Enjoy! | Why not avoid Alt+F4 and menus entirely? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|