huskies Posted March 16, 2009 Share Posted March 16, 2009 I noticed that some of the programs that I used can have their GUI take the shape of their background. for example, windows media player, when used with a skin can look like different shapes depending on the background.How do i for example create a GUI with a heart shape? and then maybe I will place my buttons on the heart. <It Shall Be Done> Link to comment Share on other sites More sharing options...
martin Posted March 16, 2009 Share Posted March 16, 2009 (edited) I noticed that some of the programs that I used can have their GUI take the shape of their background. for example, windows media player, when used with a skin can look like different shapes depending on the background. How do i for example create a GUI with a heart shape? and then maybe I will place my buttons on the heart. If you can save the image as a 24bit bitmap then you can do this #include <windowsconstants.au3> GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart. GUICtrlCreatePic("heart.bmp",0,0,300,279) GUISetState() sleep(3000) EDIT: Added comment about the GuiSetBkColor Edited March 16, 2009 by martin 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. Link to comment Share on other sites More sharing options...
huskies Posted March 16, 2009 Author Share Posted March 16, 2009 If you can save the image as a 24bit bitmap then you can do this #include <windowsconstants.au3> GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart. GUICtrlCreatePic("heart.bmp",0,0,300,279) GUISetState() sleep(3000) EDIT: Added comment about the GuiSetBkColor thanks I tried your code and here is the result, do you know how to change it so that the white background of the heart would be transparent? or is that something I will have to fix in photoshop? <It Shall Be Done> Link to comment Share on other sites More sharing options...
weaponx Posted March 16, 2009 Share Posted March 16, 2009 PNG as GUI:http://www.autoitscript.com/forum/index.ph...hl=transparency Link to comment Share on other sites More sharing options...
ProgAndy Posted March 16, 2009 Share Posted March 16, 2009 (edited) It works with a bitmap, too, like in martin's example.#include <windowsconstants.au3> GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUISetBkColor(0xFF00FF);<----------- set the background colour of the window to be the same as the background colour of the heart. GUICtrlCreatePic(@MyDocumentsDir & "\Eigene Bilder\test.bmp",0,0,300,279) GUISetState() sleep(3000)(background of bmp is 0xFF00FF ) Edited March 16, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
huskies Posted March 16, 2009 Author Share Posted March 16, 2009 (edited) It works with a bitmap, too, like in martin's example.#include <windowsconstants.au3> GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUISetBkColor(0xFF00FF);<----------- set the background colour of the window to be the same as the background colour of the heart. GUICtrlCreatePic(@MyDocumentsDir & "\Eigene Bilder\test.bmp",0,0,300,279) GUISetState() sleep(3000) (background of bmp is 0xFF00FF ) what i meant is that because my heart.bmp has a white background, the gui always has a white background (see image of my example on desktop) @weaponx thanks for the link seems like a great idea, i just need to spend some time to learn to customize it also this is probably goig out on a stretch here, but what if I wanted to use an animated gif as the background? such as this one http://e.deviantart.com/emoticons/r/raincloud.gif will autoit be able to cope? Edited March 16, 2009 by huskies <It Shall Be Done> Link to comment Share on other sites More sharing options...
martin Posted March 16, 2009 Share Posted March 16, 2009 what i meant is that because my heart.bmp has a white background, the gui always has a white background (see image of my example on desktop)The image you showed means that you can't have done what I indicated in my post. Or, instead of setting the background colour of the gui set its size to be the same as the bitmap. #include <windowsconstants.au3> $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic("heart.bmp",0,0,300,279) GUISetState() sleep(3000) Use this image. 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. Link to comment Share on other sites More sharing options...
huskies Posted March 17, 2009 Author Share Posted March 17, 2009 (edited) The image you showed means that you can't have done what I indicated in my post. Or, instead of setting the background colour of the gui set its size to be the same as the bitmap. #include <windowsconstants.au3> $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic("heart.bmp",0,0,300,279) GUISetState() sleep(3000) Use this image. thanks it worked! did you use irfan view or photoshop to crop out the white? when i saved the bmp it looked the same as the bmp i had before, but when i ran the code it worked perfectly P.S. I did save it as 24 bit bmp when i tried it at first with MS paint Edited March 17, 2009 by huskies <It Shall Be Done> Link to comment Share on other sites More sharing options...
martin Posted March 17, 2009 Share Posted March 17, 2009 thanks it worked! did you use irfan view or photoshop to crop out the white? when i saved the bmp it looked the same as the bmp i had before, but when i ran the code it worked perfectlyP.S. I did save it as 24 bit bmp when i tried it at first with MS paintI used MS Paint as well. The only thing I did which might have made a difference is that I flood-filled the borders with white just to be sure they were all the same colour. The actual colour doesn't matter as long as that colour doesn't appear in the image or you will get holes where you don't want them.When you have a bitmap on a layered window the top left pixel of the last bitmap created is used as the transparent colour. That is why you either have to have the background of the window the same colour as the image background or you must have the whole of the wndow covered by the image. You can also set the transparent colour with an API call. Prog@ndy has a nice little function for it somewhere in the forums which I've often used. Search for _API_SetLayeredWindowAttributes. 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. Link to comment Share on other sites More sharing options...
huskies Posted March 17, 2009 Author Share Posted March 17, 2009 I used MS Paint as well. The only thing I did which might have made a difference is that I flood-filled the borders with white just to be sure they were all the same colour. The actual colour doesn't matter as long as that colour doesn't appear in the image or you will get holes where you don't want them. When you have a bitmap on a layered window the top left pixel of the last bitmap created is used as the transparent colour. That is why you either have to have the background of the window the same colour as the image background or you must have the whole of the wndow covered by the image. You can also set the transparent colour with an API call. Prog@ndy has a nice little function for it somewhere in the forums which I've often used. Search for _API_SetLayeredWindowAttributes. Now I get it, why it is transparent. I tried using a different bmp and i'm getting a white border on the bottom, so I thought maybe that it is not making the GUI according to the size of the picture, so i added some extra code that retrieves the size of the picture but it didn't fix the problem either. #include <windowsconstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <GDIPlus.au3>; this is where the magic happens, people $pngSrc = @ScriptDir & "\DarkArchon.bmp" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ;GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICreate("",$width,$height,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic($pngSrc,0,0,300,279) ;GUICtrlCreatePic($pngSrc,"","",$width,$height) GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart. GUISetState() sleep(40000) the picture I used This is the link where I got the idea of using GDIPlus.au3 to get the dimensions of the picture http://www.autoitscript.com/forum/index.ph...hl=transparency <It Shall Be Done> Link to comment Share on other sites More sharing options...
martin Posted March 17, 2009 Share Posted March 17, 2009 (edited) Now I get it, why it is transparent. I tried using a different bmp and i'm getting a white border on the bottom, so I thought maybe that it is not making the GUI according to the size of the picture, so i added some extra code that retrieves the size of the picture but it didn't fix the problem either. #include <windowsconstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <GDIPlus.au3>; this is where the magic happens, people $pngSrc = @ScriptDir & "\DarkArchon.bmp" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ;GUICreate("",300,300,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICreate("",$width,$height,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic($pngSrc,0,0,300,279) ;GUICtrlCreatePic($pngSrc,"","",$width,$height) GUISetBkColor(0xffffff);<----------- set the background colour of the window to be the same as the background colour of the heart. GUISetState() sleep(40000)Good idea, though if you had set the gui background colour to 0 before you created the pic then the size of the gui wouldn't have mattered. EDIT: I'm a bit worried abot the size of your thighs though, I think you need to spend more time eating junk food and less time on scripting. Edited March 17, 2009 by martin 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. Link to comment Share on other sites More sharing options...
huskies Posted March 17, 2009 Author Share Posted March 17, 2009 (edited) Good idea, though if you had set the gui background colour to 0 before you created the pic then the size of the gui wouldn't have mattered. EDIT: I'm a bit worried abot the size of your thighs though, I think you need to spend more time eating junk food and less time on scripting. you are right I was over complicating stuff #include <windowsconstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <GDIPlus.au3>; this is where the magic happens, people $pngSrc = @ScriptDir & "\DarkArchon.bmp" ;$hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ;$width = _GDIPlus_ImageGetWidth($hImage) ;$height = _GDIPlus_ImageGetHeight($hImage) $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic($pngSrc,0,0,300,279) GUISetState() sleep(3000) and you being worried about me, are you referencing to the jpeg? lol and LAST Question, I hope How do i make it so that the GUI will be dragable , right now I cannot move it anywhere the picture I want to eventually use Edited March 17, 2009 by huskies <It Shall Be Done> Link to comment Share on other sites More sharing options...
martin Posted March 17, 2009 Share Posted March 17, 2009 you are right I was over complicating stuff #include <windowsconstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <GDIPlus.au3>; this is where the magic happens, people $pngSrc = @ScriptDir & "\DarkArchon.bmp" ;$hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ;$width = _GDIPlus_ImageGetWidth($hImage) ;$height = _GDIPlus_ImageGetHeight($hImage) $gui = GUICreate("",300,279,300,300,$WS_POPUP,$WS_EX_LAYERED) GUICtrlCreatePic($pngSrc,0,0,300,279) GUISetState() sleep(3000) and you being worried about me, are you referencing to the jpeg? lol and LAST Question, I hope How do i make it so that the GUI will be dragable , right now I cannot move it anywhere the picture I want to eventually useTo make the gui draggable by the pic you just need to add the extended style Function GUICtrlCreatePic$GUI_WS_EX_PARENTDRAG, but really you should read the help for GuiCtrlCreatePic. 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. Link to comment Share on other sites More sharing options...
huskies Posted March 17, 2009 Author Share Posted March 17, 2009 you are right, I should have read the file on that, anyways yay and thanks for the help! <It Shall Be Done> Link to comment Share on other sites More sharing options...
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