4501
Post New Requests Here / Re: IDEA: middle click on desktop to get quick launch or 'start menu'
« Last post by MilesAhead on April 11, 2012, 07:50 PM »I don't have multiple monitors. But I took the simpler approach of just moving the mouse to the Start Orb and clicking. It should calculate the correct position to click no matter what edge the Taskbar is on.
As it is the middle mouse click will only fire if Desktop is the active window. You may have to left click the desktop first to make sure it's active. Or as noted in the comments, you may comment out that limitation. A middle click anywhere would trigger it.
edit: I've modified the calculations. I pasted in the new version. Instead of adjusting x and y from the work area outward I changed the calculation from screen res inward. That way it should still work even if the work area has been shrunk via an Adjust Work Area type utility.
The code makes the assumption that Taskbar AutoHide is disabled. Otherwise the Get Work Area API won't tell you which edge has the Taskbar. Some other fancier detection would be required. But this is a pretty good starting point for step-wise enhancement.
As it is the middle mouse click will only fire if Desktop is the active window. You may have to left click the desktop first to make sure it's active. Or as noted in the comments, you may comment out that limitation. A middle click anywhere would trigger it.
edit: I've modified the calculations. I pasted in the new version. Instead of adjusting x and y from the work area outward I changed the calculation from screen res inward. That way it should still work even if the work area has been shrunk via an Adjust Work Area type utility.
The code makes the assumption that Taskbar AutoHide is disabled. Otherwise the Get Work Area API won't tell you which edge has the Taskbar. Some other fancier detection would be required. But this is a pretty good starting point for step-wise enhancement.
#SingleInstance ignore
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
x := 0
y := 0
_EmptyWorkingSet()
; DesktopGroup limits Middle Mouse Click to firing
; when the Desktop is the active window.
; comment out the next 3 lines to make hotkey global
GroupAdd,DesktopGroup, ahk_class Progman
GroupAdd,DesktopGroup, ahk_class WorkerW
#IfWinActive ahk_group DesktopGroup
MButton::
if !_StartButtonXY(x, y)
return
MouseClick, left, %x%, %y%
return
;------- helper functions --------
_StartButtonXY(ByRef xpos, ByRef ypos)
{
wl := 0
wt := 0
wr := 0
wb := 0
if !_GetWorkArea(wl, wt, wr, wb)
return 0
if (wl > 0) || (wt > 0)
{
xpos := 30
ypos := 30
}
else if (wr < A_ScreenWidth)
{
xpos := A_ScreenWidth - 30
ypos := 30
}
else
{
xpos := 30
ypos := A_ScreenHeight - 30
}
return 1
}
_GetWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom)
{
VarSetCapacity(work_area,16,0)
success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &work_area, "uint", 0 )
if success =
{
return 0
}
left := NumGet(work_area,0)
top := NumGet(work_area,4)
Right := NumGet(work_area,8)
Bottom := NumGet(work_area,12)
return 1
}
_EmptyWorkingSet()
{
return DllCall("psapi.dll\EmptyWorkingSet", "UInt", -1)
}
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
x := 0
y := 0
_EmptyWorkingSet()
; DesktopGroup limits Middle Mouse Click to firing
; when the Desktop is the active window.
; comment out the next 3 lines to make hotkey global
GroupAdd,DesktopGroup, ahk_class Progman
GroupAdd,DesktopGroup, ahk_class WorkerW
#IfWinActive ahk_group DesktopGroup
MButton::
if !_StartButtonXY(x, y)
return
MouseClick, left, %x%, %y%
return
;------- helper functions --------
_StartButtonXY(ByRef xpos, ByRef ypos)
{
wl := 0
wt := 0
wr := 0
wb := 0
if !_GetWorkArea(wl, wt, wr, wb)
return 0
if (wl > 0) || (wt > 0)
{
xpos := 30
ypos := 30
}
else if (wr < A_ScreenWidth)
{
xpos := A_ScreenWidth - 30
ypos := 30
}
else
{
xpos := 30
ypos := A_ScreenHeight - 30
}
return 1
}
_GetWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom)
{
VarSetCapacity(work_area,16,0)
success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &work_area, "uint", 0 )
if success =
{
return 0
}
left := NumGet(work_area,0)
top := NumGet(work_area,4)
Right := NumGet(work_area,8)
Bottom := NumGet(work_area,12)
return 1
}
_EmptyWorkingSet()
{
return DllCall("psapi.dll\EmptyWorkingSet", "UInt", -1)
}

Recent Posts




