Code : Tout sélectionner
#include <File.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}","_Exit")
;nom de la GUI
$Elco = "ElcosMenu"
;définition du fichier de configuration .skin
$Skn = "GTA_El2_DFX5.skin"
$RRSkinPath = @ScriptDir&"\"
Global $hGUI2, $Skin
$Trans = 255 ;values ready for button's creation
$Xpos = 0 ;default x position (screen's center)
$YPos = 0 ;default y position (screen's center)
$UpdateSlidersDelay = 2000 ;update delay for the slider (in ms)
AutoItWinSetTitle($Elco)
_GDIPlus_Startup()
If Not FileExists($RRSkinPath & $Skn) Then
MsgBox(64,"Skin file error"," The skin file doesn't exist"&@crlf&@crlf&"Please, check your .skin file name !!!")
Exit
EndIf
;mise en tableau du fichier de configuration .skin
_FileReadToArray($RRSkinPath & $Skn, $Skin)
;nom du fichier image pour la GUI
$Bknd = "gta_el2_dfx5_off.png"
;lecture de la taille de l'image .png
$Dim = _Get_Dimensions($RRSkinPath & $Bknd)
$Width = $Dim[0]
$Height = $Dim[1]
$hGUI2 = GUICreate($Elco, $Width, $Height, $Xpos, $YPos, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
$hImage = _GDIPlus_ImageLoadFromFile($RRSkinPath&$Bknd)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
_SetBitMap($hGUI2, $hImage, $Trans, $Width, $Height) ;
if $Xpos <> -1 And $YPos <> -1 Then ;set the position, if is set not to be centered.
WinMove($hGUI2, "", $Xpos, $YPos)
$MoveFirst = False ;no move has been used
EndIf
GUISetState()
;Création des sliders
Dim $SliderID[$Skin[0] + 1]
for $Ln = 1 to $Skin[0]
if StringLeft($Skin[$Ln], 1) = "S" Then
$SlidersIsON = 1
$Var = StringSplit($Skin[$Ln], ",")
;format type is: S01,148,162,120,29,62,103,70,20,H,01," ",015,"GPSSIGNAL","Gps Signal"
$NameSlider = StringReplace($Var[14],'"','')
for $Lm = 1 to $Skin[0]
if StringLeft($Skin[$Lm], 1) = "Y" Then;format is :Y01,"SignalSliderImages\slider_*.gif"
$Var2 = StringReplace(StringReplace(StringReplace($Skin[$Lm],'"',''),"\"," "),","," ")
$Var3 = StringSplit($Var2," ")
If $Var3[1] = "Y"&$Var[11] Then
$PicturesSlider = $RRSkinPath&$Var3[2]&"\"&StringReplace($Var3[3],"*","0");force les sliders avec l'image 0.png au démarrage
EndIf
EndIf
Next
[color=#FF0000]; $SliderID[$Ln] = $NameSlider[/color]
$Var4 = StringSplit($PicturesSlider,".")
If $Var4[2] <> "png" Then
_ImageConvert($Var4[1]&"."&$Var4[2], $Var4[1]&".png",$Var[4],$Var[5]);conversion de l'image si 'slider_*.gif' au lieu de 'slider_*.png'
$PicturesSlider = $Var4[1]&".png"
EndIf
$SLD_hImage = _ImageResize($PicturesSlider, $Var[4] ,$Var[5])
$SliderID[$Ln] = GUICreate($NameSlider, $Var[4] ,$Var[5], $Var[2] ,$Var[3], $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI2)
$SLD_bitmapID = _SetBitMap($SliderID[$Ln], $SLD_hImage, 255, $Var[4] ,$Var[5])
GUISetState()
WinSetOnTop($SliderID[$Ln], "", 1)
EndIf
Next
AdlibRegister("UpdateSliders",$UpdateSlidersDelay)
While 1
for $i = 0 to 65535 step Round(65535/20,0)
$ValueSlider = $i
sleep(500)
Next
Wend
Func UpdateSliders();uniquement pour slider de type $MYVAR$
for $Ln = 1 to $Skin[0]
if StringLeft($Skin[$Ln], 1) = "S" Then
$Var = StringSplit($Skin[$Ln], ",")
;format type is: S01,148,162,120,29,62,103,70,20,H,01," ",015,"$GPXSLIDER1$","Gps Signal"
$NameSlider = StringReplace($Var[14],'"','')
for $Lm = 1 to $Skin[0]
if StringLeft($Skin[$Lm], 1) = "Y" Then;format is :Y01,"SignalSliderImages\slider_*.gif"
$Var2 = StringReplace(StringReplace(StringReplace(StringReplace($Skin[$Lm],'"',''),"\"," "),","," "),"."," ")
$Var3 = StringSplit($Var2," ")
If $Var3[1] = "Y"&$Var[11] Then
If StringInStr($NameSlider,"$") Then
;$ValueSlider = 15000
Else
;$ValueSlider = 30000
EndIf
$PicturesSlider = $RRSkinPath&$Var3[2]&"\slider_"&Round($ValueSlider/65535*20,0)&"."&$Var3[4]
EndIf
EndIf
Next
[color=#FF0000]; $SliderID[$Ln] = $NameSlider[/color]
[color=#408000]GUIDelete($SliderID[$Ln])[/color]
$Var4 = StringSplit($PicturesSlider,".")
If $Var4[2] <> "png" Then
_ImageConvert($Var4[1]&"."&$Var4[2], $Var4[1]&".png",$Var[4],$Var[5]);conversion de l'image si 'slider_*.gif' au lieu de 'slider_*.png'
$PicturesSlider = $Var4[1]&".png"
EndIf
$SDL_hImage = _ImageResize($PicturesSlider, $Var[4] ,$Var[5])
$SliderID[$Ln] = GUICreate($NameSlider, $Var[4] ,$Var[5], $Var[2] ,$Var[3], $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI2)
$SLD_bitmapID = _SetBitMap($SliderID[$Ln], $SDL_hImage, 255, $Var[4] ,$Var[5])
GUISetState()
WinSetOnTop($SliderID[$Ln], "", 1)
EndIf
Next
EndFunc
; =====================================================================================================
; Resize un PNG file
; =====================================================================================================
Func _ImageResize($sInImage, $newW, $newH)
Local $oldImage, $GC, $newBmp, $newGC
_GDIPlus_Startup()
$oldImage = _GDIPlus_ImageLoadFromFile($sInImage)
$GC = _GDIPlus_ImageGetGraphicsContext($oldImage)
$newBmp = _GDIPlus_BitmapCreateFromGraphics($newW, $newH, $GC)
$newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)
_GDIPlus_GraphicsDrawImageRect($newGC, $oldImage, 0, 0, $newW, $newH)
_GDIPlus_GraphicsDispose($GC)
_GDIPlus_GraphicsDispose($newGC)
_GDIPlus_ImageDispose($oldImage)
Return $newBmp ;
EndFunc ;==>_ImageResize
; #FUNCTION# =========================================================================================
; Name...........: _ImageConvert
; Description....: Resize an image and optionally convert it to the format you want.
; Syntax.........: _ImageConvert($sInImage, $sOutImage, $iW, $iH)
; Parameters ....: $sInImage - Full path to the image to resize / convert.
; In types: *.bmp, *.gif, *.ico, *.jpg, *.jpeg, *.png, *.tif, *.tiff
; $sOutImage - Full path where to save the resized / converted image.
; Out types: *.bmp, *.gif, *.jpg, *.jpeg, *.png, *.tif, *.tiff
; $iW - Width to resize image to.
; $iH - Height to resize image to.
; Return values .: Success - Return 1 and @error 0
; Failure - Return 0 and @error 1~5
; @error 1 = In File does not exist
; @error 2 = In File format not supported
; @error 3 = Out File path does not exist
; @error 4 = Out file format not supported
; @error 5 = Resize Width or Height not an integer
; Author ........: smashly
; ====================================================================================================
Func _ImageConvert($sInImage, $sOutImage, $iW, $iH)
Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"
If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
$sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)
;OutFile path, to use later on.
$sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
If Not FileExists($sOP) Then Return SetError(3, 0, 0)
;OutFile name, to use later on.
$sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
;OutFile extension , to use for the encoder later on.
$Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)
;If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0);la fonction IsInt pose une problème !
; WinAPI to create blank bitmap at the width and height to put your resized image on.
$hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
;Start GDIPlus
_GDIPlus_Startup()
;Get the handle of blank bitmap you created above as an image
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
;Load the image you want to resize.
$hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
;Get the graphic context of the blank bitmap
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
;Draw the loaded image onto the blank bitmap at the size you want
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)
;Get the encoder of to save the resized image in the format you want.
$CLSID = _GDIPlus_EncodersGetCLSID($Ext)
;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
;Do
; $i += 1
;Until (Not FileExists($sOP & $i & "_" & $sOF))
;Prefix the number to the begining of the output filename
;$sOutImage = $sOP & $i & "_" & $sOF
$sOutImage = $sOP & $sOF
;Save the new resized image.
_GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
;Clean up and shutdown GDIPlus.
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Return SetError(0, 0, 1)
EndFunc ;==>_ImageConvert
; =====================================================================================================
; SetBitMap
; =====================================================================================================
Func _SetBitmap($hGUI, $hImage, $LnOpacity, $n_width, $n_height)
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", $n_width)
DllStructSetData($tSize, "Y", $n_height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $LnOpacity)
DllStructSetData($tBlend, "Format", 1)
_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
;======================================================================================================
;getting graphic size.
;======================================================================================================
Func _Get_Dimensions($sFileName)
Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
Local $aDimensions[2] = [ $iWidth, $iHeight ]
Return $aDimensions
EndFunc ;_GetDimensions
Func _Exit()
Exit
EndFunc