如何使用AutoIt将GUI设置为Aero Glass GUI?

时间:2019-02-13 18:28:54

标签: user-interface autoit aero-glass

如何为Autoit GUI获得Aero Glass效果?

我正在玩AutoIt,以增加我对GUI知识的了解。通常,我只是在不使用GUI的情况下创建脚本,但是当我开始使用时,我希望有一个漂亮的areo glass GUI。

我已经尝试过 WinSetTrans ,但这并不是我想要的。它看起来应该更像下面的图片。

Aero Glass Example

我当前的代码是:

#include <GUIConstants.au3>

$iWidthGui = 450
$iHeightGui = 300

$hGui = GUICreate("Glass GUI", $iWidthGui, $iHeightGui, -1, -1, -1, $WS_EX_TOPMOST)
$cExit = GUICtrlCreateButton("Exit", $iWidthGui / 2 - 50, $iHeightGui / 2 - 15, 100, 30)
GUISetState( @SW_SHOW )

WinSetTrans($hGui, "", 180)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit
            GUIDelete($hGui)
            ExitLoop
    EndSwitch
WEnd

Autoit可以吗?我该怎么办?

1 个答案:

答案 0 :(得分:1)

是的,有可能。这至少应该在Windows 7上有效。我无法在Windows 10计算机上测试脚本。

改进的代码:

#include-once
#include <GUIConstants.au3>

Global $iWidthGui  = 450
Global $iHeightGui = 300

Global $hGui  = GUICreate("Glass GUI", $iWidthGui, $iHeightGui, -1, -1, -1, $WS_EX_TOPMOST)
Global $cExit = GUICtrlCreateButton("Exit", $iWidthGui / 2 - 50, $iHeightGui / 2 - 15, 100, 30)
GUISetState( @SW_SHOW, $hGui )

Func _aeroGlassEffect( $hWnd, $iLeft = @DesktopWidth, $iRight = @DesktopWidth, $iTop = @DesktopWidth, $iBottom = @DesktopWidth )
    $hStruct = DllStructCreate( 'int left; int right; int height; int bottom;' )
    DllStructSetData( $hStruct, 'left', $iLeft )
    DllStructSetData( $hStruct, 'right', $iRight )
    DllStructSetData( $hStruct, 'height', $iTop )
    DllStructSetData( $hStruct, 'bottom', $iBottom )
    GUISetBkColor( '0x000000' )
    Return DllCall( 'dwmapi.dll', 'int', 'DwmExtendFrameIntoClientArea', 'hWnd', $hWnd, 'ptr', DllStructGetPtr( $hStruct ) )
EndFunc

_aeroGlassEffect( $hGui )

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit
            GUIDelete($hGui)
            ExitLoop
    EndSwitch
WEnd

我将WinSetTrans()切换为_aeroGlassEffect()。您可以更改功能参数$iLeft, $iRight, $iTop, $iBottom