Code : Tout sélectionner
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Sound.au3>
#include <StaticConstants.au3>
Opt("MustDeclareVars", 0)
Opt("GUIOnEventMode",1)
Global Const $AC_SRC_ALPHA = 1
Global $launchDir = @DesktopDir
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\gui3.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$GUI = GUICreate("AutoitKeygen", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
SetBitmap($GUI, $hImage, 0)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
For $i = 0 To 255 Step 10
SetBitmap($GUI, $hImage, $i)
Next
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUICtrlSetState(-1,$GUI_DISABLE)
; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width , $height)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUICtrlSetState(-1, $GUI_DISABLE)
$inp_Login = GUICtrlCreateInput("",68,225,350,20,$WS_EX_TOPMOST)
GUICtrlSetState(-1,$GUI_ENABLE)
$inp_serial = GUICtrlCreateInput("",68,310,350,20)
GUICtrlSetState(-1,$GUI_ENABLE)
$but_about = GUICtrlCreateLabel("", 67, 60, 30, 30, -1,$SS_NOTIFY)
GUICtrlSetOnEvent($but_about,"_Exit")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$but_exit = GUICtrlCreateLabel("", 387, 60, 30, 30, -1)
GUICtrlSetBkColor($but_exit, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($but_exit,"_Exit")
$but_genere = GUICtrlCreateLabel("", 150, 390, 200, 65, -1)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($but_genere,"__Genere")
GUISetState()
While 1
Global $vSound = _SoundOpen("sound.mp3")
Do
_SoundPlay($vSound)
Sleep(1000)
Until $vSound = 100
WEnd
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
Func __Genere()
MsgBox(0,"","Vous avez cliqué sur générer")
EndFunc
Func _Exit()
Dim $vSound, $controlGui, $GUI, $hImage, $i
GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step -10
SetBitmap($GUI, $hImage, $i)
Next
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
_SoundClose($vSound)
Exit
EndFunc