cryton2707 Posted September 21, 2007 Posted September 21, 2007 You should create a third GUI specifically and only for the picture control. Using this stuff is different from normal GUI methodology, to say the least.Lod3n.. thanks very much that worked great for me Its a very nice include you've got. And no doupt I'll be using it a lot in the future Thanks again Welcome to the internet :) where men are men! Women are men! and 16 year old women are FBI agents!
cryton2707 Posted September 21, 2007 Posted September 21, 2007 I have the same error and I can`t get it work ...HELP Based on what Lod3n saidfor the second graphic I used.. CODE $minon=guicreate("minon", 38,28,532,-19,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$Gui)GUICtrlCreatePic(@ScriptDir &"\minon.jpg",0, 0, 38,28)GUISetState()This creates a very small gui the size of my new graphic at the coords that I wanted my second graphic to appear at (overlayed on the first gui) then created a pic at 0,0 of this second gui So basically you create your fisrt background gui..then create a new gui the size and shape of the graphic you want to create and then finally put a picture into the new gui.hope this sorta makes sence. Welcome to the internet :) where men are men! Women are men! and 16 year old women are FBI agents!
spyrorocks Posted December 9, 2007 Posted December 9, 2007 No longer compatible with the newest release of autoit. Mind updating it? This is pretty useful. [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center]
spyrorocks Posted December 9, 2007 Posted December 9, 2007 Ah never mind, I got it working myself... CODE ;Updated to support latest autoit by spyrorocks #NoTrayIcon #Include <GDIPlus.au3> ; this is where the magic happens, people #include <GuiCombo.au3> #Include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @scriptdir&"\LaunchySkin.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth ($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($gui,"",1) ;fade in png background for $i = 0 to 255 step 10 SetBitMap($GUI, $hImage, $i) next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif",0,0,$width,$height) GuiCtrlSetState(-1,$GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter",50,12,140,50) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1,0xFFFFFF) ; combo box listing all items on desktop $Combo = GuiCtrlCreateCombo("", 210, 12,250,-1) GUICtrlSetFont ($Combo, 12) ; set default button for Enter key activation - renders outside GUI window $goButton = GUICtrlCreateButton ( "Go",$width,$height,10,10,$BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox $aFileList=_FileListToArray($launchDir) _ArraySort($aFileList,0,1) $FileList = _ArrayToString ( $aFileList, "|", 1) GUICtrlSetData($Combo,$FileList) AdlibEnable ( "GoAutoComplete", 1000 ) ; combo autocomplete every message loop = often incorrect While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $goButton $runthis = GUICtrlRead($Combo) ExitLoop EndSelect WEnd AdlibDisable () if $runthis <> "" then if fileexists($launchDir & "\" & $runthis) then beep(1000,50) beep(2000,50) _ShellExecute($runthis, "", $launchDir) EndIf EndIf GUIDelete($controlGui) ;fade out png background for $i = 255 to 0 step -10 SetBitMap($GUI, $hImage, $i) next ; Release resources _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() func GoAutoComplete() _GUICtrlComboAutoComplete ($Combo, $old_string) EndFunc ; ==================================================================================================== ===== ====================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== ===== ====================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GUI) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc ; ==================================================================================================== ===== ====================== ; SetBitMap ; ==================================================================================================== ===== ====================== 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 ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg="", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 else Return 0 EndIf EndFunc one problem, there is a bug in the guicomb.au3 file... execute the code and you will see what I mean. I tested it using autoit v3.2.10.0. [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center]
Draygoes Posted December 9, 2007 Posted December 9, 2007 @ SpyroRocks: Im haveing trouble using the updated script. It throws me all these errors:C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(4,10) : ERROR: can't open include file <GuiCombo.au3>#include <GuiCombo.au3>~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(38,55) : ERROR: syntax error$controlGui = GUICreate("ControlGUI", $width, $height,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(109,1) : ERROR: syntax error==^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(25,27) : ERROR: SetBitMap(): undefined function.SetBitMap($GUI, $hImage, 0)~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(27,45) : ERROR: WM_NCHITTEST(): undefined function.GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(87,39) : ERROR: _ShellExecute(): undefined function._ShellExecute($runthis, "", $launchDir)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3(104,47) : ERROR: _GUICtrlComboAutoComplete(): undefined function._GUICtrlComboAutoComplete ($Combo, $old_string)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Users\Draygoes\Desktop\lod3n_launcher\lod3n launcher.au3 - 7 error(s), 0 warning(s)I have no idea whats wrong. Im using the latest version of autoit. Spoiler  "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.  Â
BrettF Posted December 9, 2007 Posted December 9, 2007 (edited) Clean the script up... When you copy it, lines are added... And this works for me expandcollapse popup;Updated to support latest autoit by spyrorocks, then re-updated by Bert... =] #NoTrayIcon #Include <GDIPlus.au3> ; this is where the magic happens, people #include <GuiComboBox.au3> #Include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @ScriptDir & "\LaunchySkin.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($GUI, "", 1) ;fade in png background For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter", 50, 12, 140, 50) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; combo box listing all items on desktop $Combo = GUICtrlCreateCombo("", 210, 12, 250, -1) GUICtrlSetFont($Combo, 12) ; set default button for Enter key activation - renders outside GUI window $goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox $aFileList = _FileListToArray($launchDir) _ArraySort($aFileList, 0, 1) $FileList = _ArrayToString($aFileList, "|", 1) GUICtrlSetData($Combo, $FileList) AdlibEnable("GoAutoComplete", 1000) ; combo autocomplete every message loop = often incorrect While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $goButton $runthis = GUICtrlRead($Combo) ExitLoop EndSelect WEnd AdlibDisable() If $runthis <> "" Then If FileExists($launchDir & "\" & $runthis) Then Beep(1000, 50) Beep(2000, 50) _ShellExecute($runthis, "", $launchDir) EndIf EndIf GUIDelete($controlGui) ;fade out png background For $i = 255 To 0 Step - 10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func GoAutoComplete() _GUICtrlComboBox_AutoComplete($Combo) EndFunc ;==>GoAutoComplete ;=============================================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ;=============================================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ;=============================================================================================================================== ; SetBitMap ;=============================================================================================================================== 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 ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 Else Return 0 EndIf EndFunc ;==>_ShellExecute Edited December 9, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
LarLin Posted December 18, 2007 Posted December 18, 2007 Hi, I've solved this problem doing like this... If @OSVersion = "WIN_VISTA" Then $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-22,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI) ElseIf @OSVersion = "WIN_2003" Then $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-22,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI) Else $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-28,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI) EndIf Maybe not the right way but... I'm having a little difficulty determining where the GUICtrlCreateLabel gets it's initial placement values from. When I set it to (10, 0) it offsets it correctly from the left side, but not from the top. I disabled the GUICtrlSetBkColor to show where the label is actually placed. expandcollapse popup#NoTrayIcon #include <A3LGDIPlus.au3> ; this is where the magic happens, people #include <GuiCombo.au3> #Include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 ; Load PNG file as GDI bitmap _GDIP_Startup() $pngSrc = @scriptdir&"\Sample.png" $hImage = _GDIP_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIP_ImageGetWidth ($hImage) $height = _GDIP_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("Sample", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() ;WinSetOnTop($gui,"",1) ;fade in png background for $i = 0 to 255 step 10 SetBitMap($GUI, $hImage, $i) next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif",0,0,$width,$height) GuiCtrlSetState(-1,$GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Sample PNG GUI",10,0,110,30) ;GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1,0xf000000) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ; Case $msg = $goButton ; ExitLoop EndSelect WEnd AdlibDisable () GUIDelete($controlGui) ;fade out png background for $i = 255 to 0 step -10 SetBitMap($GUI, $hImage, $i) next ; Release resources _API_DeleteObject($hImage) _GDIP_Shutdown() ; =============================================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; =============================================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GUI) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc ; =============================================================================================================================== ; SetBitMap ; =============================================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _API_GetDC(0) $hMemDC = _API_CreateCompatibleDC($hScrDC) $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _API_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage)) DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _API_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _API_ReleaseDC (0, $hScrDC) _API_SelectObject($hMemDC, $hOld) _API_DeleteObject($hBitmap) _API_DeleteDC ($hMemDC) EndFunc
GEOSoft Posted December 18, 2007 Posted December 18, 2007 Hi,I've solved this problem doing like this...If @OSVersion = "WIN_VISTA" Then $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-22,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)ElseIf @OSVersion = "WIN_2003" Then $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-22,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)Else $controlGui = GUICreate("ControlGUI", $width, $hight, -4,-28,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)EndIfMaybe not the right way but...Hmmmmmmmmmmmmm. Maybe it's just me but I see no difference between your @OSVersion = "WIN_VISTA" and your @OSVersion = "WIN_2003". Are you sure you got that right? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
CrewXp Posted February 7, 2008 Posted February 7, 2008 This script doesn't work for me. I think I'm missing one of the includes... A3LGDIPLUS I think. Does anyone have a copy of the include? -Thanks!
WolfWorld Posted February 7, 2008 Posted February 7, 2008 @ CrewXp Theres no more A3LGDIPLUS after the last(long) update A3LGDIPLUS will give a lot of error try to clean t up because every function in the script exists in the new autoit Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
Stevo Posted April 19, 2008 Posted April 19, 2008 (edited) Here is the script cleand up for A3. expandcollapse popup#NoTrayIcon #include <GDIPlus.au3>; this is where the magic happens, people #include <GuiComboBox.au3> #Include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @scriptdir&"\LaunchySkin.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth ($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($gui,"",1) ;fade in png background for $i = 0 to 255 step 10 SetBitMap($GUI, $hImage, $i) next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif",0,0,$width,$height) GuiCtrlSetState(-1,$GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter",50,12,140,50) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1,0xFFFFFF) ; combo box listing all items on desktop $Combo = GuiCtrlCreateCombo("", 210, 12,250,-1) GUICtrlSetFont ($Combo, 12) ; set default button for Enter key activation - renders outside GUI window $goButton = GUICtrlCreateButton ( "Go",$width,$height,10,10,$BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox $aFileList=_FileListToArray($launchDir) _ArraySort($aFileList,0,1) $FileList = _ArrayToString ( $aFileList, "|", 1) GUICtrlSetData($Combo,$FileList) AdlibEnable ( "GoAutoComplete", 1000 ); combo autocomplete every message loop = often incorrect While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $goButton $runthis = GUICtrlRead($Combo) ExitLoop EndSelect WEnd AdlibDisable () if $runthis <> "" then if fileexists($launchDir & "\" & $runthis) then beep(1000,50) beep(2000,50) _ShellExecute($runthis, "", $launchDir) EndIf EndIf GUIDelete($controlGui) ;fade out png background for $i = 255 to 0 step -10 SetBitMap($GUI, $hImage, $i) next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() func GoAutoComplete() _GUICtrlComboBox_AutoComplete ($Combo) EndFunc ; ==================================================================================================== =========================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== =========================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GUI) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc ; ==================================================================================================== =========================== ; SetBitMap ; ==================================================================================================== =========================== 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 ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg="", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 else Return 0 EndIf EndFunc Download the original zip file and replace the content of lod3n_launcher with above and enjoy. Cheers. Stevo Edited April 19, 2008 by Stevo
ManojB Posted May 28, 2008 Posted May 28, 2008 Here is the script cleand up for A3. expandcollapse popup#NoTrayIcon #include <GDIPlus.au3>; this is where the magic happens, people #include <GuiComboBox.au3> #Include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @scriptdir&"\LaunchySkin.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth ($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($gui,"",1) ;fade in png background for $i = 0 to 255 step 10 SetBitMap($GUI, $hImage, $i) next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif",0,0,$width,$height) GuiCtrlSetState(-1,$GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter",50,12,140,50) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1,0xFFFFFF) ; combo box listing all items on desktop $Combo = GuiCtrlCreateCombo("", 210, 12,250,-1) GUICtrlSetFont ($Combo, 12) ; set default button for Enter key activation - renders outside GUI window $goButton = GUICtrlCreateButton ( "Go",$width,$height,10,10,$BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox $aFileList=_FileListToArray($launchDir) _ArraySort($aFileList,0,1) $FileList = _ArrayToString ( $aFileList, "|", 1) GUICtrlSetData($Combo,$FileList) AdlibEnable ( "GoAutoComplete", 1000 ); combo autocomplete every message loop = often incorrect While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $goButton $runthis = GUICtrlRead($Combo) ExitLoop EndSelect WEnd AdlibDisable () if $runthis <> "" then if fileexists($launchDir & "\" & $runthis) then beep(1000,50) beep(2000,50) _ShellExecute($runthis, "", $launchDir) EndIf EndIf GUIDelete($controlGui) ;fade out png background for $i = 255 to 0 step -10 SetBitMap($GUI, $hImage, $i) next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() func GoAutoComplete() _GUICtrlComboBox_AutoComplete ($Combo) EndFunc ; ==================================================================================================== =========================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== =========================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GUI) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc ; ==================================================================================================== =========================== ; SetBitMap ; ==================================================================================================== =========================== 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 ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg="", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 else Return 0 EndIf EndFunc Download the original zip file and replace the content of lod3n_launcher with above and enjoy. Cheers. Stevo I'm using AutoIt v3.2.12.0. This cleaned up code throws many errors in my system. Could you please help me out.
GaryFrost Posted May 28, 2008 Posted May 28, 2008 I'm using AutoIt v3.2.12.0. This cleaned up code throws many errors in my system. Could you please help me out. expandcollapse popup#NoTrayIcon #include <GDIPlus.au3>; this is where the magic happens, people #include <GuiComboBox.au3> #include <File.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;~ Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @ScriptDir & "\LaunchySkin.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($GUI, "", 1) ;fade in png background For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) ; just a text label GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter", 50, 12, 140, 50) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; combo box listing all items on desktop $Combo = GUICtrlCreateCombo("", 210, 12, 250, -1) GUICtrlSetFont($Combo, 12) ; set default button for Enter key activation - renders outside GUI window $goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox $aFileList = _FileListToArray($launchDir) _ArraySort($aFileList, 0, 1) $FileList = _ArrayToString($aFileList, "|", 1) GUICtrlSetData($Combo, $FileList) AdlibEnable("GoAutoComplete", 1000); combo autocomplete every message loop = often incorrect While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $goButton $runthis = GUICtrlRead($Combo) ExitLoop EndSelect WEnd AdlibDisable() If $runthis <> "" Then If FileExists($launchDir & "\" & $runthis) Then Beep(1000, 50) Beep(2000, 50) _ShellExecute($runthis, "", $launchDir) EndIf EndIf GUIDelete($controlGui) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Func GoAutoComplete() _GUICtrlComboBox_AutoComplete($Combo) EndFunc ;==>GoAutoComplete ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== 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 ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 Else Return 0 EndIf EndFunc ;==>_ShellExecute SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference. Â
Mojo Posted May 28, 2008 Posted May 28, 2008 Hi guys, I had an older version of this script which was "Updated to support latest autoit by spyrorocks, then re-updated by Bert". It worked fine, but now I compared it to the script posted by Gary Frost, and I noticed one (?important?) change there... In Gary's Version the following line (#98) ... _GDIPlus_ImageDispose($hImage) is replaced with this one... _WinAPI_DeleteObject($hImage) Are those two functions doing the same thing, or which version is "cleaner" from a programming perspective? You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
lod3n Posted May 28, 2008 Author Posted May 28, 2008 Thanks GaryFrost! I've re-uploaded the demo with your changes to support AutoIt v3.2.12.0. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
tic Posted June 3, 2008 Posted June 3, 2008 Perhaps you guys will be interested in what we are doing in autohotkey on the same front as this...?You might be interested as we are a lot further along so you might be able to get ideas. I'd be happy to help try and convert it for autoit. I can show a demonstration if you wish...
martin Posted June 7, 2008 Posted June 7, 2008 Perhaps you guys will be interested in what we are doing in autohotkey on the same front as this...?You might be interested as we are a lot further along so you might be able to get ideas. I'd be happy to help try and convert it for autoit. I can show a demonstration if you wish...Sure, why not give us a conversion? And maybe a link to an example of what has been done with AHK. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
tic Posted June 8, 2008 Posted June 8, 2008 Sure, why not give us a conversion? And maybe a link to an example of what has been done with AHK.Sure buddy. Here's a very simple example that I just wrote just to demonstrate 2 wrapper functions I have created, namely Gdip_TextToGraphics and Gdip_BlurBitmap. I have made much more insane things than this but just give this example a try and tell me what you think. I have included it compiled and the source in case you dont feel like installing ahk (http://www.autohotkey.com/download/)Hover buttons example
Recommended Posts