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 

Scroll klik --- close windows @ taskbar
Goto page 1, 2, 3  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jxerot
Guest





PostPosted: Thu Dec 27, 2007 10:39 pm    Post subject: Scroll klik --- close windows @ taskbar Reply with quote

hello,

can any one make me a script?? Embarassed Embarassed
so i can close windows like explorer.. whit a single klik on the taskbar whit my scroll??

like the new firefox.. when i klik whit my scroll on a tab. it will close down.

thanks!!! Very Happy
Back to top
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Fri Dec 28, 2007 12:29 am    Post subject: Reply with quote

Code:
~*MButton::
MouseGetPos, x, y
if (y < 40)
   Winclose, A
return

I tried to understand what you're asking for, but I only speak english, so I assumed that you wanted a script that would close the active window when you middle-clicked the title bar.

Please post in the appropriate language designated by the forums.
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Fri Dec 28, 2007 12:36 am    Post subject: Reply with quote

i think he wants to middle click the taskbar button to close the window.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Fri Dec 28, 2007 12:52 am    Post subject: Reply with quote

Yeah, you'd think so from what he wrote, but firefox closes a tab if you middle-click on the tab, not in the taskbar. Too bad Babblefish doesn't translate gibberish. Maybe you're right though...
[edit:]
Code:
~*MButton::
Coordmode, mouse, screen
SetKeyDelay, 50, 0
MouseGetPos, x, y
if (y + 40 > a_screenheight)
   Send {Click, Right}!{F4}
return

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Fri Dec 28, 2007 5:14 am    Post subject: Reply with quote

he was giving firefox as an example. firefox tabs are closed via the tab bar, windows tasks are closed via the task bar.

I think it's doable, I just have no idea how. maybe adapting http://www.autohotkey.com/forum/viewtopic.php?t=22763
Question

I seem to remember it did something with the taskbar.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
jxerot
Guest





PostPosted: Fri Dec 28, 2007 12:20 pm    Post subject: Reply with quote

thanks for the help..!! and sorry for my bad english. Sad

uu how to explane this..
print screen! Very Happy

http://www.jbakker.net/screenshot.JPG

and it must only close when i hit the taskbare icon. only when i'm there whit my mouse point.

so i have opend firefox an photoshop.
my point is @ firefox taskbar i click scroll and it's closed. (and photoshop is still there)
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Fri Dec 28, 2007 1:10 pm    Post subject: Reply with quote

You could try MButton: Close windows(taskbar+titlebar) & open IE links. For me (on Vista) it somehow thinks the taskbar is a titlebar, and attempts to close it (the shutdown dialog pops up.) Rolling Eyes
engunneer wrote:
I think it's doable, I just have no idea how. maybe adapting http://www.autohotkey.com/forum/viewtopic.php?t=22763
Question

