隐藏任务栏后调整窗口大小

时间:2015-01-24 12:22:38

标签: autohotkey

当关键字lWin& H时,热键脚本隐藏/显示任务栏:

LWin & h::

if toggle := !toggle

{

WinHide ahk_class Shell_TrayWnd

WinHide Start ahk_class Button

}

else

{

WinShow ahk_class Shell_TrayWnd

WinShow Start ahk_class Button

}
return

脚本来自http://lifehacker.com/taskbar-control-hides-and-unhides-the-windows-taskbar-w-1573974951

的评论

但是当任务栏被隐藏时,占用任务栏的空间无法使用:窗口不会拖动到此区域,新打开的程序不会占用此空间。

是否可以修改脚本以便在隐藏任务栏时整个屏幕区域可用?

3 个答案:

答案 0 :(得分:0)

这是一种将工作区设置为包含任务栏空间的方法。

LWin & h::
if toggle := !toggle
{
    WinHide ahk_class Shell_TrayWnd
    WinHide Start ahk_class Button
    SysGet, Mon, Monitor
    SetWorkArea(MonLeft, MonTop, MonRight, MonBottom)
}
else
{
    WinShow ahk_class Shell_TrayWnd
    WinShow Start ahk_class Button
    SysGet, Mon, MonitorWorkArea
    SetWorkArea(MonLeft, MonTop, MonRight, MonBottom)
}
return

SetWorkArea(left,top,right,bottom)  ; set main monitor work area ; windows are not resized!
{
    VarSetCapacity(area, 16)
    NumPut(left,  area, 0, "UInt") ; left
    NumPut(top,   area, 4, "UInt") ; top
    NumPut(right, area, 8, "UInt") ; right
    NumPut(bottom,area,12, "UInt") ; bottom
    DllCall("SystemParametersInfo", "UInt", 0x2F, "UInt", 0, "UPtr", &area, "UInt", 0) ; SPI_SETWORKAREA
}

希望有所帮助

答案 1 :(得分:0)

我没有使用autohotkey,而是使用此实用程序:

http://www.itsamples.com/taskbar-hider.html

答案 2 :(得分:0)

这似乎有效(仅在Windows7上测试过):

   lWin & h::

;#NoEnv

#NoTrayIcon

;#SingleInstance force

DetectHiddenWindows, Off   ;for IfWinExist

VarSetCapacity( APPBARDATA, 36, 0 )

;------------------------------------------------------------

; Fetch current hidden/showing status



IfWinNotExist, ahk_class Shell_TrayWnd

  TaskbarAndStartToggleState = 0     ;Currently [color=darkred]hidden[/color] (not showing)

Else

  TaskbarAndStartToggleState = 1     ;Currently [color=darkred]non-hidden[/color] (showing)

;------------------------------------------------------------

Gosub +z   ;Toggle the taskbar/SM state

;------------------------------------------------------------

Exit

;------------------------------------------------------------

+z::

 TaskbarAndStartToggleState := Func(TaskbarAndStartToggleState)

Return



Func(TaskbarAndStartToggleState)

{

   Global APPBARDATA



   If TaskbarAndStartToggleState = 0

   {

      NumPut( (ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt" )           ;Enable "Always on top" [color=darkred](& disable auto-hide)[/color]

      DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )



      WinShow ahk_class Shell_TrayWnd

      Return 1            ;Now showing

   }



   If TaskbarAndStartToggleState = 1

   {

      NumPut( ( ABS_AUTOHIDE := 0x1 ), APPBARDATA, 32, "UInt" )            ;Disable "Always on top" [color=darkred](& enable auto-hide to hide Start button)[/color]

      DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )



      WinHide ahk_class Shell_TrayWnd

      ;WinHide ahk_class Shell_TrayWnd   ;[color=darkred]don't need this 2nd one?[/color]

      Return 0            ;Now hidden

   }

}

return

略有修改:

http://www.autohotkey.com/board/topic/25932-trying-to-toggle-autohide-taskbar-with-keystroke-in-vista/page-2

更新:使用多个桌面时,此脚本会导致意外行为。任务栏被隐藏但是当切换到恢复时,只显示Windows图标。隐藏任务栏并取消隐藏任务栏属性中的任务栏似乎可以解决此问题,但如果使用多个桌面,则会使脚本无法使用。