Jump to content

picea892

Active Members
  • Posts

    691
  • Joined

  • Last visited

Everything posted by picea892

  1. Cool. I just added a fade border for fun #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_LegalCopyright=funkey #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <GDIPlus.au3> #Include <Array.au3> Global $sFile1 = StringReplace(@AutoItExe, "AutoIt3.exe", "") & '\Examples\GUI\msoobe.jpg' Global $sFile2 = StringReplace(@AutoItExe, "AutoIt3.exe", "") & '\Examples\GUI\mslogo.jpg' Global $hGui = GUICreate("Test", 500, 500) Global $nTab = GUICtrlCreateTab(10, 10,480, 480) GUICtrlCreateTabItem("Tab1") Global $nPic1 = GUICtrlCreatePic($sFile1, 20, 50, 460, 420, 0) GUICtrlCreateLabel("Text-Label", 100, 100, 100, 30) _LabelMakeTranslucent(-1, $nPic1) GUICtrlCreateLabel("This is a translucent label", 100, 335, 200, 31) _LabelMakeTranslucent(-1, $nPic1) GUICtrlCreateLabel("This is a transparent label", 300, 335, -1, -1, 0x201) GUICtrlCreateTabItem("Tab2") Global $nPic2 = GUICtrlCreatePic($sFile2, 20, 50, 460, 420, 0) GUICtrlCreateLabel("Translucent label", 30, 200, 100, 20) _LabelMakeTranslucent(-1, $nPic2, 0x80FFFFFF, 0xFFFF0000) GUICtrlCreateLabel("Transparent label", 30, 250, 100, 20, 0x201) GUICtrlCreateTabItem("") GUISetState() Do Until GUIGetMsg() = -3 Func _LabelMakeTranslucent($nLbl, $nPic, $TransColor = 0x40FFFFFF, $FontColor = 0xFF000000, $iSize = 8, $sFontName = "Arial", $iStyle = 0) Local $sText = GUICtrlRead($nLbl) Local $hLbl = GUICtrlGetHandle($nLbl) Local $hPic = GUICtrlGetHandle($nPic) Local $hImage = _SendMessage($hPic, 371) Local $hParent = _WinAPI_GetParent($hlbl) _WinAPI_SetWindowLong($hLbl, -16, BitOR(_WinAPI_GetWindowLong($hLbl, -16), 512, 14)) Local $aLblPos = ControlGetPos($hParent, "", $hLbl) Local $aPicPos = ControlGetPos($hParent, "", $nPic) _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hImage) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hlbl) Local $hBitmap2 = _GDIPlus_BitmapCloneArea($hBitmap, $aLblPos[0] - $aPicPos[0], $aLblPos[1] - $aPicPos[1], $aLblPos[2], $aLblPos[3]) Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap2) $hBitmap2=_fadeborder2($hBitmap2,"0xFFFFFF","33","15") Local $hBrushArea = _GDIPlus_BrushCreateSolid($TransColor) ;_GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $aLblPos[2], $aLblPos[3], $hBrushArea) Local $hBrushText = _GDIPlus_BrushCreateSolid($FontColor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFontFamily = _GDIPlus_FontFamilyCreate($sFontName) Local $hFont = _GDIPlus_FontCreate($hFontFamily, $iSize, $iStyle) Local $tLayout = _GDIPlus_RectFCreate(0, $aLblPos[3]/2 - $iSize + 1) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat) DllStructSetData($aInfo[0], 1, ($aLblPos[2] - DllStructGetData($aInfo[0], 3)) / 2) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sText, $hFont, $aInfo[0], $hFormat, $hBrushText) Local $hImageNew = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2) _WinAPI_DeleteObject(GUICtrlSendMsg($nLbl, 370, 0, $hImageNew)) _WinAPI_DeleteObject($hImageNew) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap2) _GDIPlus_BrushDispose($hBrushArea) _GDIPlus_BrushDispose($hBrushText) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFontFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() EndFunc Func _fadeborder2($hBitmap, $col1, $faded, $depth) $gwt = _GDIPlus_ImageGetWidth($hBitmap) $ght = _GDIPlus_ImageGetHeight($hBitmap) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) $fadechange=int($faded/$depth) For $i=0 To $depth $iC1 = StringReplace($col1, "0x", "0x"&$fadechange*$i) Global $hBrush = _GDIPlus_BrushCreateSolid($iC1) _GDIPlus_GraphicsFillRect($hGraphics, $i, $i, $gwt-($i*2), $ght-($i*2), $hBrush) _GDIPlus_BrushDispose($hBrush) Next _GDIPlus_GraphicsDispose($hGraphics) Return $hBitmap EndFunc
  2. Welcome to Autoit. Put your vbs and notepad away....no need for that here. From the autoit site you can download the full install. It has Scite which is a very powerful editor and a compiler called Aut2exe.exe Using that....any autoit script can be turned into an exe. Of course you can use notepad...but Scite is so much better. For the code above a complete working example is. You can run it from scite by pressing F5. Or you can compile it using aut2exe and run it just like any exe. Have fun. #include <Misc.au3> #Include <WinAPI.au3> $dll = DllOpen("user32.dll") Global $onoff=1 While 1 Sleep ( 50 ) If _IsPressed("41", $dll) Then ; A pressed _ShowTaskBar($onoff) elseif _IsPressed("51", $dll) Then ;Q pressed ExitLoop EndIf WEnd DllClose($dll) Func _ShowTaskBar($fShow) if $onoff=0 Then $onoff=1 Else $onoff=0 EndIf Local $hTaskBar If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" Then _ShowStartButton($fShow) $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "") If $fShow=0 Then _WinAPI_ShowWindow($hTaskBar, @SW_SHOW) Else _WinAPI_ShowWindow($hTaskBar, @SW_HIDE) EndIf EndFunc ;==>_ShowTaskBar Func _ShowStartButton($fShow ) Local $hTaskBar, $hStartButton If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" Then $hStartButton = _WinAPI_FindWindow("Button", "Start") Else $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "") $hStartButton = ControlGetHandle($hTaskBar, "", "Button1") EndIf If $fShow=0 Then _WinAPI_ShowWindow($hStartButton, @SW_SHOW) Else _WinAPI_ShowWindow($hStartButton, @SW_HIDE) EndIf EndFunc ;==>_ShowStartButton
  3. This is a snippet from a much longer program I created. Maybe it will help you You need from Yashied #include <WindowsConstants.au3> #Include <Constants.au3> #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <winapi.au3> #include <GuiListView.au3> #include <GDIPlus.au3> #include <GuiImageList.au3> #include <ListViewConstants.au3> #include <INet.au3> #include <String.au3> #Include <Icons.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("MouseCoordMode", 2) global $listcolour="0x666666" global $quickonoff=0, $view=0, $comparedate=0,$totalappointments Global $listview,$listview2, $hImage,$listviewGui _starting() func _starting() Global $listviewGui = GUICreate("listviews", 420, 150, -1, -1, $WS_POPUP,$WS_EX_TOOLWINDOW) internetlinks() GUISetState(@SW_SHOWNOACTIVATE, $listviewGui) EndFunc while 1 Sleep (1000) WEnd Func _Main() Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES) Global $inireference="files.ini" $listview = GUICtrlCreateListView("", 0, 0, 420, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUICtrlSetBkColor(-1,$listcolour) GUICtrlSetFont(-1,10,400,0,"Verdana") _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles) ; Load images $hImage = _GUIImageList_Create(16, 16, 5, 3) $longest=0 For $j = 1 To $names[0] $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j]) if $sections[0][0]>$longest then $longest=$sections[0][0] Next $sections = IniReadSection(@scriptdir&"\files.ini", $names[1]) For $i = 1 To $longest if $sections[0][0]>=$i then if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then _GUIImageList_AddBitmap($hImage,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") Else _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) EndIf Else _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 50) EndIf Next For $j = 2 To $names[0] $count2=0 Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j]) For $i = 1 To $sections[0][0] if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then _GUIImageList_AddBitmap($hImage,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") Else _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) EndIf Next Next _GUICtrlListView_SetImageList($listview, $hImage, 1) $count=0 $longest=0 For $j = 1 To $names[0] _GUICtrlListView_AddColumn($listview, $names[$j], 136) $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j]) if $sections[0][0]>$longest then $longest=$sections[0][0] Next $sections = IniReadSection(@scriptdir&"\files.ini", $names[1]) For $i = 1 To $longest if $sections[0][0]>=$i then _GUICtrlListView_AddItem($listview, $sections[$i][0],$count) Else _GUICtrlListView_AddItem($listview, "", $count) EndIf $count=$count+1 Next For $j = 2 To $names[0] $count2=0 Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j]) For $i = 1 To $sections[0][0] _GUICtrlListView_AddSubItem($listview, $count2, $sections[$i][0], $j-1, $count) $count2=$count2+1 $count=$count+1 Next Next GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") EndFunc ;==>_Main func internetlinks() _GDIPlus_Startup () Global $names = IniReadSectionNames(@scriptdir&"\files.ini") For $j = 1 To $names[0] ; ConsoleWrite($names[$j]&@CRLF) ; if not $names[$j]="tools" then Global $sections = IniReadSection(@scriptdir&"\files.ini", $names[$j]) For $i = 1 To $sections[0][0] if FileExists(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp") then ContinueLoop $itsago=get_favicon($sections[$i][1],$sections[$i][0]) $image = _GDIPlus_ImageLoadFromFile (@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".ico") ; ConsoleWrite(@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".ico") $t = _GDIPlus_EncodersGetCLSID ("bmp") _GDIPlus_ImageSaveToFileEx ($image,@ScriptDir & "\favicon\favicon_" & $sections[$i][0]&".bmp",$t) Next ; EndIf Next _GDIPlus_Shutdown () _Main() EndFunc Func get_favicon($favicon_page, $filenamed) if not FileExists(@scriptdir&"\favicon") then DirCreate(@scriptdir&"\favicon") If not FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then dim $searcharray[5]=[".com",".ca",".org",".net",".edu"] for $i=0 to UBound($searcharray)-1 $stringpos=StringInStr($favicon_page,$searcharray[$i]) if $stringpos<>0 Then $favicon_page=StringTrimRight($favicon_page,(stringlen($favicon_page)-($stringpos+StringLen($searcharray[$i])-1))) ;get first page EndIf Next $hDownload1 = InetGet($favicon_page & "/favicon.ico", @ScriptDir & "\favicon\favicon_" & $filenamed&".ico") If not FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then $source = _INetGetSource($favicon_page) $resultarray = _StringBetween($source, 'href="', '"') If IsArray($resultarray) Then For $i = 0 To UBound($resultarray) - 1 ; ConsoleWrite($resultarray[$i] & @CRLF) If StringInStr($resultarray[$i], ".ico") Then if StringLeft($resultarray[$i],1)="/" then $resultarray[$i] = $favicon_page & $resultarray[$i] $hDownload1 = InetGet($resultarray[$i], @ScriptDir & "\favicon\favicon_" & $filenamed&".ico") ; ConsoleWrite($favicon_page) ExitLoop EndIf Next EndIf EndIf If FileExists(@ScriptDir & "\favicon\favicon_" & $filenamed&".ico") Then Return True Else Return False EndIf EndIf return "Already Exists" EndFunc ;==>get_favicon Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event If $wParam = $ListView Then $tagNMHDR = DllStructCreate("int;int;int", $lParam) $event = DllStructGetData($tagNMHDR, 3) If $event = $NM_CLICK Then $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $Number=DllStructGetData($tInfo, "SubItem") $col1 = _GUICtrlListView_GetItemText($ListView,_GUICtrlListView_GetNextItem($ListView),$Number) $inireference="files.ini" $names = IniReadSectionNames(@scriptdir&"\"&$inireference) For $j = 1 To $names[0] $count2=0 Global $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j]) For $i = 1 To $sections[0][0] if $col1=$sections[$i][0] then _GUICtrlListView_SetItemSelected ($ListView, -1, 0) ShellExecute($sections[$i][1]) Return $GUI_RUNDEFMSG EndIf Next Next elseIf $event = $NM_RCLICK Then $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $Number=DllStructGetData($tInfo, "SubItem") $col1 = _GUICtrlListView_GetItemText($ListView,_GUICtrlListView_GetNextItem($ListView),$Number) $names = IniReadSectionNames(@scriptdir&"\"&$inireference) For $j = 1 To $names[0] $count2=0 Global $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j]) For $i = 1 To $sections[0][0] ;ConsoleWrite("C:\applications\opera10\opera.exe "&$sections[$i][1]&@crlf) if $col1=$sections[$i][0] then if FileExists("C:\applications\opera10\opera.exe") then _GUICtrlListView_SetItemSelected ($ListView, -1, 0) ShellExecute("C:\applications\opera10\opera.exe",$sections[$i][1]) Return $GUI_RUNDEFMSG endif EndIf Next Next EndIf elseIf $wParam = $ListView2 Then $tagNMHDR = DllStructCreate("int;int;int", $lParam) $event = DllStructGetData($tagNMHDR, 3) If $event = $NM_CLICK Then $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $Number=DllStructGetData($tInfo, "SubItem") $col1 = _GUICtrlListView_GetItemText($ListView2,_GUICtrlListView_GetNextItem($ListView2),$Number) $inireference="folders.ini" $names = IniReadSectionNames(@scriptdir&"\"&$inireference) For $j = 1 To $names[0] $count2=0 $sections = IniReadSection(@scriptdir&"\"&$inireference, $names[$j]) For $i = 1 To $sections[0][0] if $col1=$sections[$i][0] then _GUICtrlListView_SetItemSelected ($ListView2, -1, 0) ShellExecute($sections[$i][1]) Return $GUI_RUNDEFMSG EndIf Next Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; files.ini [Autoit] Forum=http://www.autoitscript.com/forum/ [Newspaper] The Globe and Mail=http://www.theglobeandmail.com/ [Programs] File hippo=http://www.filehippo.com Opera=http://www.opera.com/
  4. agreed.... I did it with a pic...it can be done with an extracted icon using a script
  5. I'm glad you said you were "almost" certain #include <GDIPlus.au3> global $nottranscolour="0x000066" While 1 $nottranscolour="0x000066" PicSetGraphics(32, 32) sleep(1000) ; check every 5 minutes $nottranscolour="0x990000" PicSetGraphics(32, 32) sleep(1000) ; check every 5 minutes WEnd Func PicSetGraphics($iW, $iH) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local $hWnd, $hBitmap, $hImage, $hGraphic, $hBrush, $hBrush1, $hbmp, $aBmp _GDIPlus_Startup() ;Buffer $hBitmap = _WinAPI_CreateSolidBitmap(0, $nottranscolour, $iW, $iH) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $sText = @MDAY $hBrush1 = _GDIPlus_BrushCreateSolid(_InvertColor($nottranscolour,0)) $hFormat = _GDIPlus_StringFormatCreate(0) $hFamily = _GDIPlus_FontFamilyCreate("Verdana") $hFont = _GDIPlus_FontCreate($hFamily, 14, 0, 3) $tLayout = _GDIPlus_RectFCreate(0, 4, 32,32) ; increase 300 to 380 for one line of text $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush1) $hIcon = _GDIPlus_BitmapCreateHICONFromBitmap($hImage) ; Create an ico file from the image _CreateIconFileFromHICON($hIcon, @ScriptDir & "\trayicon.ico") $_mday=@MDAY ; Destroy the HICON now I've finished with it. _WinAPI_DestroyIcon($hIcon) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TraySetIcon(@ScriptDir & "\trayicon.ico") _GDIPlus_ImageDispose($hImage) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush1) ; _GDIPlus_BrushDispose($hBrushLin) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hbmp) _WinAPI_DeleteObject($hBitmap) _GDIPlus_Shutdown() EndFunc ;==>PicSetGraphics Func _GDIPlus_BitmapCreateHICONFromBitmap($hBitmap) Local $hIcon $hIcon = DllCall($ghGDIPDll, "int", "GdipCreateHICONFromBitmap", "hwnd", $hBitmap, "int*", 0) If @error Then Return SetError(@error, 0, -1) Return SetError($hIcon[0], 0, $hIcon[2]) EndFunc ;==>_GDIPlus_BitmapCreateHICONFromBitmap Func _CreateIconFileFromHICON($hIcon, $sOutIcon) Local $aInfo, $sIco, $sBmp, $hCDC, $tBI, $tBits, $iSz, $sBD, $FO $sIco = "0x000001000100" $sBmp = "28000000" $aInfo = _WinAPI_GetIconInfo($hIcon) $hCDC = _WinAPI_CreateCompatibleDC(0) $tBI = DllStructCreate($tagBITMAPINFO) DllStructSetData($tBI, "Size", DllStructGetSize($tBI)) _WinAPI_GetDIBits($hCDC, $aInfo[5], 0, 0, 0, DllStructGetPtr($tBI), 0) $sIco &= Hex(DllStructGetData($tBI, "Width"), 2) & Hex(DllStructGetData($tBI, "Height"), 2) & "00000100" & _RB(Hex(DllStructGetData($tBI, "BitCount"), 4)) $sBmp &= _RB(Hex(DllStructGetData($tBI, "Width"))) & _RB(Hex(DllStructGetData($tBI, "Height") * 2)) & "0100" & _RB(Hex(DllStructGetData($tBI, "BitCount"), 4)) & "00000000" $iSz = DllStructGetData($tBI, "SizeImage") $tBits = DllStructCreate("byte[" & DllStructGetData($tBI, "SizeImage") & "]") DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $aInfo[5], 'int', $iSz, 'ptr', DllStructGetPtr($tBits)) For $i = DllStructGetData($tBI, "SizeImage") + 1 To 0 Step -(DllStructGetData($tBI, "SizeImage") / DllStructGetData($tBI, "Height")) $sBD &= StringTrimLeft(BinaryMid(DllStructGetData($tBits, 1), $i, (DllStructGetData($tBI, "SizeImage") / DllStructGetData($tBI, "Height"))), 2) Next $tBits = 0 $tBI = 0 $tBI = DllStructCreate($tagBITMAPINFO) DllStructSetData($tBI, "Size", DllStructGetSize($tBI)) _WinAPI_GetDIBits($hCDC, $aInfo[4], 0, 0, 0, DllStructGetPtr($tBI), 0) _WinAPI_DeleteDC($hCDC) $iSz += DllStructGetData($tBI, "SizeImage") $sBmp &= _RB(Hex($iSz)) & "00000000000000000000000000000000" $sIco &= _RB(Hex($iSz + 40)) & _RB(Hex("22")) & $sBmp & $sBD $tBits = DllStructCreate("byte[" & DllStructGetData($tBI, "SizeImage") & "]") DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $aInfo[4], 'int', DllStructGetData($tBI, "SizeImage"), 'ptr', DllStructGetPtr($tBits)) For $i = DllStructGetData($tBI, "SizeImage") + 1 To 0 Step -(DllStructGetData($tBI, "SizeImage") / DllStructGetData($tBI, "Height")) $sIco &= StringTrimLeft(BinaryMid(DllStructGetData($tBits, 1), $i, (DllStructGetData($tBI, "SizeImage") / DllStructGetData($tBI, "Height"))), 2) Next ; Write the icon to a file. $FO = FileOpen($sOutIcon, 18) FileWrite($sOutIcon, Binary($sIco)) FileClose($FO) ; Clear the structs $tBits = 0 $tBI = 0 EndFunc ;==>_CreateIconFileFromHICON ; Reverse Byte String Func _RB($sByte) Local $aX = StringRegExp($sByte, "(.{2})", 3), $sX = '' For $i = UBound($aX) - 1 To 0 Step -1 $sX &= $aX[$i] Next Return $sX EndFunc ;==>_RB Func _InvertColor($iColor, $mode = 1) Switch $mode Case 0 Return "0xFF" & Hex(0xFFFFFF - $iColor, 6) Case 1 Return "0xFF" & StringRegExpReplace(Hex($iColor, 6), "(.{2})(.{2})(.{2})", "\3\2\1") Case 2 Return "0xFF" & StringRegExpReplace(Hex(0xFFFFFF - $iColor, 6), "(.{2})(.{2})(.{2})", "\3\2\1") EndSwitch EndFunc ;==>_InvertColor
  6. Hmmm. if Uez's work doesn't meet your needs, I think you might be looking to add more gui's in a layered sort of fashion. An extreme example that demonstrates my point....I think this is not a good approach but throw it in just for a laugh. #include <WindowsConstants.au3> Global $array[255] $j = 300 For $i = 0 to 255 - 1 $array[$i] = guicreate("Title", 2, 300, $j, 300,$WS_POPUP+$WS_DISABLED,$WS_EX_TOOLWINDOW+$WS_EX_TOPMOST) WinSetTrans($array[$i], "", $i) guisetstate() $j += 1 next While 1 Sleep(100) WEnd
  7. Glad I could help. You have one awesome script there...I need to study it.
  8. This may help you ;#include <FontConstants.au3> Global Const $NONANTIALIASED_QUALITY = 3 GUICtrlSetFont($viewTable, 14, 550, Default, "Arial", $NONANTIALIASED_QUALITY)
  9. Look again...that was only part of it. There is a child gui where the controls are being housed that is not semitransparent.
  10. Awesome effect! This is the only way I know how to do it. #include <gdiplus.au3> #include <winapi.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> Global Const $STM_SETIMAGE = 0x172 $hGui = GuiCreate("Test Skin Functions",-1,200,-1,-1,$WS_POPUP) _SetGuiRoundCorners($hGUI, 40,false,true,true,false) _CreateCustomBk($hGui, 0x550555) _CreateCustomGroupPic(100,100,200,75,0xff0000) WinSetTrans("Test Skin Functions","",150) GuiSetState() $hGui_child = GuiCreate("Test Skin Functions",-1,200,-1,-1,$WS_POPUP,BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD),$hGui) GuiCtrlCreateLabel("TEST LABEL HERE!!!",50,50,120,20) GuictrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GuiCtrlSetColor(-1,0xFFFFFF) GuiCtrlCreateLabel("AND HERE!!!",150,150,100,20) GuictrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GuiCtrlSetColor(-1,0xFFFFFF) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGui_child, 0xABCDEF, 255) GuiSetState() Do Until GuiGetMsg() = -3 Func _CreateCustomBk($hGui, $hexColor) Local $iWidth = _WinAPI_GetClientWidth($hGui) Local $iHeight = _WinAPI_GetClientHeight($hGui) Local $iPic = GuiCtrlCreatePic("", 0,0,$iWidth,$iHeight) Local $hHandle = GUICtrlGetHandle($iPic) _GDIPlus_Startup() local $oBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) local $hBrush = _GDIPlus_BrushCreateSolid("0xAA"&hex($hexColor,6)) _GDIPlus_GraphicsFillRect($hGraphics, 0, 0 ,$iWidth ,$iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2 ,$iWidth - 6 ,$iHeight - 6, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0x22FFFFFF) local $iTimes = round($iWidth/50) local $aPoints[5][2] $aPoints[0][0] = 4 $aPoints[1][1] = $iHeight $aPoints[2][1] = $iHeight $aPoints[4][1] = 0 $aPoints[3][1] = 0 For $i = 0 to $iTimes local $Random1 = random(0,$iWidth,1) local $Random2 = random(30,50,1) $aPoints[1][0] = $Random1 $aPoints[2][0] = $Random1 + $Random2 $aPoints[4][0] = $aPoints[1][0] + 50 $aPoints[3][0] = $aPoints[2][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics,$aPoints, $hBrush) $aPoints[1][0] -= $Random2/10 $aPoints[2][0] = $Random1 + $Random2 - ($Random2/10*2) $aPoints[3][0] = $aPoints[2][0] + 50 $aPoints[4][0] = $aPoints[1][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics,$aPoints, $hBrush) Next local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($oBitmap,0x00000000) _winapi_deleteobject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_brushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($oBitmap) _GDIPlus_Shutdown() GuiCtrlSetState($iPic, $GUI_DISABLE) EndFunc Func _CreateCustomGroupPic($ix, $iy, $Width, $iHeight, $hexColor) Local $iPic = GuiCtrlCreatePic("", $ix,$iy,$Width,$iHeight) Local $hHandle = GUICtrlGetHandle($iPic) _GDIPlus_Startup() local $oBitmap = _GDIPlus_BitmapCreateFromScan0($Width, $iHeight) local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) local $hBrush = _GDIPlus_BrushCreateSolid("0x55"&hex($hexColor,6)) _GDIPlus_GraphicsFillRect($hGraphics, $ix, $iy ,$Width ,$iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2 ,$Width- 4 ,$iHeight-4, $hBrush) local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($oBitmap,0x00000000) _winapi_deleteobject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_brushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($oBitmap) _GDIPlus_Shutdown() GuiCtrlSetState($iPic, $GUI_DISABLE) EndFunc Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True) Local $hCornerRgn Local $aGuiSize = WinGetPos($hGUI) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse) If $iLeftUp = false Then $hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR ) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iLeftDown = false Then $hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3]) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightUp = false Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightDown = false Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2]-1, $aGuiSize[3]-1) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf _WinAPI_SetWindowRgn($hGUI, $hRgn) EndFunc ;==>_SetGuiRoundCorners
  11. I suppose 3 seconds has to be 3 seconds every time... I'm not satisfied with this solution because this is not the case. But I believe you need to play with adlibregister or put a sleep in your main loop and count the times looped through to get to 3 seconds. Good luck Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff] local $tempaddress[1][4]=[[0,0,0,0]] Global $itsago=10 AdlibRegister("waiting",3000) While 1 for $i=0 to (UBound($colourarray)-1) $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i]) If IsArray($pixelSearch) = 1 and $itsago=10 Then MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0) $itsago=0 ContinueLoop EndIf Next WEnd Func waiting() if $itsago=10 then Return if $itsago=0 then $itsago=1 ToolTip("waiting") Else $itsago=10 ToolTip("") EndIf ConsoleWrite($itsago&@crlf) EndFunc
  12. So you come to this forum after not even attempting to learn to code....You have very very obvious mistakes in your code. The code obviously isn't yours and the code is likely for something game related....so why are we to help you? Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff] While 1 for $i=0 to (UBound($colourarray)-1) $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i]) If IsArray($pixelSearch) = 1 Then MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0) ContinueLoop EndIf Next WEnd
  13. Hi, my attempts at buttons are here. Take a look if you like Backgrounds that can be buttons
  14. More complicated but removes the red....alternatively you can use Yashied "icons" UDF No way to +1 me etc....a thank you is all that's needed..Cheers. #include <GUIConstantsEx.au3> #include <GDIPlus.au3> $Main = GUICreate('Some GUI', 200, 100) $hDownload1 = InetGet('https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif',@ScriptDir&'/paypal.gif') $Button = GUICtrlCreatePic('', 10, 35, 74,21) GUICtrlSetCursor(-1,0) iconbutton_1($Button) GUISetState() Do $msg = GUIGetMsg() $hov=GUIGetCursorInfo() if $hov[2]=1 and $hov[4]=$Button then MsgBox(0, "","Button Pressed") sleep(50) Until $msg = $GUI_EVENT_CLOSE Func iconbutton_1($control) _GDIPlus_Startup() $hwd = GUICtrlGetHandle($control) $width = _WinAPI_GetClientWidth($hwd) $height = _WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hBitmap1 = _ImageDrawicon($hBitmap1,@ScriptDir&'/paypal.gif',74,21) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _WinAPI_DeleteObject($hBMP1) _GDIPlus_BitmapDispose($hBitmap1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Func _ImageDrawicon($hImage, $picture, $iW, $iH, $iX = 0, $iY = 0) $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $iW, $iH) Global $icon = _GDIPlus_ImageLoadFromFile($picture) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $icon, $iX, $iY, $iW, $iH) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_GraphicsDispose ($hGraphic1) Return $hBitmap EndFunc
  15. Better explanations will generate better help...Perhaps this is the code you need. #include <GUIConstantsEx.au3> $Main = GUICreate('Some GUI', 200, 100) $hDownload1 = InetGet('https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif',@ScriptDir&'/paypal.gif') $Button = GUICtrlCreatePic(@ScriptDir&'/paypal.gif', 10, 35, 74,21) GUISetState() Do $msg = GUIGetMsg() $hov=GUIGetCursorInfo() if $hov[2]=1 and $hov[4]=$Button then MsgBox(0, "","Button Pressed") sleep(50) Until $msg = $GUI_EVENT_CLOSE
  16. ShellExecute("www.google.com") ShellExecute("C:\applications\opera10\opera.exe","www.google.com")
  17. Trancexx had a good example as well.. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> ; Make GUI GUICreate("StringSize", 600, 400) GUISetBkColor(0) ; black magic GUI ; First example: Global $sLabelText = "Pa Da Pam Pam..." Global $aLabelTextSize = _StringSize($sLabelText, 14) GUICtrlCreateLabel($sLabelText, 10, 20, $aLabelTextSize[0], $aLabelTextSize[1]) ; create label in calculated size GUICtrlSetFont(-1, 14) ; set wanted font GUICtrlSetBkColor(-1, 0xFFFFFF) ; make the background white ; Print size ConsoleWrite($aLabelTextSize[0] & " x " & $aLabelTextSize[1] & @CRLF) ; Secand example: $sLabelText = "abcdehmma" $aLabelTextSize = _StringSize($sLabelText, 60, 800) GUICtrlCreateLabel($sLabelText, 10, 80, $aLabelTextSize[0], $aLabelTextSize[1]) ; create label in calculated size GUICtrlSetFont(-1, 60, 800) ; set wanted font GUICtrlSetBkColor(-1, 0xFFFFFF) ; make the background white ; Print size ConsoleWrite($aLabelTextSize[0] & " x " & $aLabelTextSize[1] & @CRLF) ; Third example: $sLabelText = "First line of the text" & @LF & "Second line of the text" & @CRLF & "Third line of the text" & @CRLF & "Fourth line of the text. See ya!" $aLabelTextSize = _StringSize($sLabelText, 17, 700, 2, "Tahoma", 4) GUICtrlCreateLabel($sLabelText, 10, 220, $aLabelTextSize[0], $aLabelTextSize[1]) ; create label in calculated size GUICtrlSetFont(-1, 17, 700, 2, "Tahoma", 4) ; set wanted font GUICtrlSetBkColor(-1, 0xFFFFFF) ; make the background white ; Print size ConsoleWrite($aLabelTextSize[0] & " x " & $aLabelTextSize[1] & @CRLF) ; Show GUI GUISetState() ; Wait for the exit While GUIGetMsg() <> -3 WEnd ; FUNCTION Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iQuality = 2) Local Const $LOGPIXELSY = 90 Local $fItalic = BitAND($iAttrib, 2) Local $hDC = _WinAPI_GetDC(0) Local $hFont = _WinAPI_CreateFont(-_WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) * $iSize / 72, 0, 0, 0, $iWeight, $fItalic, BitAND($iAttrib, 4), BitAND($iAttrib, 8), 0, 0, 0, $iQuality, 0, $sName) Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont) Local $tSIZE If $fItalic Then $sText &= " " Local $iWidth, $iHeight Local $aArrayOfStrings = StringSplit($sText, @LF, 2) For $sString In $aArrayOfStrings $tSIZE = _WinAPI_GetTextExtentPoint32($hDC, $sString) If DllStructGetData($tSIZE, "X") > $iWidth Then $iWidth = DllStructGetData($tSIZE, "X") $iHeight += DllStructGetData($tSIZE, "Y") Next _WinAPI_SelectObject($hDC, $hOldFont) _WinAPI_DeleteObject($hFont) _WinAPI_ReleaseDC(0, $hDC) Local $aOut[2] = [$iWidth, $iHeight] Return $aOut EndFunc ;==>_StringSize
  18. maybe this example will give you some ideas.
  19. Looks like some nice clean code. This can be very useful as a template for a GUI.....I also like how there are only 2 includes. Good work like usual.
  20. Hi all I recently have been experimenting with GDI backgrounds, and these examples are really a continuation of this Instead of experimenting with gradients, this example focuses on fading in a background with the intent of making borders, shadows and glow effect. Include the picture in the same directory as the script Any improvements and suggestions are welcome. #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <Color.au3> commonbck() HotKeySet("{esc}","quiter") Func commonbck() $mainwidth=560 $mainheight=250 $Gui = GUICreate("", $mainwidth,$mainheight,-1,-1, $WS_POPUP, $WS_EX_TOOLWINDOW) $Pic = GUICtrlCreatePic("", 0, 0, $mainwidth, $mainheight) GUICtrlSetState(-1, $GUI_DISABLE) _mainbackground(-1,$mainwidth,$mainheight,"metal_small.jpg") $bckpic= GUICtrlCreatePic("",25,12,150, 150) GuiCtrlSetState(-1,$GUI_DISABLE) background(-1,"0xBB000000","0x880000FF","6","10") ; blue $bckpic2= GUICtrlCreatePic("",25,170,280, 70) GuiCtrlSetState(-1,$GUI_DISABLE) background(-1,"0xFF660000","0x88220000","14","6") ;red $bckpic3= GUICtrlCreatePic("",180,15,120, 40) GuiCtrlSetState(-1,$GUI_DISABLE) background(-1,"0x8800AA00","0x88003300","4","16") ; green $bckshadow= GUICtrlCreatePic("",320,10,120, 70) GuiCtrlSetState(-1,$GUI_DISABLE) fadebackground(-1,"0x000033","0x000099","21","17","12") $bckshadow2= GUICtrlCreatePic("",320,90,120, 60) GuiCtrlSetState(-1,$GUI_DISABLE) fadebackground(-1,"0xCCCC00","0x555500","33","10","8") $bckshadow3= GUICtrlCreatePic("",320,160,120, 80) GuiCtrlSetState(-1,$GUI_DISABLE) fadebackground2(-1,"0xCCCC00","55","30","8") $bckshadow3= GUICtrlCreatePic("",440,165,100, 70) GuiCtrlSetState(-1,$GUI_DISABLE) fadebackground2(-1,"0x550000","66","30","0") $round= GUICtrlCreatePic("",500,12,50, 50) GuiCtrlSetState(-1,$GUI_DISABLE) background(-1,"0xDD000000","0x880000FF","10","16") ; blue GUISetState() EndFunc While 1 sleep(50) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd func _mainbackground($guicontrol,$reqwidth,$reqheight,$picname="") _GDIPlus_Startup() Local $hImage1 = _GDIPlus_ImageLoadFromFile($picname) Local $iX1 = _GDIPlus_ImageGetWidth($hImage1)+15 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $reqwidth, "int", $reqheight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap = $hBitmap[6] Local $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap) For $i = 0 To $reqwidth Step $iX1 _GDIPlus_GraphicsDrawImage($hCtx, $hImage1, $i, 0) Next _GDIPlus_GraphicsDrawborder($hCtx, 0, 0, $reqwidth, $reqheight, 6,"AA",0x000011,10) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_ImageDispose($hImage1) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtx) Local Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($guicontrol, $STM_SETIMAGE, 0, $hBmp)) _WinAPI_DeleteObject($hBmp) _GDIPlus_Shutdown () EndFunc Func _GDIPlus_GraphicsDrawborder($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius, $hPen, $colour, $thick) $transpen=_GDIPlus_PenCreate(BitOR("0x"&$hPen&"000000",$colour),1) for $r=0 to $thick _GDIPlus_GraphicsDrawLine($hGraphics, $iX+$thick+1, $iY+$r, $iX + $iWidth-$thick-1, $iY+$r,$transpen) ; top _GDIPlus_GraphicsdrawLine($hGraphics, $iX + $iWidth-$r, $iY, $iX + $iWidth-$r, $iY + $iHeight,$transpen) ;right _GDIPlus_GraphicsdrawLine($hGraphics, $iX + $iWidth-$thick-1, $iY + $iHeight-$r, $iX+$thick+1, $iY + $iHeight-$r,$transpen) ;bottom _GDIPlus_GraphicsdrawLine($hGraphics, $iX+$r, $iY + $iHeight, $iX+$r, $iY,$transpen) ;left _GDIPlus_PenDispose($hPen) Next EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; func background($control,$col1,$col2,$deep,$cornered) _GDIPlus_Startup () $hwd=GUICtrlGetHandle($control) ;$guiname=_WinAPI_GetParent($hwd) $width=_WinAPI_GetClientWidth($hwd) $height=_WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width,$height, $hGraphic) $hBitmap1=_drawborder($hBitmap1,$col1,$col2,$deep,$cornered) $hImage1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) _GDIPlus_GraphicsSetSmoothingMode($hImage1, 2) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _GDIPlus_ImageDispose ($hImage1) _WinAPI_DeleteObject($hBMP1) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc ;handler, to draw background and createbutton3 Func _drawborder($hBitmap, $colour1, $colour2, $depth, $corner) ;this is for normal buttons $gwt = _GDIPlus_ImageGetWidth($hBitmap) - 1 $ght = _GDIPlus_ImageGetHeight($hBitmap) - 1 $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $bGammaCorrection = False Global $hBrush1 = _GDIPlus_BrushCreateSolid($colour1) Global $hBrush = _GDIPlus_BrushCreateSolid($colour2) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) _GDIPlus_GraphicsDrawRoundRect($hGraphics, 0, 0, $gwt, $ght, $corner, $hBrush) _GDIPlus_GraphicsDrawRoundRect($hGraphics, $depth, $depth, $gwt - ($depth * 2), $ght - ($depth * 2), $corner - 2, $hBrush1) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush1) _GDIPlus_GraphicsDispose($hGraphics) Return $hBitmap EndFunc ;==>_drawborder ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; func fadebackground($control,$col1,$col2,$faded,$deep,$cornered) _GDIPlus_Startup () $hwd=GUICtrlGetHandle($control) ;$guiname=_WinAPI_GetParent($hwd) $width=_WinAPI_GetClientWidth($hwd) $height=_WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width,$height, $hGraphic) $hBitmap1=_fadeborder($hBitmap1,$col1,$col2, $faded, $deep,$cornered) $hImage1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) _GDIPlus_GraphicsSetSmoothingMode($hImage1, 2) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _GDIPlus_ImageDispose ($hImage1) _WinAPI_DeleteObject($hBMP1) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc Func _fadeborder($hBitmap, $col1,$col2, $faded, $depth, $corner) $gwt = _GDIPlus_ImageGetWidth($hBitmap) $ght = _GDIPlus_ImageGetHeight($hBitmap) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $bGammaCorrection = False _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) $f = _GUICtrlCreateGradient($col1,$col2,$depth) For $i=0 To $depth $iC1 = StringReplace($f[$i], "0x", "0x"&$faded) Global $hBrush = _GDIPlus_BrushCreateSolid($iC1) GDIPlus_SetLineGammaCorrection($hBrush, $bGammaCorrection) _GDIPlus_GraphicsDrawRoundRect($hGraphics, $i, $i, $gwt-($i*2), $ght-($i*2), $corner, $hBrush) _GDIPlus_BrushDispose($hBrush) Next _GDIPlus_GraphicsDispose($hGraphics) Return $hBitmap EndFunc Func _GUICtrlCreateGradient($col1,$col2,$depth2) Local $color1R = _ColorGetRed($col1) Local $color1G = _ColorGetGreen($col1) Local $color1B = _ColorGetBlue($col1) Local $nStepR = (_ColorGetRed($col2) - $color1R) / $depth2 Local $nStepG = (_ColorGetGreen($col2) - $color1G) / $depth2 Local $nStepB = (_ColorGetBlue($col2) - $color1B) / $depth2 dim $colours[$depth2+1] For $i = 0 To $depth2 $colours[$i] = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i) Next Return $colours EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; func fadebackground2($control,$col1,$faded,$deep,$cornered) _GDIPlus_Startup () $hwd=GUICtrlGetHandle($control) ;$guiname=_WinAPI_GetParent($hwd) $width=_WinAPI_GetClientWidth($hwd) $height=_WinAPI_GetClientHeight($hwd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hwd) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($width,$height, $hGraphic) $hBitmap1=_fadeborder2($hBitmap1,$col1, $faded, $deep,$cornered) $hImage1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) _GDIPlus_GraphicsSetSmoothingMode($hImage1, 2) $hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1) _WinAPI_DeleteObject(GUICtrlSendMsg($control, 0x0172, 0, $hBMP1)) _GDIPlus_ImageDispose ($hImage1) _WinAPI_DeleteObject($hBMP1) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc Func _fadeborder2($hBitmap, $col1, $faded, $depth, $corner) $gwt = _GDIPlus_ImageGetWidth($hBitmap) $ght = _GDIPlus_ImageGetHeight($hBitmap) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $bGammaCorrection = False _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 4) $fadechange=int($faded/$depth) For $i=0 To $depth ConsoleWrite($fadechange&@crlf) $iC1 = StringReplace($col1, "0x", "0x"&$fadechange*$i) Global $hBrush = _GDIPlus_BrushCreateSolid($iC1) GDIPlus_SetLineGammaCorrection($hBrush, $bGammaCorrection) _GDIPlus_GraphicsDrawRoundRect($hGraphics, $i, $i, $gwt-($i*2), $ght-($i*2), $corner, $hBrush) _GDIPlus_BrushDispose($hBrush) Next _GDIPlus_GraphicsDispose($hGraphics) Return $hBitmap EndFunc While 1 $MSG = GUIGetMsg() Switch $MSG Case -3 Quiter() EndSwitch WEnd Func Quiter() Exit EndFunc Func _GDIPlus_GraphicsDrawRoundRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $iRadius, $hBrush = 0, $hPen = 0) _GDIPlus_PenCreate($hPen) Local $hPath = _GDIPlus_GraphicsPathCreate() _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iRadius, $iY, $iX + $iWidth - ($iRadius * 2), $iY) _GDIPlus_GraphicsPathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iWidth, $iY + $iRadius, $iX + $iWidth, $iY + $iHeight - ($iRadius * 2)) _GDIPlus_GraphicsPathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight, $iX + $iRadius, $iY + $iHeight) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90) _GDIPlus_GraphicsPathAddLine($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iX, $iY + $iRadius) _GDIPlus_GraphicsPathAddArc($hPath, $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90) ;Draw the font onto the new bitmap _GDIPlus_GraphicsPathCloseFigure($hPath) If $hBrush <> 0 Then _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hPath) _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hPath) _GDIPlus_GraphicsPathDispose($hPath) _GDIPlus_PenDispose($hPen) EndFunc ;==>_GDIPlus_GraphicsDrawRoundRect ;==== GDIPlus_CreateLineBrushFromRect === Malkey's function Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _ $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0) Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount If $iArgb1 = Default Then $iArgb1 = 0xFF0000FF If $iArgb2 = Default Then $iArgb2 = 0xFFFF0000 If $LinearGradientMode = -1 Or $LinearGradientMode = Default Then $LinearGradientMode = 0x00000001 If $WrapMode = -1 Or $LinearGradientMode = Default Then $WrapMode = 1 $tRect = DllStructCreate("float X;float Y;float Width;float Height") $pRect = DllStructGetPtr($tRect) DllStructSetData($tRect, "X", $iX) DllStructSetData($tRect, "Y", $iY) DllStructSetData($tRect, "Width", $iWidth) DllStructSetData($tRect, "Height", $iHeight) $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _ "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0) If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0] If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0] $iCount = UBound($aPositions) $tFactors = DllStructCreate("float[" & $iCount & "]") $pFactors = DllStructGetPtr($tFactors) For $iI = 0 To $iCount - 1 DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1) Next $tPositions = DllStructCreate("float[" & $iCount & "]") $pPositions = DllStructGetPtr($tPositions) For $iI = 0 To $iCount - 1 DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1) Next $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _ "ptr", $pFactors, "ptr", $pPositions, "int", $iCount) Return $aRet[6] ; Handle of Line Brush EndFunc ;==>_GDIPlus_CreateLineBrushFromRect Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection) Return $aResult[0] EndFunc ;==>GDIPlus_SetLineGammaCorrection Func _GDIPlus_GraphicsPathCreate($iFillMode = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "int*", 0); If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>_GDIPlus_GraphicsPathCreate Func _GDIPlus_GraphicsPathAddLine($hGraphicsPath, $iX1, $iY1, $iX2, $iY2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine", "hwnd", $hGraphicsPath, "float", $iX1, "float", $iY1, _ "float", $iX2, "float", $iY2) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddLine Func _GDIPlus_GraphicsPathAddArc($hGraphicsPath, $iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle) Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathArc", "hwnd", $hGraphicsPath, "float", $iX, "float", $iY, _ "float", $iWidth, "float", $iHeight, "float", $iStartAngle, "float", $iSweepAngle) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathAddArc Func _GDIPlus_GraphicsPathCloseFigure($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathCloseFigure Func _GDIPlus_GraphicsPathDispose($hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsPathDispose Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPen, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPath", "hwnd", $hGraphics, "hwnd", $hPen, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsDrawPath Func _GDIPlus_GraphicsFillPath($hGraphics, $hBrush, $hGraphicsPath) Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphics, "hwnd", $hBrush, "hwnd", $hGraphicsPath) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, 0) EndFunc ;==>_GDIPlus_GraphicsFillPath
  21. I don't know why the file is not deleting, I'm guessing the file is still open and can't be deleted...perhaps there is a variable that wasn't disposed of? I'm at a loss, perhaps someone else knows the answer. Yes, you are right about the error, thanks
  22. There are two GUIs, there is one created in the _GUICreate_Alpha function. See attached fixed version, #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $NONANTIALIASED_QUALITY = 3 Global $hGUI ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 127, 122, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 130, 12, 12) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 146, 112, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $Button1 = GUICtrlCreateButton('exit', 110, 220, 60, 23) GUICtrlSetBkColor(-1, 0x5099C0) GUICtrlSetColor(-1, 0xFFFFFF) $label = GUICtrlCreateLabel('_ x', 350, 25, 50, 25) GUICtrlSetColor(-1, 0xFFFFFF) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUICtrlSetOnEvent($Button1, "_exit") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $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", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($GUI) GUIDelete($hGUI) Sleep(200) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd
  23. Hi there Here is a control on your gui. recently learned how to change font quality and so incorporated that as well. Added Monoscout999 fix as well #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $NONANTIALIASED_QUALITY = 3 ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Global $hImage HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 129, 132, 32) GUICtrlSetFont($label, 14, 550, Default, "Arial", $NONANTIALIASED_QUALITY) ; GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $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", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _WinAPI_DeleteObject($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($GUI) Sleep(700) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd
  24. Hi Goldenix See my example Make sure to have a png image named appropriately in the script directory.
  25. You no longer need gray gif to render transparent. Search for _WinAPI_SetLayeredWindowAttributes or look in helpfile. For your checkbox and radio I would do the following. #include <GUIConstants.au3> #Include <WinAPI.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> $hWndMain = GUICreate("My CheckBox Button with Transparency", 300, 200, -1, -1,$WS_OVERLAPPEDWINDOW) GUISetBkColor(0x00ff00) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 30, 12, 12) $label = GUICtrlCreateLabel('Checkbox', 118, 29, 122, 12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 149, 112, 12) GUISetState() While True Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd
×
×
  • Create New...