dickep Posted February 25, 2010 Posted February 25, 2010 I have looked here and cannot seem to find what can help me. What I want is a window that is completely transparent with some circles in it. The circles (colored) should be the ONLY thing showing. Later, the circle color will change per some calculations in the app. I just need to figure out how to make the main window "invisible" with only the colored circles showing. I have put in some code I have been trying. Maybe this could be a start point - or not. Thanks E expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $ctrlGraphic = 0, $iColor = 0xFFFFFF, $oColor = 0x00ff66, $mColor = 0x00ff00 Global $count = 1 Global $hGUI = GUICreate("Draw Test", 300, 300) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUISetState() WinSetTrans($hGUI,"",100) _Redraw() HotKeySet("g", "_Redraw") ; Hit 'g' to redraw graphic Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _Redraw() consolewrite($ctrlGraphic) If $ctrlGraphic Then GUICtrlDelete($ctrlGraphic) $iColor -= 0x404040 If $iColor < 0 Then $iColor = 0xFFFFFF EndIf $ctrlGraphic = GUICtrlCreateGraphic(10, 10, 280, 280) WinSetTrans($ctrlGraphic,"",100) ConsoleWrite("Debug: $ctrlGraphic = " & $ctrlGraphic & "; $iColor = 0x" & Hex($iColor) & @LF) ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $iColor) GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 10,10,20,20) if mod($count,2) = 0 Then GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $iColor) ElseIf mod($count,3) = 0 Then GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0 , $oColor) Else GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $mColor) EndIf GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 10,50, 20,20) if mod($count,2) = 0 Then GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $oColor) ElseIf mod($count,3) = 0 Then GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0 , $mColor) Else GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $iColor) EndIf GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 10,90,20,20) if mod($count,2) = 0 Then GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $mColor) ElseIf mod($count,3) = 0 Then GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0 , $iColor) Else GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, $oColor) EndIf GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 10,130,20,20) GUICtrlSetGraphic(-1, $GUI_GR_REFRESH) EndFunc ;==>ReDraw
Moderators Melba23 Posted February 25, 2010 Moderators Posted February 25, 2010 dickep,Here is a simple example of a transparent GUI with "buttons" which you can change as the script runs. Just click on the red one!#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> $hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) $hPic_1 = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Red.bmp", 10, 10, 15, 15) $hPic_2 = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Green.bmp", 100, 10, 15, 15) $hPic_3 = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp", 200, 10, 15, 15) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) GUISetState() $fState = True While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hPic_1 $fState = Not $fState If $fState = True Then GUICtrlSetImage($hPic_2, "C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Green.bmp") GUICtrlSetImage($hPic_3, "C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp") Else GUICtrlSetImage($hPic_2, "C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp") GUICtrlSetImage($hPic_3, "C:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Green.bmp") EndIf EndSwitch WEndI used the AutoIt bmps to guarantee you would have them - to get round buttons, you would need to create/download some suitable .gifs with transparent backgrounds.I hope this helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
dickep Posted February 26, 2010 Author Posted February 26, 2010 Melba23 - thanks!!! This is almost what I wanted, but a GREAT improvement over mine. I am still looking over the code trying to figure out what/how you did it. However - I downloaded a couple of GIF's with transparent backgrounds and, well, they have a black area making them square with a button in the middle. Not sure why. Also, I can't relocate the "window". Need that and resizing, but will wait for other stuff first. I have attached the GIF's I used to see if you get the same results. Thanks again Eimages.rar
Moderators Melba23 Posted February 26, 2010 Moderators Posted February 26, 2010 dickep,Set the background colour of the GUI to 0x000000 and use the same colour in the WinAPI call - your gifs have a black background and need that colour made transparent in the GUI. Once I do that, I get round buttons with no problem.Dragging the window is posing a problem. I know of 3 ways to move a $WS_POPUP GUI - and none of them work once you add the layered style. I will keep looking.As for resize - I do not how you can do that at the moment, but again I will keep looking.So, only 1 out 3 so far - I will try to do better! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
dickep Posted February 26, 2010 Author Posted February 26, 2010 Melba23, No, 1 of 3 is GREAT!!! You really do know this - I wish I knew 10% of what you do. And I really do appreciate your help and will look forward to seeing what I can do with this. E
Moderators Melba23 Posted February 26, 2010 Moderators Posted February 26, 2010 dickep,Got the dragging working. You will need something on the GUI to grab hold of - as you can see I am currently using a label with the $GUI_WS_EX_PARENTDRAG style. That was one of the ways I thought of at first, but I could not see the label when I created it. Stupid me - the default text colour is the same as the colour we have set as the transparent colour. Hardly surprising I could not see it! Anyway, I just set the Default GUI text colour to something other than pure black - it makes no difference to the label text appearance.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> $hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0x000000) GUICtrlSetDefColor(0x010101, $hGUI) $hPic_1 = GUICtrlCreatePic("M:\Program\Au3 Scripts\0005a.gif", 10, 10, 30, 30) $hPic_2 = GUICtrlCreatePic("M:\Program\Au3 Scripts\0035a.gif", 100, 10, 30, 30) $hPic_3 = GUICtrlCreatePic("M:\Program\Au3 Scripts\0036a.gif", 200, 10, 30, 30) GUICtrlCreateLabel("Click on the text to drag this transparent GUI" & @CRLF & "Press ESC to exit", 10, 50, 480, 50, -1, $GUI_WS_EX_PARENTDRAG) _WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000, 250) GUISetState() $fState = True While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hPic_1 $fState = Not $fState If $fState = True Then GUICtrlSetImage($hPic_2, "M:\Program\Au3 Scripts\0035a.gif") GUICtrlSetImage($hPic_3, "M:\Program\Au3 Scripts\0036a.gif") Else GUICtrlSetImage($hPic_2, "M:\Program\Au3 Scripts\0036a.gif") GUICtrlSetImage($hPic_3, "M:\Program\Au3 Scripts\0035a.gif") EndIf EndSwitch WEndResizing remains difficult. One problem is that the GUI has no edges to grab hold of - it is essentially "not there" as far as Windows is concerned. A question - why do you want to resize it anyway? As the GUI does not really exist, why not make it as big as you need to begin with and then show/hide the additional controls as required?2 out of 3! We are getting there! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
dickep Posted February 26, 2010 Author Posted February 26, 2010 Melba23, You are AWESOME!!! 2 of 3 is enough for me - unless you want to investigate more for "personal challenge". I wanted to resize since the object I am building could go full screen down to about 100x100 size. I have another problem, but am trying to work that out myself. Not related to this, general programming problem - sometimes can't see forest for the grass (or is that trees - oh, well). Again, you ROCK sir!!! E
Moderators Melba23 Posted February 26, 2010 Moderators Posted February 26, 2010 dickep,Nothing to stop you using WinMove if you know the size you want. But as I said, the GUI essentially "does not exist" - so I can see little point in resizing it any smaller than the largest size you could want.Shall I keep a look out for a post in the General Help forum? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
dickep Posted February 26, 2010 Author Posted February 26, 2010 Melba23I will try the WinMove but not sure how to implement it because (1) I am not that familiar with AutoIt and (2) you stated very well that the window really "does not exist" so not sure how/what to grab to resize.No, I figured out what I needed. Just played enough that I got something working.Now, if you want to critique my code, I can post it and let you have at it.Thanks again for your diligence and excellent help.You are the AutoIt man!E
dickep Posted February 26, 2010 Author Posted February 26, 2010 One more thing - just an FYI. I was playing around with the GUICtrlCreatePic item(s) and put in the ,-1,$GUI_WS_EX_PARENTDRAG at the end of each line. Now I can pick any button and drag the window where I want it. Melba23 inspired me and the help files, well, really do HELP. Now to just get it working again - seems I got it out of sync and is not transparent anymore. Thanks Melba23.
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