AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Close windows by middle clicking on task bar

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Ivan
Guest





PostPosted: Wed Jul 26, 2006 9:40 am    Post subject: Close windows by middle clicking on task bar Reply with quote

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





PostPosted: Thu Jul 27, 2006 3:59 am    Post subject: Reply with quote

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

PostPosted: Wed Jun 13, 2007 6:58 am    Post subject: Reply with quote

can you tell me please how to close a window by right clicking on its taskbar tab

thanks
Back to top
View user's profile Send private message
TK
Guest





PostPosted: Mon Jul 21, 2008 3:54 pm    Post subject: Re: Close windows by middle clicking on task bar Reply with quote

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 Cool Cool
Back to top
TK
Guest





PostPosted: Mon Jul 21, 2008 8:43 pm    Post subject: Re: Close windows by middle clicking on task bar Reply with quote

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 Exclamation

And just missed to appreciate ur initial work in the last post dude
Fantabulous keep it up!!


Cool
Back to top
k3ph



Joined: 21 Jul 2006
Posts: 123

PostPosted: Tue Jul 22, 2008 5:23 am    Post subject: Reply with quote

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
View user's profile Send private message
TK



Joined: 22 Jul 2008
Posts: 1
Location: INDIA

PostPosted: Tue Jul 22, 2008 3:32 pm    Post subject: Reply with quote

good job, thanks
secure but lil lengthier Smile
_________________
AHK = A hot keyboard
Back to top
View user's profile Send private message
k3ph



Joined: 21 Jul 2006
Posts: 123

PostPosted: Wed Jul 23, 2008 1:44 am    Post subject: Reply with quote

my solution would not work in all languages because it uses the "right click + c", the best solution yet is from lexikos in http://www.autohotkey.com/forum/viewtopic.php?p=168788#168788 although the else for "click m" is fugly Razz...
_________________
                                  [ profile | ahk.net | ahk.talk ]


Last edited by k3ph on Wed Jul 23, 2008 11:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Wed Jul 23, 2008 7:55 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group