I seem to remember it did something with the taskbar.
Auto-raise (the above link) uses GetMouseTaskButton to determine which taskbar button is under the mouse, if any, and which window it belongs to.
Code:
button := GetMouseTaskButton(hwnd)
; button: the one-based index of the taskbar button, or 0 if none.
; hwnd: the unique ID (hwnd) of the window belonging to the button.
Note: hwnd is 0 for group buttons (as in XP's "Group similar taskbar buttons" option.)
Code:
MButton::
    if GetMouseTaskButton(hwnd) && hwnd
        WinClose, ahk_id %hwnd%
    else {
        Click M Down
        KeyWait, MButton
        Click M Up
    }
return

; Gets the index+1 of the taskbar button which the mouse is hovering over.
; Returns an empty string if the mouse is not over the taskbar's task toolbar.
;
; Some code and inspiration from Sean's TaskButton.ahk
GetMouseTaskButton(ByRef hwnd)
{
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, win, ctl, 2
    ; Check if hovering over taskbar.
    WinGetClass, cl, ahk_id %win%
    if (cl != "Shell_TrayWnd")
        return
    ; Check if hovering over a Toolbar.
    WinGetClass, cl, ahk_id %ctl%
    if (cl != "ToolbarWindow32")
        return
    ; Check if hovering over task-switching buttons (specific toolbar).
    hParent := DllCall("GetParent", "Uint", ctl)
    WinGetClass, cl, ahk_id %hParent%
    if (cl != "MSTaskSwWClass")
        return

   
    WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd

    hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
    pRB := DllCall("VirtualAllocEx", "Uint", hProc
        , "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)

    VarSetCapacity(pt, 8, 0)
    NumPut(x, pt, 0, "int")
    NumPut(y, pt, 4, "int")
   
    ; Convert screen coords to toolbar-client-area coords.
    DllCall("ScreenToClient", "uint", ctl, "uint", &pt)
   
    ; Write POINT into explorer.exe.
    DllCall("WriteProcessMemory", "uint", hProc, "uint", pRB+0, "uint", &pt, "uint", 8, "uint", 0)

;     SendMessage, 0x447,,,, ahk_id %ctl%  ; TB_GETHOTITEM
    SendMessage, 0x445, 0, pRB,, ahk_id %ctl%  ; TB_HITTEST
    btn_index := ErrorLevel
    ; Convert btn_index to a signed int, since result may be -1 if no 'hot' item.
    if btn_index > 0x7FFFFFFF
        btn_index := -(~btn_index) - 1
   
   
    if (btn_index > -1)
    {
        ; Get button info.
        SendMessage, 0x417, btn_index, pRB,, ahk_id %ctl%   ; TB_GETBUTTON
   
        VarSetCapacity(btn, 20)
        DllCall("ReadProcessMemory", "Uint", hProc
            , "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
   
        state := NumGet(btn, 8, "UChar")  ; fsState
        pdata := NumGet(btn, 12, "UInt")  ; dwData
       
        ret := DllCall("ReadProcessMemory", "Uint", hProc
            , "Uint", pdata, "UintP", hwnd, "Uint", 4, "Uint", 0)
    } else
        hwnd = 0

       
    DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
    DllCall("CloseHandle", "Uint", hProc)


    ; Negative values indicate seperator items. (abs(btn_index) is the index)
    return btn_index > -1 ? btn_index+1 : 0
}

You could use ~MButton:: instead of MButton:: & Click M, but then the taskbar would be activated whenever you middle-click a button.

Here is another, much simpler method:
Code:
~MButton::
    MouseGetPos,,, win
    ifWinExist, ahk_id %win% ahk_class Shell_TrayWnd
        Send {Click}!{F4}
return

Middle-clicking empty space in the taskbar will probably bring up the shutdown dialog. It might do strange things if you middle-click a tray icon...
Back to top
View user's profile Send private message Visit poster's website
jxerot
Guest





PostPosted: Fri Dec 28, 2007 7:38 pm    Post subject: Reply with quote

thanks!!! Very Happy i think i have it now.. Very Happy thanks.. i will try it tonight. i have windows xp black v6.2 so i think it wil work well.. (whitout the vista problem)

thanks thanks thanks!! you guy's did help me great!!
Back to top
jxerot



Joined: 28 Dec 2007
Posts: 6
Location: holland / netherland

PostPosted: Wed Jan 02, 2008 12:45 pm    Post subject: Reply with quote

one question... i have 2 screens..
this script works on one.. how to make it work on two screens?? i have ultramon for the extra taskbar.

this is the script i used
Code:
mButton::
    if GetMouseTaskButton(hwnd) && hwnd
        WinClose, ahk_id %hwnd%
    else {
        Click M Down
        KeyWait, MButton
        Click M Up
    }
return

; Gets the index+1 of the taskbar button which the mouse is hovering over.
; Returns an empty string if the mouse is not over the taskbar's task toolbar.
;
; Some code and inspiration from Sean's TaskButton.ahk
GetMouseTaskButton(ByRef hwnd)
{
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, win, ctl, 2
    ; Check if hovering over taskbar.
    WinGetClass, cl, ahk_id %win%
    if (cl != "Shell_TrayWnd")
        return
    ; Check if hovering over a Toolbar.
    WinGetClass, cl, ahk_id %ctl%
    if (cl != "ToolbarWindow32")
        return
    ; Check if hovering over task-switching buttons (specific toolbar).
    hParent := DllCall("GetParent", "Uint", ctl)
    WinGetClass, cl, ahk_id %hParent%
    if (cl != "MSTaskSwWClass")
        return

   
    WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd

    hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
    pRB := DllCall("VirtualAllocEx", "Uint", hProc
        , "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)

    VarSetCapacity(pt, 8, 0)
    NumPut(x, pt, 0, "int")
    NumPut(y, pt, 4, "int")
   
    ; Convert screen coords to toolbar-client-area coords.
    DllCall("ScreenToClient", "uint", ctl, "uint", &pt)
   
    ; Write POINT into explorer.exe.
    DllCall("WriteProcessMemory", "uint", hProc, "uint", pRB+0, "uint", &pt, "uint", 8, "uint", 0)

;     SendMessage, 0x447,,,, ahk_id %ctl%  ; TB_GETHOTITEM
    SendMessage, 0x445, 0, pRB,, ahk_id %ctl%  ; TB_HITTEST
    btn_index := ErrorLevel
    ; Convert btn_index to a signed int, since result may be -1 if no 'hot' item.
    if btn_index > 0x7FFFFFFF
        btn_index := -(~btn_index) - 1
   
   
    if (btn_index > -1)
    {
        ; Get button info.
        SendMessage, 0x417, btn_index, pRB,, ahk_id %ctl%   ; TB_GETBUTTON
   
        VarSetCapacity(btn, 20)
        DllCall("ReadProcessMemory", "Uint", hProc
            , "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
   
        state := NumGet(btn, 8, "UChar")  ; fsState
        pdata := NumGet(btn, 12, "UInt")  ; dwData
       
        ret := DllCall("ReadProcessMemory", "Uint", hProc
            , "Uint", pdata, "UintP", hwnd, "Uint", 4, "Uint", 0)
    } else
        hwnd = 0

       
    DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
    DllCall("CloseHandle", "Uint", hProc)


    ; Negative values indicate seperator items. (abs(btn_index) is the index)
    return btn_index > -1 ? btn_index+1 : 0
}

_________________
Back to top
View user's profile Send private message MSN Messenger
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Wed Jan 02, 2008 1:21 pm    Post subject: Reply with quote

jxerot wrote:
i have ultramon for the extra taskbar.
I suspect the Ultramon taskbar doesn't work the same way as the regular taskbar. Try one of the simpler methods, like this script or the last example in my previous post.
Back to top
View user's profile Send private message Visit poster's website
jxerot



Joined: 28 Dec 2007
Posts: 6
Location: holland / netherland

PostPosted: Wed Jan 02, 2008 4:22 pm    Post subject: Reply with quote

it works exactly the same way.. right click close is there (alt - f4 works) etc etc.. think it's something with the coordinates
_________________
Back to top
View user's profile Send private message MSN Messenger
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Wed Jan 02, 2008 7:21 pm    Post subject: Reply with quote

You can make this work with UltraMon, but it will take some editing
e.g. Instead of Shell_TrayWnd use UltraMonDeskTaskBar
e.g. Instead of MSTaskSwWClass use TaskBand

You might be able to add some or's to your if statements
Or find another way around e.g. double up the code Razz
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Thu Jan 03, 2008 1:19 am    Post subject: Reply with quote

@jxerot: I was referring to the way the taskbar internally stores the hwnd associated with the button. Since afaik it is not documented, I see no reason Ultramon would use the same internal structure.

@Mustang: So you've successfully retrieved the hwnd associated with a button...?


You (whoever) could try changing the following lines in GetMouseTaskButton:
Code:
if (cl != "Shell_TrayWnd")
Code:
if (cl != "MSTaskSwWClass")
Code:
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
to these:
Code:
if cl not in Shell_TrayWnd,UltraMonDeskTaskBar
Code:
if cl not in MSTaskSwWClass,TaskBand
Code:
WinGet, pidTaskbar, PID, ahk_id %ctl%
Back to top
View user's profile Send private message Visit poster's website
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Thu Jan 03, 2008 1:46 am    Post subject: Reply with quote

lexikos wrote:
@Mustang: So you've successfully retrieved the hwnd associated with a button...?

Yes
After getting TBBUTTON Structure for the desired button
Then: hWnd = dwData Cool
Back to top
View user's profile Send private message
jxerot



Joined: 28 Dec 2007
Posts: 6
Location: holland / netherland

PostPosted: Thu Jan 03, 2008 5:29 pm    Post subject: Reply with quote

nope doesn't work.. for the second monitor.. Sad to bad! :'(
_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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