Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WindowsConstants.au3>
- #include <GUIConstants.au3>
- #include <GDIPlus.au3>
- #include <WinAPI.au3>
- #include <Misc.au3>
- ; - Author: name22 (www.autoit.de)
- ; Warning! This script needs a specific image to function (or you could make your own image of a frame and adjust the coordinates in _DrawBG). Press F10 to display the window.
- Opt("GUIOnEventMode", 1)
- Global Const $nPiHalf = ACos(-1) / 2
- Global $vU32dll = DllOpen("user32.dll")
- ;###-v-SETTINGS-v-###
- $iGUIWidth = 600 ;Width of the GUI
- $iGUIHeight = 200 ;Height of the GUI
- $iDurationON = 600 ;The time it will take for the window to appear[in ms]
- $iDurationOFF = 400 ;The time it will take for the window to disappear [in ms]
- ;###-^-SETTINGS-^-###
- $tSize = DllStructCreate($tagSIZE)
- $pSize = DllStructGetPtr($tSize)
- DllStructSetData($tSize, "X", $iGUIWidth)
- DllStructSetData($tSize, "Y", $iGUIHeight)
- $tDest = DllStructCreate($tagSIZE)
- $pDest = DllStructGetPtr($tDest)
- DllStructSetData($tDest, "X", 0)
- DllStructSetData($tDest, "Y", 0)
- $tSource = DllStructCreate($tagPOINT)
- $pSource = DllStructGetPtr($tSource)
- $tBlend = DllStructCreate($tagBLENDFUNCTION)
- $pBlend = DllStructGetPtr($tBlend)
- DllStructSetData($tBlend, "Alpha", 0)
- DllStructSetData($tBlend, "Format", 1)
- $hMain = GUICreate("Example by name22", $iGUIWidth, $iGUIHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
- GUISetState()
- $hDC_Main = _WinAPI_GetDC($hMain)
- $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Main)
- $hBitmap_Buffer = _WinAPI_CreateCompatibleBitmap($hDC_Main, $iGUIWidth, $iGUIHeight)
- _WinAPI_SelectObject($hDC_Buffer, $hBitmap_Buffer)
- _GDIPlus_Startup()
- $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
- _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
- $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
- $hImage_BG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\bg.png")
- $aBG_Glass = _CutImage($hImage_BG)
- GUIRegisterMsg($WM_PAINT, "_RedrawGUI")
- GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hMain)
- OnAutoItExitRegister("_Shutdown")
- HotKeySet("{F10}", "_Show")
- While Sleep(1000)
- WEnd
- Func _Show()
- HotKeySet("{F10}")
- Local $iTimeOffset = 0, $iTime, $vTimer = TimerInit()
- GUISetState(@SW_SHOW, $hMain)
- While _IsPressed("79", $vU32dll)
- $iTime = Floor(TimerDiff($vTimer))
- If $iTime < $iDurationON Then
- $nFrac = Sin($iTime / $iDurationON * $nPiHalf)
- $iWidthTmp = $nFrac * $iGUIWidth
- $iHeightTmp = $nFrac * $iGUIHeight
- $iAlphaTmp = Floor($nFrac * 0xFF)
- _GUISettings($iWidthTmp, $iHeightTmp, @DesktopWidth / 2 - $iWidthTmp / 2, @DesktopHeight / 2 - $iHeightTmp / 2, $iAlphaTmp)
- EndIf
- Sleep(10)
- WEnd
- HotKeySet("{F10}", "_Show")
- If $iTime <= $iDurationON Then
- $iTimeOffset = $iDurationOFF - $iTime / $iDurationON * $iDurationOFF
- EndIf
- $iTime = 0
- $vTimer = TimerInit()
- While $iTime <= $iDurationOFF
- $iTime = Floor(TimerDiff($vTimer)) + $iTimeOffset
- $nFrac = Sin((1 - $iTime / $iDurationOFF) * $nPiHalf)
- $iWidthTmp = $nFrac * $iGUIWidth
- $iHeightTmp = $nFrac * $iGUIHeight
- $iAlphaTmp = Floor($nFrac * 0xFF)
- _GUISettings($iWidthTmp, $iHeightTmp, @DesktopWidth / 2 - $iWidthTmp / 2, @DesktopHeight / 2 - $iHeightTmp / 2, $iAlphaTmp)
- Sleep(10)
- WEnd
- _GUISettings(0, 0, 0, 0, 0)
- GUISetState(@SW_HIDE, $hMain)
- EndFunc
- Func _GUISettings($iWidth, $iHeight, $iX = -1, $iY = -1, $iAlpha = 255)
- DllStructSetData($tBlend, "Alpha", $iAlpha)
- DllStructSetData($tSize, "X", $iWidth)
- DllStructSetData($tSize, "Y", $iHeight)
- _WinAPI_DeleteObject($hBitmap_Buffer)
- _GDIPlus_GraphicsDispose($hGraphics)
- $hBitmap_Buffer = _WinAPI_CreateCompatibleBitmap($hDC_Main, $iWidth, $iHeight)
- _WinAPI_SelectObject($hDC_Buffer, $hBitmap_Buffer)
- $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
- _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
- _GDIPlus_GraphicsClear($hGraphics, 0)
- _DrawBG($aBG_Glass, $iWidth, $iHeight)
- If $iX = -1 And $iY = -1 Then
- _RedrawGUI()
- Else
- DllStructSetData($tDest, "X", Floor($iX))
- DllStructSetData($tDest, "Y", Floor($iY))
- _WinAPI_UpdateLayeredWindow($hMain, $hDC_Main, $pDest, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
- EndIf
- EndFunc
- Func _DrawBG($aBG, $iWidth, $iHeight)
- _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 0)
- _GDIPlus_GraphicsSetInterpolationMode($hGraphics, 5)
- _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics, 2)
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[0], 0, 0, 20, 20) ;upper left corner
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[1], 0, $iHeight - 17, 20, 17) ;lower left corner
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[2], $iWidth - 21, 0, 21, 20) ;upper right corner
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[3], $iWidth - 21, $iHeight - 17, 21, 17) ;lower right corner
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[4], 0, 20, 20, $iHeight - 37) ;left edge
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[5], $iWidth - 21, 20, 21, $iHeight - 37) ;right edge
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[6], 20, 0, $iWidth - 41, 20) ;upper edge
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[7], 20, $iHeight - 17, $iWidth - 41, 17) ;lower edge
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $aBG[8], 20, 20, $iWidth - 41, $iHeight - 37) ;center
- _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
- EndFunc
- Func _CutImage($hImage) ;Splits the image into 9 parts that can be individually scaled (prevents quality loss).
- Local $aReturn[9]
- $aReturn[0] = _GDIPlus_BitmapCloneArea($hImage, 0, 0, 20, 20, $GDIP_PXF32ARGB) ;upper left corner
- $aReturn[1] = _GDIPlus_BitmapCloneArea($hImage, 0, 87, 20, 17, $GDIP_PXF32ARGB) ;lower left corner
- $aReturn[2] = _GDIPlus_BitmapCloneArea($hImage, 86, 0, 21, 20, $GDIP_PXF32ARGB) ;upper right corner
- $aReturn[3] = _GDIPlus_BitmapCloneArea($hImage, 86, 87, 21, 17, $GDIP_PXF32ARGB) ;lower right corner
- $aReturn[4] = _GDIPlus_BitmapCloneArea($hImage, 0, 20, 20, 67, $GDIP_PXF32ARGB) ;left edge
- $aReturn[5] = _GDIPlus_BitmapCloneArea($hImage, 86, 20, 21, 67, $GDIP_PXF32ARGB) ;right edge
- $aReturn[6] = _GDIPlus_BitmapCloneArea($hImage, 20, 0, 66, 20, $GDIP_PXF32ARGB) ;upper edge
- $aReturn[7] = _GDIPlus_BitmapCloneArea($hImage, 20, 87, 66, 17, $GDIP_PXF32ARGB) ;lower edge
- $aReturn[8] = _GDIPlus_BitmapCloneArea($hImage, 20, 20, 66, 67, $GDIP_PXF32ARGB) ;center
- Return $aReturn
- EndFunc
- Func _RedrawGUI()
- _WinAPI_UpdateLayeredWindow($hMain, $hDC_Main, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, $ULW_ALPHA)
- EndFunc
- Func _Close()
- Exit
- EndFunc ;==>_Close
- Func _Shutdown()
- _WinAPI_ReleaseDC($hMain, $hDC_Main)
- _WinAPI_DeleteDC($hDC_Buffer)
- _WinAPI_DeleteObject($hBitmap_Buffer)
- _GDIPlus_GraphicsDispose($hGraphics)
- _GDIPlus_ImageDispose($hImage_BG)
- For $i = 0 To 8
- _GDIPlus_BitmapDispose($aBG_Glass[$i])
- Next
- _GDIPlus_BrushDispose($hBrush)
- _GDIPlus_Shutdown()
- EndFunc ;==>_Shutdown
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_GraphicsSetPixelOffsetMode
- ; Description ...: Sets the pixel offset mode of a Graphics object
- ; Syntax.........: _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics, $iPixelOffsetMode)
- ; Parameters ....: $hGraphics - Pointer to a Graphics object
- ; $iPixelOffsetMode - Pixel offset mode:
- ; |0,1,3 - Pixel centers have integer coordinates
- ; |2,4 - Pixel centers have coordinates that are half way between integer values (i.e. 0.5, 20, 105.5, etc...)
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: _GDIPlus_GraphicsGetPixelOffsetMode
- ; Link ..........; @@MsdnLink@@ GdipSetPixelOffsetMode
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics, $iPixelOffsetMode)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGraphics, "int", $iPixelOffsetMode)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_GraphicsSetPixelOffsetMode
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_GraphicsSetInterpolationMode
- ; Description ...: Sets the interpolation mode of a Graphics object
- ; Syntax.........: _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode)
- ; Parameters ....: $hGraphics - Pointer to a Graphics object
- ; $iInterpolationMode - Interpolation mode:
- ; |0 - Default interpolation mode
- ; |1 - Low-quality mode
- ; |2 - High-quality mode
- ; |3 - Bilinear interpolation. No prefiltering is done
- ; |4 - Bicubic interpolation. No prefiltering is done
- ; |5 - Nearest-neighbor interpolation
- ; |6 - High-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking
- ; |7 - High-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: The interpolation mode determines the algorithm that is used when images are scaled or rotated
- ; Related .......: _GDIPlus_GraphicsGetInterpolationMode
- ; Link ..........; @@MsdnLink@@ GdipSetInterpolationMode
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphics, "int", $iInterpolationMode)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement