Here are 2 examples of using transparency in a GUI. The first uses a background image that is used to display an oval shaped GUI and controls on top of it. It's just a basic one color oval, but you can use anything in it's place to make a GUI of any shape, as long as the background has a consistent single color to be used for the transparent color.
The second is a GUI that is nearly fully transparent except for the label text. This example also shows how to use a label as a hyperlink, and a label that can be used to drag a GUI around like a title bar.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
Opt("GUIOnEventMode", 1)
Global $URL[4]
Global $Active = 1
_Main()
_Links()
Func _Main() ; Partially transparent GUI
$Temp = GUICreate("", 800, 280, -1, -1, $WS_POPUP, $WS_EX_LAYERED) ; set up GUI to be transparent
GUISetBkColor(0x9FBAD8) ; set the back ground color of the GUI to match the color of the upper left pixel of the back ground picture
GUICtrlCreatePic(@ScriptDir & "\bg.bmp", 0, 0, 0, 0) ; use a bmp as the back ground picture, jpg can be used but it won't look as good.
GUICtrlSetState(-1, $GUI_DISABLE) ; disable the picture so you can interact with the controls
GUISetOnEvent($GUI_EVENT_CLOSE, "_TempClose1")
GUICtrlSetFont(-1, 10, 800, -1, "Consolas")
GUICtrlSetColor(-1, 0x0000000)
GUICtrlCreateButton(" Close ", 225, 210, -1) ; buttons can show artifacts that you don't want on your GUI
GUICtrlSetOnEvent(-1, "_TempClose1")
GUICtrlCreateIcon("shell32.dll", -28, 230, 150) ; icons look much better on this type of GUI
GUICtrlSetOnEvent(-1, "_TempClose1") ; the icon acts like a button
Local $idProgress = GUICtrlCreateProgress(110, 100, 280, 20)
$iProgress = 1
GUISetState()
While $Active
Sleep(100)
$iProgress += 1
If $iProgress = 101 Then $iProgress = 1
GUICtrlSetData($idProgress, $iProgress)
WEnd
EndFunc ;==>_Main
Func _Links() ; Fully transparent GUI with hyperlinks
Local $Func[4]
$URL[0] = "http://www.autoitscript.com/forum"
$URL[1] = "http://www.autoitscript.com/forum/forum/2-general-help-and-support/"
$URL[2] = "http://www.autoitscript.com/forum/forum/9-example-scripts/"
$URL[3] = "Extended Message Box"
Local $Text = "You can drag the GUI around by left clicking on this label and dragging it." & @LF & @LF & _
"Some helpful links: "
$Func[0] = "Main forum page"
$Func[1] = "General Help and Support"
$Func[2] = "Example Scripts"
$Func[3] = ""
$Temp = GUICreate("", 800, 280, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xFFFFFF) ; set the back ground color of the GUI to match the color of the Upper left pixel of the background image. In this case it's white.
GUICtrlCreatePic(@ScriptDir & "\White.bmp", 0, 0, 0, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetOnEvent($GUI_EVENT_CLOSE, "_TempClose")
GUISetBkColor(0xFFFFFF, $Temp)
GUICtrlCreateLabel($Text, 40, 10, 750, 100, Default, $GUI_WS_EX_PARENTDRAG) ; You can drag the window around with this label
GUICtrlSetFont(-1, 10, 800, -1, "Consolas")
GUICtrlSetBkColor(-1, 0x00DDDD) ; sets the back ground color of the label so you can see where it starts/ends
GUICtrlSetColor(-1, 0x0000000)
GUICtrlCreateButton(" Close ", 360, 230, -1)
GUICtrlSetOnEvent(-1, "_TempClose")
For $I = 0 To 3
GUICtrlCreateLabel($Func[$I], 40, 130 + ($I * 20), 200, 20)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetFont(-1, 9, 400, 0)
Next
GUICtrlCreateLabel($URL[0], 260, 130, 400, 20)
GUICtrlSetOnEvent(-1, "_ForumURL")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0x00000FF)
GUICtrlSetFont(-1, 9, 400, 4)
GUICtrlCreateLabel($URL[1], 260, 150, 400, 20)
GUICtrlSetOnEvent(-1, "_GHSURL")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0x00000FF)
GUICtrlSetFont(-1, 9, 400, 4)
GUICtrlCreateLabel($URL[2], 260, 170, 348, 20)
GUICtrlSetOnEvent(-1, "_ExampleURL")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0x00000FF)
GUICtrlSetFont(-1, 9, 400, 4)
GUICtrlCreateLabel($URL[3], 260, 190, 400, 20)
GUICtrlSetOnEvent(-1, "_EMBURL")
GUICtrlSetCursor(-1, 0)
GUICtrlSetColor(-1, 0x00000FF)
GUICtrlSetFont(-1, 9, 400, 4)
GUISetState()
While 1
Sleep(10)
WEnd
EndFunc ;==>_Links
Func _TempClose()
Exit
EndFunc ;==>_TempClose
Func _TempClose1()
$Active = 0
GUIDelete()
EndFunc ;==>_TempClose1
Func _ForumURL()
ShellExecute($URL[0])
EndFunc ;==>_ForumURL
Func _GHSURL()
ShellExecute($URL[1])
EndFunc ;==>_GHSURL
Func _ExampleURL()
ShellExecute($URL[2])
EndFunc ;==>_ExampleURL
Func _EMBURL()
ShellExecute("http://www.autoitscript.com/forum/index.php?showtopic=109096")
EndFunc ;==>_EMBURL
You will need the files in the attached zip to see these in action, extract them to the same folder that the script is being run from.
You can use files other than BMP files, but they won't look as good because of artifacting due to image compression. A PNG should/might work as well, I haven't tried that yet. Backgrounds.zip