如何为我的Autoit GUI获得Aero Glass效果?
我正在玩AutoIt以增加我对GUI内容的了解。通常我只是在不使用GUI的情况下创建脚本,但是当我刚开始使用时,我希望有一个漂亮的玻璃GUI。
我已经尝试过WinSetTrans,但这不是我想要的。它应该看起来更像下面的图像。
我目前的代码是:
#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?我怎样才能做到这一点?
对的,这是可能的。这应该至少适用于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
。