Code : Tout sélectionner
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <File.au3>
Opt("WinTitleMatchMode", 3)
$hGUI2 = GUICreate("OverLayMenu", 200, 200, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST"); déplacement du menu possible
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN");test if the left mouse button click on an Indicator
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\GTA_MenuV_off.png")
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
$w = _GDIPlus_ImageGetWidth($hImage)
$h = _GDIPlus_ImageGetHeight($hImage)
_SetBitMap($hGUI2, $hImage, 255, $w, $h)
GUISetState()
;définition des indicators comme boutons
Dim $Indicator[1][1][1]
$NumInd = ""
$Indicator[0][0][0] = ""
Dim $Skin, $Xpos, $Height, $Width, $Height, $Var, $Blink, $GUI
_FileReadToArray(@ScriptDir & "\liste.txt", $Skin)
if @error then Exit
Dim $LogoID[$Skin[0] + 1]
for $Ln = 1 to $Skin[0]
if StringLeft($Skin[$Ln], 2) = "I," Then ;indicators
$Var = StringSplit($Skin[$Ln], ",")
If StringInStr($Var[9],"_") Then
$Logo = StringSplit(StringReplace($Var[9],'"',''),"_")
$LogoID[$Ln] = $Logo[1]
$Ind = "_01"
$Logo = $LogoID[$Ln]&$Ind&".png"
Else
$Logo = StringReplace($Var[9],'"','')
$LogoID[$Ln] = $Logo
$Ind = ""
$Logo = $LogoID[$Ln]&$Ind
EndIf
$Speed = 1500;vitesse de clignotement en ms
If $Var[7] <> "" and $Var[8] <> "" Then
$IndBlink =1
EndIf
; MsgBox(0,"",$Logo)
MySplash($Logo,@ScriptDir&"\"&$Logo, $Speed, $IndBlink, $Var[2] ,$Var[3], $Var[4] ,$Var[5])
EndIf
Next
While 1
$msg = GUIGetMsg()
Sleep(100)
WEnd
;======================================================================================================
; Build a Gui for each indicator
;======================================================================================================
Func MySplash($LnndName, $Path_Logo, $Time_Splash, $Blink, $Xlogo, $Ylogo, $newW, $newH)
$GUI = GUICreate($LnndName, $newW, $newH, $Xlogo, $Ylogo, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI2)
$hImage = _ImageResize($Path_Logo, $newW, $newH)
$bitmapID = _SetBitMap($GUI, $hImage, 255, $newW, $newH)
GUISetState()
WinSetOnTop($GUI, "", 1)
EndFunc ;==>MySplash
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
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
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $LnMsg, $LnwParam, $LnlParam)
If ($hWnd = $hGUI2) And ($LnMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
;======================================================================================================
;Test if the mouse click on a gui of an indicator and test if the handel is the same as the gui clicked
;======================================================================================================
Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
; msgbox(0,"",$hWnd&@crlf&$iMsg&@crlf&$wParam&@crlf&$lParam,2)
$var = WinList()
For $i = 1 to $var[0][0]
If $var[$i][0] <> "" Then
If $var[$i][1] = $hWnd Then
For $Ln = 1 to $Skin[0]
If StringLeft($Skin[$Ln], 2) = "I," Then
$Var2 = StringSplit($Skin[$Ln], ",")
$Ind = "_01"
$Logo2 = StringReplace(StringReplace($Var2[9],'"',''),"_*.png",$Ind&".png")
$CMDtoExecute = StringReplace($Var2[6],'"','')
; MsgBox(0, "Details",$Logo2,2)
If $Logo2 = $var[$i][0] Then
; MsgBox(0, "Details", "I click on the logo : " & $var[$i][0],2)
MsgBox(0, "Details", "I click on the logo : " & $Logo2,2)
EndIf
EndIf
Next
EndIf
EndIf
Next
EndFunc