 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jxerot Guest
|
Posted: Thu Dec 27, 2007 10:39 pm Post subject: Scroll klik --- close windows @ taskbar |
|
|
hello,
can any one make me a script??
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!!!  |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Fri Dec 28, 2007 12:29 am Post subject: |
|
|
| 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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Fri Dec 28, 2007 12:36 am Post subject: |
|
|
i think he wants to middle click the taskbar button to close the window. _________________
(Common Answers) |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Fri Dec 28, 2007 12:52 am Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Fri Dec 28, 2007 5:14 am Post subject: |
|
|
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. _________________
(Common Answers) |
|
| Back to top |
|
 |
jxerot Guest
|
Posted: Fri Dec 28, 2007 12:20 pm Post subject: |
|
|
thanks for the help..!! and sorry for my bad english.
uu how to explane this..
print screen!
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
|
Posted: Fri Dec 28, 2007 1:10 pm Post subject: |
|
|
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.)
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 |
|
 |
jxerot Guest
|
Posted: Fri Dec 28, 2007 7:38 pm Post subject: |
|
|
thanks!!! i think i have it now.. 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
|
Posted: Wed Jan 02, 2008 12:45 pm Post subject: |
|
|
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 |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Wed Jan 02, 2008 1:21 pm Post subject: |
|
|
| 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 |
|
 |
jxerot
Joined: 28 Dec 2007 Posts: 6 Location: holland / netherland
|
Posted: Wed Jan 02, 2008 4:22 pm Post subject: |
|
|
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 |
|
 |
Mustang
Joined: 17 May 2007 Posts: 421 Location: England
|
Posted: Wed Jan 02, 2008 7:21 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Thu Jan 03, 2008 1:19 am Post subject: |
|
|
@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 |
|
 |
Mustang
Joined: 17 May 2007 Posts: 421 Location: England
|
Posted: Thu Jan 03, 2008 1:46 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
jxerot
Joined: 28 Dec 2007 Posts: 6 Location: holland / netherland
|
Posted: Thu Jan 03, 2008 5:29 pm Post subject: |
|
|
nope doesn't work.. for the second monitor.. to bad! :'( _________________
 |
|
| 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
|