AutoHotkey Community

It is currently May 26th, 2012, 1:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: December 27th, 2007, 11:39 pm 
hello,

can any one make me a script?? :oops: :oops:
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!!! :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 1:29 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 1:36 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
i think he wants to middle click the taskbar button to close the window.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 1:52 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 6:14 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
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
:?:

I seem to remember it did something with the taskbar.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 1:20 pm 
thanks for the help..!! and sorry for my bad english. :(

uu how to explane this..
print screen! :D

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)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 2:10 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.) :roll:
engunneer wrote:
I think it's doable, I just have no idea how. maybe adapting http://www.autohotkey.com/forum/viewtopic.php?t=22763
:?:

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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 8:38 pm 
thanks!!! :D i think i have it now.. :D 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!!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2008, 1:45 pm 
Offline

Joined: December 28th, 2007, 8:52 pm
Posts: 6
Location: holland / netherland
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
}

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2008, 2:21 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2008, 5:22 pm 
Offline

Joined: December 28th, 2007, 8:52 pm
Posts: 6
Location: holland / netherland
it works exactly the same way.. right click close is there (alt - f4 works) etc etc.. think it's something with the coordinates

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2008, 8:21 pm 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
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 :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2008, 2:19 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
@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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2008, 2:46 am 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
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 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2008, 6:29 pm 
Offline

Joined: December 28th, 2007, 8:52 pm
Posts: 6
Location: holland / netherland
nope doesn't work.. for the second monitor.. :( to bad! :'(

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group