Trigger tear off menu by desktop right-click?
Started by szekelya


Rate this topic
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


15 posts in this topic
szekelya
Junior Member
**


0
37 posts 15 threads Joined: Feb 2010
03-03-2010, 02:23 AM -
#6
Hi Yuri,

I also have another autohotkey script that emulates another great feature of the blackbox replacement shell. Right-clicking a window titlebar minimizes the window, middle-clicking a window titlebar closes the window. Since both fetches right-clicks, these two interferes with each other.

This one operates with WM_NCHITTEST to detect titlebar clicks. If I knew how to detect desktop clicks either with WM_NCHITTEST or with any other trick, the two features could be combined.

This is the other script (works fine, you can try that, or I can also give the compiled standalone exe)
Code:
SetTitleMatchMode, 2
;#IfWinActive, Firefox
    
    ~RButton::
    {
        CoordMode, Mouse, Screen
        SetMouseDelay, -1 ; no pause after mouse clicks
        SetKeyDelay, -1 ; no pause after keys sent
        MouseGetPos, ClickX, ClickY, WindowUnderMouseID
        WinActivate, ahk_id %WindowUnderMouseID%
        
        WM_NCHITTEST_Result := IsOverTitleBar( ClickX, ClickY, WindowUnderMouseID )
        
        If ( WM_NCHITTEST_Result = 1 ) ; in titlebar enclosed area - top of window
        {
    If ClickY > 22
        {
        ;MsgBox, %ClickY% Right-click in titlebar.
        Send, {ESC}
        ;WinMinimize, ahk_class MozillaUIWindowClass
        WinMinimize, ahk_id %WindowUnderMouseID%
        }
        }
    }
return
    ~MButton::
    {
        CoordMode, Mouse, Screen
        SetMouseDelay, -1 ; no pause after mouse clicks
        SetKeyDelay, -1 ; no pause after keys sent
        MouseGetPos, ClickX, ClickY, WindowUnderMouseID
        WinActivate, ahk_id %WindowUnderMouseID%
        
        WM_NCHITTEST_Result := IsOverTitleBar( ClickX, ClickY, WindowUnderMouseID )
        
        If ( WM_NCHITTEST_Result = 1 ) ; in titlebar enclosed area - top of window
        {
            ;MsgBox, Right-click in Firefox's titlebar.
            ;WinMinimize, ahk_class MozillaUIWindowClass
    WinClose, ahk_id %WindowUnderMouseID%
    Send, {ESC}
        }
    }
return

#IfWinActive

; http://www.autohotkey.com/forum/topic22178.html
IsOverTitleBar(x, y, hWnd)
{
   SendMessage, 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16,, ahk_id %hWnd%
;msgbox, %ErrorLevel%
   if ErrorLevel in 2,3,8,9,20,21
      return true
   else
      return false
}
Visit my deviantArt gallery: http://ethsza.deviantart.com


Messages In This Thread
Re: Trigger tear off menu by desktop right-click? - by szekelya - 03-03-2010, 02:23 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)