水木子
发表于 2018-4-25 15:42:10
本帖最后由 水木子 于 2018-4-25 17:27 编辑
回复 26# 沉默的斗鱼
将19楼代码稍作修改即可。
这样就很清楚了吧!
#include <GDIPlus.au3>
#include <WinAPISys.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include 'GUICtrlOnHover.au3'
OnAutoItExitRegister('GuiExit')
_GDIPlus_Startup()
Global $hClone, $hGraphic, $hBitmap
Global $iGuiWidth = 400, $iGuiHeight = 400
Global $aButton
Global $iColumn = 3
Global $iLeft = 60, $iTop = 50
Global $iButtonWidth = 80, $iButtonHeight = 80
Global $iSpacingX = 100, $iSpacingY = 100
$hBKImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Images\BK.png')
$hButtonImage1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Images\1.png')
$hButtonImage2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Images\2.png')
$hButtonImage3 = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Images\3.png')
$hGui1 = GUICreate('', $iGuiWidth, $iGuiHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
For $i = 0 To UBound($aButton) - 1
$aButton[$i] = GUICtrlCreateLabel('', $iSpacingX * Mod($i, $iColumn) + $iLeft, _
$iSpacingY * Floor($i / $iColumn) + $iTop, _
$iButtonWidth, $iButtonHeight)
_GUICtrl_OnHoverRegister($aButton[$i], '_Hover_Proc', '_Leave_Hover_Proc', 'PrimaryDown_Proc', '_Hover_Proc')
Next
$hGui2 = GUICreate('', $iGuiWidth, $iGuiHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGui1)
GUICtrlCreatePic(@ScriptDir & '\Images\Grey.gif', 0, 0, $iGuiWidth, $iGuiHeight)
GUICtrlSetState(-1, $GUI_DISABLE)
_DrawImage($hGui1, $hBKImage)
GUISetState(@SW_SHOW, $hGui1)
GUISetState(@SW_SHOW, $hGui2)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
_GDIPlus_Shutdown()
Exit
Case $aButton To $aButton
_DrawImage($hGui1, $hBKImage, '', $nMsg)
EndSwitch
WEnd
Func _Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $aButton To $aButton
_DrawImage($hGui1, $hBKImage, $iCtrlID)
EndSwitch
EndFunc ;==>_Hover_Proc
Func _Leave_Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $aButton To $aButton
_DrawImage($hGui1, $hBKImage)
EndSwitch
EndFunc ;==>_Leave_Hover_Proc
Func _DrawImage($hWnd, $hBKImage, $iCtrlID = '', $iImageIndex = 0)
Local $hImage
$hClone = _GDIPlus_BitmapCloneArea($hBKImage, 0, 0, $iGuiWidth, $iGuiHeight, 0x0026200A)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hClone)
For $i = 0 To UBound($aButton) - 1
If $iImageIndex = $aButton[$i] Then
$hImage = $hButtonImage3
Else
If $iCtrlID = $aButton[$i] Then
$hImage = $hButtonImage2
Else
$hImage = $hButtonImage1
EndIf
EndIf
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, _
$iSpacingX * Mod($i, $iColumn) + $iLeft, _
$iSpacingY * Floor($i / $iColumn) + $iTop, _
$iButtonWidth, $iButtonHeight)
Next
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone)
_WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ImageDispose($hClone)
_GDIPlus_GraphicsDispose($hGraphic)
EndFunc ;==>_DrawImage
Func WM_NCHITTEST($hWnd, $IMSG, $IWPARAM, $ILPARAM)
If ($hWnd = $hGui1) And ($IMSG = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func GuiExit()
_GDIPlus_Shutdown()
EndFunc ;==>GuiExit
chzj589
发表于 2018-4-26 09:17:58
回复 1# 沉默的斗鱼
凑个热闹
纯png背景和按钮界面,如何再添加按钮和更改按钮尺寸
沉默的斗鱼
发表于 2018-4-26 09:20:43
回复 32# chzj589
大神,你做的漂亮呀!可否分享一下源码?
zpmc123
发表于 2018-4-26 13:11:24
回复 31# 水木子
GUICtrlOnHover.au3
找不到!
chzj589
发表于 2018-4-26 13:55:40
本帖最后由 chzj589 于 2018-4-27 10:35 编辑
回复 33# 沉默的斗鱼
没有鼠标动作
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
#include "_plusCtrl.au3"
#include <ScreenCapture.au3>; 捕获窗口
;#include 'GUICtrlOnHover.au3'
Opt("GUIOnEventMode", 1)
Global $iWidtha = @DesktopWidth
Global $iHeighta = @DesktopHeight
Global $Form1, $aRect, $tPropertyData, $iLength, $jish, $jishb, $jishc, $jishd, $jishe, $jishf, $Label1
Global $Labela, $Labelb, $Labelc, $Labeld, $Labele, $Labelf
Global $Pic1, $Pic2, $Pic3, $Pic4, $Pic5, $Pic6, $Pica1, $Pica2, $Pica3, $Pica4, $Pica5, $Pica6
Local Const $sFilePath = "Tup.ini"
Local $sReadA = IniRead($sFilePath, "设置", "A", "")
Local $sReadA1 = IniRead($sFilePath, "设置", "1", "")
Local $sReadA2 = IniRead($sFilePath, "设置", "2", "")
Local $sReadA3 = IniRead($sFilePath, "设置", "3", "")
Local $sReadA4 = IniRead($sFilePath, "设置", "4", "")
Local $sReadB = IniRead($sFilePath, "设置b", "B", "")
Local $sReadB1 = IniRead($sFilePath, "设置b", "1", "")
Local $sReadB2 = IniRead($sFilePath, "设置b", "2", "")
Local $sReadB3 = IniRead($sFilePath, "设置b", "3", "")
Local $sReadB4 = IniRead($sFilePath, "设置b", "4", "")
Local $sReadC = IniRead($sFilePath, "设置C", "C", "")
Local $sReadC1 = IniRead($sFilePath, "设置C", "1", "")
Local $sReadC2 = IniRead($sFilePath, "设置C", "2", "")
Local $sReadC3 = IniRead($sFilePath, "设置C", "3", "")
Local $sReadC4 = IniRead($sFilePath, "设置C", "4", "")
Local $sReadD = IniRead($sFilePath, "设置D", "D", "")
Local $sReadD1 = IniRead($sFilePath, "设置D", "1", "")
Local $sReadD2 = IniRead($sFilePath, "设置D", "2", "")
Local $sReadD3 = IniRead($sFilePath, "设置D", "3", "")
Local $sReadD4 = IniRead($sFilePath, "设置D", "4", "")
Local $sReadE = IniRead($sFilePath, "设置E", "E", "")
Local $sReadE1 = IniRead($sFilePath, "设置E", "1", "")
Local $sReadE2 = IniRead($sFilePath, "设置E", "2", "")
Local $sReadE3 = IniRead($sFilePath, "设置E", "3", "")
Local $sReadE4 = IniRead($sFilePath, "设置E", "4", "")
Local $sReadF = IniRead($sFilePath, "设置F", "F", "")
Local $sReadF1 = IniRead($sFilePath, "设置F", "1", "")
Local $sReadF2 = IniRead($sFilePath, "设置F", "2", "")
Local $sReadF3 = IniRead($sFilePath, "设置F", "3", "")
Local $sReadF4 = IniRead($sFilePath, "设置F", "4", "")
GUIForm1()
While 1
Sleep(1000)
WEnd
Func _Message()
;无边框窗口拖动
_SendMessage($Form1, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
EndFunc ;==>_Message
Func GUIForm1()
$Form1 = GUICreate("PNG图片与JPG图片合成", $iWidtha - 400, $iHeighta - 163, -1, -1, BitOR($WS_POPUP, $WS_CLIPSIBLINGS))
GUISetBkColor(0xC0E0FF)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Message");无边框窗口拖动
Local $sReadCc = IniRead($sFilePath, "设置页面", "C", "")
$hplusForm = plusCreatePic(@ScriptDir & "\" & $sReadCc, 0, 30, $iWidtha - 400, $iHeighta - 233);使用PNG图片创建异形窗口。必须先设置背景,再创建控件
GUICtrlSetState(-1, $GUI_DISABLE)
; 创建背景图片
Local $sString = StringRight($sReadA, 4)
Local $iFileExists = FileExists($sReadA)
If $iFileExists Then
;MsgBox(0, $sReadA, "文件存在." & @CRLF & $sReadA)
Else
MsgBox(0, $sReadA, "文件不存在." & @CRLF & "FileExist 返回: " & $iFileExists)
FileDelete($sFilePath)
EndIf
$Pic1 = plusCreatePic(@ScriptDir & "\" & $sReadA, $sReadA1, $sReadA2, $sReadA3, $sReadA4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click1")
$Pic2 = plusCreatePic(@ScriptDir & "\" & $sReadB, $sReadB1, $sReadB2, $sReadB3, $sReadB4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click2")
$Pic3 = plusCreatePic(@ScriptDir & "\" & $sReadC, $sReadC1, $sReadC2, $sReadC3, $sReadC4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click3")
$Pic4 = plusCreatePic(@ScriptDir & "\" & $sReadD, $sReadD1, $sReadD2, $sReadD3, $sReadD4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click4")
$Pic5 = plusCreatePic(@ScriptDir & "\" & $sReadE, $sReadE1, $sReadE2, $sReadE3, $sReadE4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click5")
$Pic6 = plusCreatePic(@ScriptDir & "\" & $sReadF, $sReadF1, $sReadF2, $sReadF3, $sReadF4)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent(-1, "_click6")
GUICtrlCreateLabel("PNG图片与JPEG图片合成", 10, 6, 227, 32, $SS_CENTER)
GUICtrlSetColor(-1, 0x804040)
GUICtrlSetFont(-1, 13, 800, 0, "微软雅黑")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
$btnMin = GUICtrlCreateLabel("━", $iWidtha - 450, 8, 27, 22, $SS_CENTER)
GUICtrlSetBkColor(-1, 0x677780)
GUICtrlSetColor(-1, 0x804040);0xfbfcfd)
GUICtrlSetFont(-1, 11, 800, 0, "微软雅黑")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "btnMin")
$btnClose = GUICtrlCreateLabel("X", $iWidtha - 425, 2, 25, 22, $SS_CENTER);╋
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 14, 600, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "btnClose")
$Label1 = GUICtrlCreateLabel("鼠标位置---安装", $iWidtha - 900, $iHeighta - 193, 300, 17)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetFont(-1, 12, 600, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;$IDButton2 = GUICtrlCreateButton("设置图片", $iWidtha - 600, $iHeighta - 203, 75, 22, 0)
;GUICtrlSetOnEvent($IDButton2, "_Form2")
$IDButton2 = GUICtrlCreateButton("显示图片", $iWidtha - 500, $iHeighta - 203, 75, 22, 0)
GUICtrlSetOnEvent($IDButton2, "IDExample")
GUISetState(@SW_SHOW, $Form1)
_Pica()
EndFunc ;==>GUIForm1
Func _click1()
;Case $GUI_EVENT_MOUSEMOVE
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装A")
MsgBox(0, ' 安装1', ' 安装A', 2)
EndIf
EndIf
EndFunc ;==>_click1
Func _click2()
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装B")
;MsgBox(0, ' 安装2', ' 安装B', 2)
EndIf
EndIf
EndFunc ;==>_click2
Func _click3()
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装C")
;MsgBox(0, ' 安装3', ' 安装C', 2)
EndIf
EndIf
EndFunc ;==>_click3
Func _click4()
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装D")
;MsgBox(0, ' 安装4', ' 安装D', 2)
EndIf
EndIf
EndFunc ;==>_click4
Func _click5()
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装E")
;MsgBox(0, ' 安装5', ' 安装E', 2)
EndIf
EndIf
EndFunc ;==>_click5
Func _click6()
Local $A = GUIGetCursorInfo($Form1)
If Not @error Then
If $A > -1 And $A < 1600 And $A > -1 And $A < 570 Then
GUICtrlSetData($Label1, "(鼠标位置: " & Int($A) & "," & Int($A) & ")---安装F")
;MsgBox(0, ' 安装6', ' 安装F', 2)
EndIf
EndIf
EndFunc ;==>_click6
Func IDExample()
FileDelete(@ScriptDir & "\GDIPlus_Image.jpg")
FileDelete(@ScriptDir & "\GDIPlus_Image.png")
; 捕获窗口
_ScreenCapture_CaptureWnd(@ScriptDir & "\GDIPlus_Image.png", $Form1, 0, 28, $iWidtha - 400, $iHeighta - 203)
_ScreenCapture_CaptureWnd(@ScriptDir & "\GDIPlus_Image.jpg", $Form1, 0, 0, $iWidtha - 400, $iHeighta - 203)
ShellExecute(@ScriptDir & "\GDIPlus_Image.png")
EndFunc ;==>IDExample
Func btnClose()
GUIDelete()
Exit
EndFunc ;==>btnClose
Func btnMin()
WinSetState($Form1, "", @SW_MINIMIZE)
EndFunc ;==>btnMin
#include "_Pica.au3"
沉默的斗鱼
发表于 2018-4-26 17:16:05
回复 34# zpmc123
有的,你如果需要我发给你,这是控制鼠标动作的函数。
chzj589
发表于 2018-4-27 10:30:21
回复 35# chzj589
使用_plusCtrl.au3函数,GUICtrlOnHover.au3函数就失去作用。
用另一个方法
zpmc123
发表于 2018-4-28 12:22:38
回复 36# 沉默的斗鱼
好的,谢谢!
kk_lee69
发表于 2018-4-30 10:02:33
回复 36# 沉默的斗鱼
還沒解決問題??
zpmc123
发表于 2018-4-30 12:38:04
本帖最后由 zpmc123 于 2018-4-30 12:41 编辑
回复 36# 沉默的斗鱼
从官方找来的多个png图片按钮菜单,含触边隐藏或收缩(附带修改后的QQ透明菜单)
搜一下这个主题
附件如下:
298311657
发表于 2018-4-30 19:04:07
回复 1# 沉默的斗鱼
png图片按钮建议楼主你使用我之前发在论坛的plusCtrl控件udf,可以很轻松的创建和使用各种图片按钮,不需要任何折腾,有图片资源就行
http://www.autoit3.cn/thread-50788-1-2.html
298311657
发表于 2018-5-1 12:06:26
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include "_plusCtrl.au3"
$GUI = GUICreate("plusCtrl示例", 799, 407)
$hplusForm = plusCreateBitmapGui($GUI, @ScriptDir & "\bg.png");使用PNG图片创建异形窗口。必须先设置背景,再创建控件
Local $tSkin1_png = plusSkin(@ScriptDir & "\anniu1a.png", @ScriptDir & "\anniu1b.png", @ScriptDir & "\anniu1a.png")
Local $tSkin2_png = plusSkin(@ScriptDir & "\anniu2a.png", @ScriptDir & "\anniu2b.png", @ScriptDir & "\anniu2a.png")
Local $tSkin3_png = plusSkin(@ScriptDir & "\anniu3a.png", @ScriptDir & "\anniu3b.png", @ScriptDir & "\anniu3a.png")
Local $tSkin4_png = plusSkin(@ScriptDir & "\anniu4a.png", @ScriptDir & "\anniu4b.png", @ScriptDir & "\anniu4a.png")
Local $tSkin5_png = plusSkin(@ScriptDir & "\anniu5a.png", @ScriptDir & "\anniu5b.png", @ScriptDir & "\anniu5a.png")
Local $tSkin6_png = plusSkin(@ScriptDir & "\anniu6a.png", @ScriptDir & "\anniu6b.png", @ScriptDir & "\anniu6a.png")
$plusBtn1 = plusCreateButton("按钮一", 337, 180, 91, 91, $tSkin1_png);创建plusCtrl
plusCtrlSetColor(-1, 0xFF33A5B0);设置plusCtrl文本颜色,颜色值为ARGB格式
plusCtrlSetEvent(-1, "plusCtrlEvent");设置plusCtrl点击事件的响应函数
$plusBtn2 = plusCreateButton("按钮二", 453, 118, 97, 94, $tSkin2_png);创建plusCtrl
plusCtrlSetEvent(-1, "plusCtrlEvent");设置plusCtrl点击事件的响应函数
$plusBtn3 = plusCreateButton("按钮三", 600, 58, 119, 132, $tSkin3_png);创建plusCtrl
plusCtrlSetEvent(-1, "plusCtrlEvent");设置plusCtrl点击事件的响应函数
$plusBtn4 = plusCreateButton("按钮四", 350, 288, 96, 100, $tSkin4_png);创建plusCtrl
plusCtrlSetEvent(-1, "plusCtrlEvent");设置plusCtrl点击事件的响应函数
;下面两个按钮使用GUIGetMsg()消息模式响应点击
$plusBtn5 = plusCreateButton("按钮五", 492, 261, 105, 107, $tSkin5_png);创建plusCtrl
$plusBtn6 = plusCreateButton("按钮六", 635, 201, 121, 123, $tSkin6_png);创建plusCtrl
plusBitmapGuiSetState($GUI);使用plusCreateBitmapGui函数设置背景后,必须使用此函数显示窗口
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST");窗口拖动
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $plusBtn5
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($plusBtn5))
Case $plusBtn6
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($plusBtn6))
EndSwitch
WEnd
Func plusCtrlEvent($iCtrl)
Switch $iCtrl
Case $plusBtn1
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($iCtrl))
Case $plusBtn2
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($iCtrl))
Case $plusBtn3
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($iCtrl))
Case $plusBtn4
MsgBox(0,"提示","按钮的文字为:" & plusCtrlRead($iCtrl))
EndSwitch
EndFunc
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
Switch $hWnd
Case $GUI
Switch $iMsg
Case $WM_NCHITTEST
Return $HTCAPTION
EndSwitch
Case Else
Return $HTCLIENT
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NCHITTEST
chzj589
发表于 2018-5-2 09:20:45
回复 42# 298311657
用$hplusForm = plusCreateBitmapGui($GUI, @ScriptDir & "\bg.png")
图标按钮有边剌
用$hplusForm = plusCreatePic(@ScriptDir & "\bg.png", 0, 30, $iWidtha - 400, $iHeighta - 233);使用PNG图片创建异形窗口。必须先设置背景,再创建控件
图标按钮就好一点
kk_lee69
发表于 2018-5-2 22:03:51
回复 43# chzj589
樓主 可能沒上線了吧