Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autohotkey 隐藏任务栏后调整窗口大小_Autohotkey - Fatal编程技术网

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

Autohotkey 隐藏任务栏后调整窗口大小,autohotkey,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 脚本取自以下位置的注释: 但当任务栏被隐藏时,占据任务栏的空

设置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
脚本取自以下位置的注释:

但当任务栏被隐藏时,占据任务栏的空间将不可用:窗口不会拖动到此区域,新打开的程序不会占据此空间


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

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

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
}

希望它有帮助

而不是使用自动热键我使用此实用程序:

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

稍微修改自:


更新:使用多个桌面时,此脚本会导致意外行为。任务栏是隐藏的,但切换到仅还原windows时,将显示图标。在任务栏属性中隐藏任务栏和取消隐藏任务栏似乎可以解决此问题,但如果使用多个桌面,则会使脚本无法使用。

::谢谢,但当我使用脚本隐藏任务栏时,任务栏占据的区域无法被其他程序使用。糟糕!我在win7上使用ahk 1.1+32位unicode很好
   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