如何把这几个QQ的PNG图象围绕成一个圆圈呢?请看代码如下:(已解决)
本帖最后由 yiruirui 于 2010-8-30 09:20 编辑#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
Dim $Over
Dim $Pressed
$GUI = GUICreate("Launcher-Playlet", $Width, $Height, $PosX, $PosY, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle(""))
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]
$LabelArray[$i] = GUICtrlCreateLabel($Name, ($i - 1) * 101, 40, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor($LabelArray[$i], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i], 0x00FF00) ;字体颜色
Next
#cs $LabelArray = GUICtrlCreateLabel($GameName, (1 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (2 - 1) * 101, 100, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (3 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (2- 1) * 101, 0, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
;$LabelArray = GUICtrlCreateLabel($GameName, (1 - 1) * 101, 40, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
#ce
$LabelArray = GUICtrlCreateLabel("", 510, 10, 40, 40);退出标签
GUICtrlSetBkColor($LabelArray[$i], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i], 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] = 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 = $LabelArray[$i] Then ;光标在按钮
While $CursorInfo = $LabelArray[$i] ;而在光标按钮
$CursorInfo = GUIGetCursorInfo($ControlGUI)
Switch $CursorInfo
Case 0 ;如果没有按下按钮
If $LabelArray[$i] <> 1 Then
$LabelArray[$i] = 1 ;状态 = over
SetBitmap($GUI, $Over[$i], 255)
EndIf
Case 1 ;若按下按钮
If $LabelArray[$i] <> 2 Then
$LabelArray[$i] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
While $CursorInfo = 1
$CursorInfo = GUIGetCursorInfo($ControlGUI)
If $CursorInfo = $LabelArray[$i] Then ;若按下按钮,并在控制
If $LabelArray[$i] <> 2 Then
$LabelArray[$i] = 2 ;状态 = pressed
SetBitmap($GUI, $Pressed[$i], 255)
EndIf
Else ;若按下按钮,是在无法控制
If $LabelArray[$i] <> 3 Then
$LabelArray[$i] = 3 ;状态 = pressed and over
SetBitmap($GUI, $Over[$i], 255)
EndIf
EndIf
Sleep(10)
WEnd
If $CursorInfo = $LabelArray[$i] Then RunButton($i)
EndSwitch
Sleep(10)
WEnd
$LabelArray[$i] = 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 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 = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath)
EndIf
Case 2
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath)
EndIf
Case 3
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath)
EndIf
Case 4
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath)
EndIf
Case 5
;Beep(1000, 50)
;Beep(2000, 50)
If $GamePath = '' Then
MsgBox(48, '提示', '请设置好config.ini执行路径再试!')
Else
Run($GamePath)
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
;设置默认
For $i = 1 To 5
$Image[$i] = $NormalImage
Next
$Image = $NormalImage_Small
$Image = $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 = $PressedImage_Exit
EndSwitch
Case "over"
Switch $Case
Case 1 To 5
$Image[$Case] = $OverImage
Case 11
$Image = $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, 505, 0, 57, 52)
;清理不再需要的资源
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_GraphicsDispose($hGraphic1)
;返回新的位图
Return $hBitmap
EndFunc ;==>_ImageDraw 我的想法如下:#cs For $i = 1 To 5
Global $Name = $GameName[$i]
$LabelArray[$i] = GUICtrlCreateLabel($Name, ($i - 1) * 101, 40, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor($LabelArray[$i], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($LabelArray[$i], 0x00FF00) ;字体颜色
Next
#ce
$LabelArray = GUICtrlCreateLabel($GameName, (1 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (2 - 1) * 101, 100, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (3 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (2- 1) * 101, 0, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray = GUICtrlCreateLabel($GameName, (2 - 1) * 101, 50, 100, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE))用下面替换上面,让这5个PNG图片相成一个圆圈,可惜,错的一塌糊涂,差距还很大的!上面的脚本是在一条直线上显示了这5张PNG图片,我是想弄个环.
我会把脚本中用到的PNG图象当成附件传上来,大家直接复制代码编译运行看效果,然后看看则么改!
小弟先说谢谢了!滴水之恩涌泉相报!!! 本帖最后由 yiruirui 于 2010-8-11 16:57 编辑
5个PNG图片 config.ini
内容如下:
; 未完成
;GameTitle=聊天菜单 未完成
;GameNumber=5 未完成
名称①=QQ2006
名称②=QQ2007
名称③=QQ2008
名称④=QQ2009
名称⑤=QQ2010
路径①=
路径②=C:\Program Files\Microsoft Games\FreeCell\FreeCell.exe
路径③=C:\Program Files\Microsoft Games\Hearts\Hearts.exe
路径④=C:\Program Files\Microsoft Games\Hearts\Hearts.exe
路径⑤=C:\Program Files\Microsoft Games\Hearts\Hearts.exe 如果各位大虾嫌麻烦的话,可以去这个连接:
http://www.autoitx.com/forum.php?mod=viewthread&tid=13262&highlight=PNG
我就是从这里搞的,谢谢了!这里的第2个例子! 同样在期待高手们蹦出来ING...... 已经能够解决。只要代码看懂就OK了,难度不大,但是很需要耐心! 很好很强大 好复杂啊 ,,,, 貌似很复杂的问题?{:face (125):} 太给力了
{:face (114):} {:face (411):}{:face (411):}{:face (411):} 这里有个圆形排列图标的例子,你看下里面把圆型排列的算法(就是那个3.1415926 圆周率相关的东西),套用到你的脚本里就可以了。。。 学些,等待高手解围 不错,顶一下
页:
[1]