Jump to content

Search the Community

Showing results for tags '$WS_EX_TRANSPARENT'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. While looking for a way to change my desktop background of only my secondary monitor, I found a few simple solutions that are built into Windows. But when you look up how to do such with a slideshow... You only find programs that cost money. So, I set out to make it myself.This is a pretty basic program. It simply displays an image in the center of the screen (scaled to fit screen) and uses a black background.The program does allow mouse passthrough, though you can't drag and drop over it, so it wouldn't really work well if you have icons on your second monitor. #include <File.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <Array.au3> #include <GDIPlus.au3> ;User Changeable Variables ;======================================================================== $pictureFolder = "D:\Wallpapers" $changeTime = 5 ;Seconds Global $smWidth = 1600 Global $smHeight = 900 Global $monitorPosition = "Right" ;Global $monitorPosition = "Left" ;======================================================================== Global $imageList = _FileListToArray($pictureFolder) Global $imageCount = $imageList[0] Global $imageHeight, $imageWidth, $pHeight, $pWidth, $pic, $gdiPic _GDIPlus_Startup() OnAutoItExitRegister("CloseProgram") $GUIStyle = BitOR($WS_POPUP, $WS_VISIBLE, $HWND_BOTTOM) ;Popup, Visible, Window on Bottom $GUIStyleEx = BitOR($WS_EX_TRANSPARENT, $WS_EX_TOOLWINDOW) ;Allow Passthrough, Hide from Alt+Tab $Parent = WinGetHandle('Program Manager', '') ;Sets parent to the program manager, allowing you to right click the desktop If $monitorPosition = "Right" Then $GUI = GUICreate("Secondary Wallpaper", $smWidth, $smHeight, @DesktopWidth, 0, $GUIStyle, $GUIStyleEx, $Parent) Else $GUI = GUICreate("Secondary Wallpaper", $smWidth, $smHeight, (-1 * @DesktopWidth), 0, $GUIStyle, $GUIStyleEx, $Parent) EndIf GUISetBkColor(0, $GUI) _WinAPI_SetWindowPos($GUI, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_SHOWWINDOW)) ;Forces window to bottom of screen WinSetTrans($GUI, '', 255) ;Sets Window Visible Transparency: Required for mouse passthrough ChangeImage() GUISetState(@SW_SHOW) ;Show GUI While 1 Sleep($changeTime * 1000) ChangeImage() WEnd Func ChangeImage() $picName = Random(1, $imageCount, 1) ;Get Dimensions of image GetDimensions($imageList[$picName]) $imageHeight = $pHeight $imageWidth = $pWidth ;Turn them all into integers. (Fixes glitch that caused some images to skip resizing) $imageHeight = Int($imageHeight) $imageWidth = Int($imageWidth) $smHeight = Int($smHeight) $smWidth = Int($smWidth) ;Adjust the image size ;----------------------------------------------- ;If the image is bigger than the screen, adjust it If $imageWidth > $smWidth = 1 Or $imageHeight > $smHeight = 1 Then ;Calculate Aspect Ratio of image $aspectRatioX = $smWidth / $imageWidth $aspectRatioY = $smHeight / $imageHeight If $aspectRatioX < $aspectRatioY Then $scaleFactor = $aspectRatioX Else $scaleFactor = $aspectRatioY EndIf $imageHeight = $imageHeight * $scaleFactor $imageWidth = $imageWidth * $scaleFactor ;Else ;Image is smaller/same size as monitor EndIf ;Calculate Center of monitor ;(Monitor size - image size) / 2 $smCenterX = ($smWidth - $imageWidth) / 2 $smCenterY = ($smHeight - $imageHeight) / 2 ;Resize the image $hHBmp = $pictureFolder & "\" & $imageList[$picName] $gdiPic = _GDIPlus_BitmapCreateFromFile($hHBmp) ;convert GDI bitmap to GDI+ bitmap _GDIPlus_BitmapDispose($pic) $pic = _GDIPlus_ImageResize($gdiPic, $imageWidth, $imageHeight) ;resize image _GDIPlus_BitmapDispose($gdiPic) GUISetBkColor(0, $GUI) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI) ;create a graphics object from a window handle $gdiPic = _GDIPlus_BitmapCreateFromFile($pictureFolder & "\" & $imageList[$picName]) _GDIPlus_GraphicsDrawImage($hGraphics, $pic, $smCenterX, $smCenterY) ;display scaled image _GDIPlus_GraphicsDispose($hGraphics) ;Garbage Cleanup EndFunc ;==>ChangeImage Func GetDimensions($picName) Local $prop, $dArray, $fileSize, $imageDimensionsGDI $path = $pictureFolder & "\" & $picName $fileSize = FileGetSize($path) ;Save information to registry for faster access. Compare size of picture to verify changes to picture If $fileSize <> RegRead("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Size") Then ;File sizes do not match RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Size", "REG_SZ", $fileSize) $imageDimensionsGDI = _GDIPlus_ImageLoadFromFile($path) $pWidth = _GDIPlus_ImageGetWidth($imageDimensionsGDI) $pHeight = _GDIPlus_ImageGetHeight($imageDimensionsGDI) _GDIPlus_ImageDispose($imageDimensionsGDI) RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Width", "REG_SZ", $pWidth) RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Height", "REG_SZ", $pHeight) Else ;File sizes match $pWidth = RegRead("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Width") $pHeight = RegRead("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Height") If $pWidth = "-1" Or $pHeight = "-1" Then RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Size", "REG_SZ", $fileSize) $imageDimensionsGDI = _GDIPlus_ImageLoadFromFile($path) $pWidth = _GDIPlus_ImageGetWidth($imageDimensionsGDI) $pHeight = _GDIPlus_ImageGetHeight($imageDimensionsGDI) _GDIPlus_ImageDispose($imageDimensionsGDI) RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Width", "REG_SZ", $pWidth) RegWrite("HKEY_CURRENT_USER\Software\Secondary Wallpaper\Pictures", $picName & " Height", "REG_SZ", $pHeight) EndIf EndIf EndFunc ;==>GetDimensions Func CloseProgram() ;Garbage Cleanup _GDIPlus_GraphicsDispose($gdiPic) _GDIPlus_Shutdown() EndFunc ;==>CloseProgram Secondary Wallpaper.au3
  2. Hey guys, Im posting a new thread out of a necro post as per Melba. I edited a .gif picture to make a transparent background (with photoshop). When I try to add this picutre into my gui, it makes the background of my picture white. I dont want any background on my picture. I just want the image alone alone with nothing around it. Using a previous post I was able to do so using the code below. #include <GUIConstants.au3> HotKeySet("{END}", "Terminate") $gui=GUICreate("test transparentpic", 47, 45) $pic=GUICreate("", 47, 45, 0, 0,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD,$WS_EX_TRANSPARENT),$gui) GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0,0,47, 45) WinSetTrans ( $pic, "", 50 ) GUISetState(@SW_SHOW,$pic) Sleep(1e9) GUISetState(@SW_SHOW,$gui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else EndSelect WEnd Exit Func Terminate() exit(0) EndFunc My problem is that I also want to make it transparent as well. When I use $WS_EX_TRANSPARENT and WinSetTrans ( $pic, "", 50 ), it appears transparent but the background comes back white. UEZ suggested this code below using GDIPlus: #include <GUIConstants.au3> #include <GDIPlus.au3> Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() $himg=_GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif") $hbmp=_GDIPlus_BitmapCreateHBITMAPFromBitmap($himg) _GDIPlus_ImageDispose($himg) $gui=GUICreate("test transparentpic", 200, 250) $pic=GUICtrlCreatePic("",60,85,68,71) _WinAPI_DeleteObject(GUICtrlSendMsg($pic,$STM_SETIMAGE,$IMAGE_BITMAP,$hbmp)) GUISetState(@SW_SHOW,$gui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hbmp) _GDIPlus_Shutdown() ExitLoop EndSelect WEnd Exit I ran this above to see what happens and it brought the image up with white background and no transparency (which is what I thought it was going to do). Then I augmented as below: #include <GUIConstants.au3> #include <GDIPlus.au3> HotKeySet("{END}", "Terminate") Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() $himg=_GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif") $hbmp=_GDIPlus_BitmapCreateHBITMAPFromBitmap($himg) _GDIPlus_ImageDispose($himg) $gui=GUICreate("test transparentpic", 200, 250) $gui=GUICreate("", 200, 250,0,0,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD,$WS_EX_TRANSPARENT),$gui) $pic=GUICtrlCreatePic("",60,85,68,71) WinSetTrans ( $pic, "", 50 ) _WinAPI_DeleteObject(GUICtrlSendMsg($pic,$STM_SETIMAGE,$IMAGE_BITMAP,$hbmp)) GUISetState(@SW_SHOW,$gui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hbmp) _GDIPlus_Shutdown() ExitLoop EndSelect WEnd Func Terminate() exit(0) EndFunc trying to make it no background with transparency, but it still doesnt. I dont understand why. Any thoughts from anyone? Thank you for your time guys, Mason
×
×
  • Create New...