realkiller Posted November 10, 2007 Posted November 10, 2007 i wanna use my png picture as gui how can i do that? Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2
Moderators SmOke_N Posted November 10, 2007 Moderators Posted November 10, 2007 i wanna use my png picture as gui how can i do that?Take some initiative and look? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
realkiller Posted November 10, 2007 Author Posted November 10, 2007 thx for replying, i found a code and altererd it a little bit the problem now is, the gui start but i cant see the buttons:( expandcollapse popup#include <GUIConstants.au3> #include <A3LGDIPlus.au3> #Include <Misc.au3> Opt("OnExitFunc","OnAutoItExit") Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Dim $Splitted[3] _GDIP_Startup() $pngSrc = @scriptdir&"\Bakgrund.png" $hImageExperiment2 = _GDIP_ImageLoadFromFile($pngSrc) $Width = _GDIP_ImageGetWidth ($hImageExperiment2) $Height = _GDIP_ImageGetHeight($hImageExperiment2) $GuiExperiment2 = GUICreate("Experiment2", $Width, $Height, 200, 200, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)); will create a dialog box that when displayed is centered SetBitMap($GuiExperiment2, $hImageExperiment2, 0) GUISetState(@SW_SHOW, $GuiExperiment2) WinSetOnTop($GuiExperiment2,"",1) SetBitMap($GuiExperiment2, $hImageExperiment2, 255) $Button_1 = GUICtrlCreateButton ("Run Notepad", 100, 100, 100, 30) $Button_2 = GUICtrlCreateButton ( "Button Test", 110, 30, 100, 30) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState (); will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 Switch GuiGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button_1 Run('Notepad.exe'); Will Run/Open Notepad Case $Button_2 MsgBox(0, 'Testing', 'Button 2 was pressed'); Will demonstrate Button 2 being pressed EndSwitch Wend Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GuiExperiment2) and ($iMsg = $WM_NCHITTEST) And _IsPressed(01) then Return $HTCAPTION EndIf EndFunc Func OnAutoItExit() _API_DeleteObject($hImageExperiment2) _GDIP_Shutdown() EndFunc 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 Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2
realkiller Posted November 10, 2007 Author Posted November 10, 2007 i found it thx anyway:) 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 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir ; Load PNG file as GDI bitmap _GDIP_Startup() $pngSrc = @scriptdir&"\Bakgrund.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("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() 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 gUICtrlCreateButton("gfd", 400, 400) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE 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 _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 ; 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 Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2
Moderators SmOke_N Posted November 10, 2007 Moderators Posted November 10, 2007 http://www.autoitscript.com/forum/index.ph...st&p=391424The PNG is the main gui, so you'll create a child to hold the controls, the above is an example. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
realkiller Posted November 10, 2007 Author Posted November 10, 2007 thx:) it seems that i can't use tabs with this i tryed buttons they work edits fields works 2, any knows a way to fix the tab issu? Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now