#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
FileInstall("devilish.ico", @TempDir & "\devilish.ico", 1)
FileInstall("normal.png", @TempDir & "\normal.png", 1)
FileInstall("over.png", @TempDir & "\over.png", 1)
FileInstall("pressed.png", @TempDir & "\pressed.png", 1)
FileInstall("normal-exit.png", @TempDir & "\normal-exit.png", 1)
FileInstall("over-exit.png", @TempDir & "\over-exit.png", 1)
FileInstall("pressed-exit.png", @TempDir & "\pressed-exit.png", 1)
_GDIPlus_Startup()
TraySetIcon(@TempDir & "\devilish.ico")
Opt("TrayAutoPause", 0)
Global Const $NormalImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\normal.png")
Global Const $OverImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\over.png")
Global Const $PressedImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\pressed.png")
Global Const $NormalImage_Small = _ResizeBitmap(@TempDir & "\normal.png", 118, 53)
Global Const $OverImage_Small = _ResizeBitmap(@TempDir & "\over.png", 118, 53)
Global Const $PressedImage_Small = _ResizeBitmap(@TempDir & "\pressed.png", 118, 53)
Global Const $NormalImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\normal-exit.png")
Global Const $OverImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\over-exit.png")
Global Const $PressedImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\pressed-exit.png")
Global Const $AC_SRC_ALPHA = 1
Global Const $Sensitivity = 200
Global Const $Width = 565
Global Const $Height = 200
Global $PosX = @DesktopWidth - 868
Global $PosY = @DesktopHeight - 768
Global $Pause = 0
Global $LastActiveWindow = ""
Global $Offline = 1
Dim $LabelArray[14][2]
Dim $Over[12]
Dim $Pressed[12]
$GUI = GUICreate("Launcher-Playlet", $Width, $Height, $PosX, $PosY, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]"))
GUISetIcon(@TempDir & "\devilish.ico")
GUISetState(@SW_SHOW, $GUI)
$Skin = _ImageDraw()
For $i = 1 To 11
$Over[$i] = _ImageDraw("over", $i)
$Pressed[$i] = _ImageDraw("pressed", $i)
Next
#EndRegion Image GUI
#Region GUI for holding button text, also for getting hover position
$ControlGUI = GUICreate("ControlGUI", $Width, $Height, $PosX, $PosY, $WS_POPUP, BitOR($WS_EX_LAYERED, 0x2000000), $GUI)
GUISetFont(14, 400, -1, "IMPACT") ;字体
GUISetBkColor(0x123456, $ControlGUI)
$IniPath = @ScriptDir & "\config.ini"
$G3Title = IniRead($IniPath, "Config", "GameTitle", "")
$GameName = IniReadSection($IniPath, "GameName")
$GamePath = IniReadSection($IniPath, "GamePath")
For $i = 1 To 5
Global $Name = $GameName[$i][1]
$LabelArray[$i][0] = GUICtrlCreateLabel($Name, ($i - 1) * 101, 40, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor($LabelArray[$i][0], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i][0], 0x00FF00) ;字体颜色
Next
#cs $LabelArray[1][0] = GUICtrlCreateLabel($GameName[1][1], (1 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[2][0] = GUICtrlCreateLabel($GameName[2][1], (2 - 1) * 101, 100, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[3][0] = GUICtrlCreateLabel($GameName[3][1], (3 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[4][0] = GUICtrlCreateLabel($GameName[4][1], (2- 1) * 101, 0, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
;$LabelArray[1][0] = GUICtrlCreateLabel($GameName[1][1], (1 - 1) * 101, 40, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
#ce
$LabelArray[11][0] = GUICtrlCreateLabel("", 510, 10, 40, 40);退出标签
GUICtrlSetBkColor($LabelArray[$i][0], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i][0], 0xFFFFFF)
_API_SetLayeredWindowAttributes($ControlGUI, 0x123456, 230)
GUISetState(@SW_SHOW, $ControlGUI)
#EndRegion GUI for holding button text, also for getting hover position
;设置状态变量
For $i = 1 To 11
$LabelArray[$i][1] = 0 ;normal = 0; over = 1; pressed = 2; pressed, but not over on mouseup = 3
Next
SetBitmap($GUI, $Skin, 255)
Global $CursorInfo = GUIGetCursorInfo($ControlGUI)
While 1
#Region Button Checking Part
For $i = 1 To 11
If $CursorInfo[4] = $LabelArray[$i][0] Then ;光标在按钮
While $CursorInfo[4] = $LabelArray[$i][0] ;而在光标按钮
$CursorInfo = GUIGetCursorInfo($ControlGUI)
Switch $CursorInfo[2]
Case 0 ;如果没有按下按钮
If $LabelArray[$i][1] <> 1 Then
$LabelArray[$i][1] = 1 ;状态 = over
SetBitmap($GUI, $Over[$i], 255)
EndIf
Case 1 ;若按下按钮
If $LabelArray[$i][1] <> 2 Then
$LabelArray[$i][1] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
While $CursorInfo[2] = 1
$CursorInfo = GUIGetCursorInfo($ControlGUI)
If $CursorInfo[4] = $LabelArray[$i][0] Then ;若按下按钮,并在控制
If $LabelArray[$i][1] <> 2 Then
$LabelArray[$i][1] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
Else ;若按下按钮,是在无法控制
If $LabelArray[$i][1] <> 3 Then
$LabelArray[$i][1] = 3 ;状态 = pressed and over
SetBitmap($GUI, $Over[$i], 255)
EndIf
EndIf
Sleep(10)
WEnd
If $CursorInfo[4] = $LabelArray[$i][0] Then RunButton($i)
EndSwitch
Sleep(10)
WEnd
$LabelArray[$i][1] = 0 ;设置的状态正常
SetBitmap($GUI, $Skin, 255) ;重置所有按钮
;更新状态字段时,不通过控制 - 减少使用
EndIf
Next
#EndRegion Button Checking Part
Sleep(10) ;可以改变取决于CPU的速度
WEnd
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
If @error Then
Return SetError(@error, 0, 0)
ElseIf $Ret[0] = 0 Then
Return SetError(4, 0, 0)
Else
Return 1
EndIf
EndFunc ;==>_API_SetLayeredWindowAttributes
Func _ResizeBitmap($sFile, $newW, $newH)
Local $oldImage, $GC, $newBmp, $newGC
;加载图像
$oldImage = _GDIPlus_ImageLoadFromFile($sFile)
;创建新形象
$GC = _GDIPlus_ImageGetGraphicsContext($oldImage)
$newBmp = _GDIPlus_BitmapCreateFromGraphics($newW, $newH, $GC)
$newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)
;绘制
_GDIPlus_GraphicsDrawImageRect($newGC, $oldImage, 0, 0, $newW, $newH)
;Clenaup
_GDIPlus_GraphicsDispose($GC)
_GDIPlus_GraphicsDispose($newGC)
_GDIPlus_ImageDispose($oldImage)
Return $newBmp
EndFunc ;==>_ResizeBitmap
Func OnAutoItExit()
If IsDeclared("WS_EX_COMPOSITED") Then ;如果脚本没有关闭_Singleton
_GDIPlus_ImageDispose($NormalImage)
_GDIPlus_ImageDispose($NormalImage_Small)
_GDIPlus_ImageDispose($NormalImage_Exit)
_GDIPlus_ImageDispose($OverImage)
_GDIPlus_ImageDispose($OverImage_Small)
_GDIPlus_ImageDispose($OverImage_Exit)
_GDIPlus_ImageDispose($PressedImage)
_GDIPlus_ImageDispose($PressedImage_Small)
_GDIPlus_ImageDispose($PressedImage_Exit)
_GDIPlus_Shutdown()
WinActivate($LastActiveWindow)
DirRemove(@TempDir & "\essential2", 1)
Beep(1000, 50)
Beep(2000, 50)
Beep(500, 50)
EndIf
EndFunc ;==>OnAutoItExit
Func RunButton($ButtonNumber)
Switch $ButtonNumber
Case 1
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath[1][1] = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath[1][1])
EndIf
Case 2
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath[2][1] = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath[2][1])
EndIf
Case 3
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath[3][1] = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath[3][1])
EndIf
Case 4
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath[4][1] = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath[4][1])
EndIf
Case 5
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath[5][1] = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath[5][1])
EndIf
Case 11
Exit
EndSwitch
EndFunc ;==>RunButton
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 _ImageDraw($State = "normal", $Case = "");利用为PNG图片
Local $hGraphic1, $hBitmap, $hGraphic2
Local $Image[13]
;设置默认
For $i = 1 To 5
$Image[$i] = $NormalImage
Next
$Image[11] = $NormalImage_Small
$Image[12] = $NormalImage_Exit
;创建一个新的位图,这样,原来打开PNG是保持不变
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;绘制原图到新创建的位图
Switch $State
Case "normal"
Case "pressed"
Switch $Case
Case 1 To 5
$Image[$Case] = $PressedImage
Case 11
$Image[12] = $PressedImage_Exit
EndSwitch
Case "over"
Switch $Case
Case 1 To 5
$Image[$Case] = $OverImage
Case 11
$Image[12] = $OverImage_Exit
EndSwitch
EndSwitch
For $i = 1 To 5
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], ($i - 1) * 101, 0, 100, 100)
Next
_GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[12], 505, 0, 57, 52)
;清理不再需要的资源
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
;返回新的位图
Return $hBitmap
EndFunc ;==>_ImageDraw