Jump to content

AeroBackgrounder for Windows Vista/Seven


komalo
 Share

Recommended Posts

AeroBackgrounder

AeroBackgrounder is a very simple application, designed to create a window with an aero interface to be used as a background for applications like Rain Meter, it is easy to use and can be used by skinners or by normal user

Version

2.0

Works On

Windows Vista 32/64 Bits

Windows Seven 32/64 Bits

Download

Here: [Link]

Screen Shot

Posted Image

Features

- Options can be modified from Tray Menu with "on the fly apply"

- Ability to make several backgrounds

- "OnBottom" Option which allows you to set the background under all windows

- "Edit Mode": to move,size or remove the background

- "ShadowEffect": control whether to show shadow frame around the background

- "HideIcon": control whether to show the tray icon(so that you can put it easily with your project)

- CanMouseClick: control whether the background is clickable or not

- hardly uses CPU usage and Memory

How to use

Create New Background

1 - Click on tray menu and click (Create New Background)

2 - Enter a name THAT WAS NOT USED BEFORE for the background and click enter

Modify Or Remove a Background

- Click on tray menu and click (Enable/Disable "EditMode")

To Modify: Move and size the background like a normal window as you like

To Remove: Click the close button

- when you are done, click (Enable/Disable "EditMode") again to exit the edit mode

Change Log

Added

- ability to make several backgrounds

- Tray Menu to modify through the tray icon

- "OnBottom", "EditMode", "ShadowEffect"and "CanMouseClick" option Options

- Memory cleaner

Credits :

LeZaar for the main idea: [link]

Nieswiety for: [link]

Allhopeislost for: [link]

JamesBrooks for: [Link]

Petercui for : [link]

Source Code:

#NoTrayIcon
#include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <process.au3>
#include <string.au3>


If _Vista_ICE() = 0 Then
    MsgBox(16, "AeroBackgrounder", "DWM is not enabled")
    Exit
EndIf

Global Const $WM_MOVING = 0x0216
Global Const $WS_EX_NOACTIVATE = 0x08000000

Const $ConfigFile = "Config.ini"
Const $ConfigSection = "Config"
Const $BackgroundSection = "Backgrounds."

Const $HideIconKey = "HideIcon"
Const $EditModeKey = "EditMode"
Const $OnBottomKey = "OnBottom"
Const $CanMouseClickKey = "CanMouseClick"
Const $ShadowEdgesKey = "ShadowEdges"

Global $HideIcon = ConfigRead($ConfigSection, $HideIconKey)
Global $EditMode = ConfigRead($ConfigSection, $EditModeKey)
Global $OnBottom = ConfigRead($ConfigSection, $OnBottomKey)
Global $CanMouseClick = ConfigRead($ConfigSection, $CanMouseClickKey)
Global $ShadowEdges = ConfigRead($ConfigSection, $ShadowEdgesKey)

Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", $HideIcon)

Local $Sections = IniReadSectionNames($ConfigFile)
For $i = 1 To UBound($Sections) - 1
    If StringInStr($Sections[$i], $BackgroundSection) <> 0 Then
        Background_Create($Sections[$i])
    EndIf
Next

$CreateNew = TrayCreateItem("Create New Background")
TrayCreateItem("")
TrayCreateItem('Options')
TrayItemSetState(-1, $TRAY_DEFAULT)
$ShadowEdgesItem = TrayCreateItem('Enable/Disable "ShadowEdges"')
$EditModeItem = TrayCreateItem('Enable/Disable "EditMode"')
$CanMouseItem = TrayCreateItem('Enable/Disable "Can Mouse Click"')
$OnBottomItem = TrayCreateItem('Enable/Disable "Always On Bottom"')
$HideTrayItem = TrayCreateItem('Enable/Disable "Hide Tray Icon"')
TrayCreateItem("")
$About = TrayCreateItem("About")
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")
ClearMemory()

While 1
    Switch TrayGetMsg()
        Case $CreateNew
            $Name = InputBox("AeroBackgrounder", "Enter a name for the aero background")
            If $Name <> "" Then
                Local $Bounds[5] = [400, 400, 400, 400]
                Background_SaveData($BackgroundSection & $Name, $Bounds)
                Background_Create($BackgroundSection & $Name)
            EndIf

        Case $ShadowEdgesItem
            Settings_Reverse($ShadowEdgesKey, $ShadowEdges)
            RefreshBackgrounds()

        Case $EditModeItem
            Settings_Reverse($EditModeKey, $EditMode)
            RefreshBackgrounds()

        Case $CanMouseItem
            Settings_Reverse($CanMouseClickKey, $CanMouseClick)
            RefreshBackgrounds()

        Case $HideTrayItem
            Settings_Reverse($HideIconKey, $HideIcon)

        Case $OnBottomItem
            Settings_Reverse($OnBottomKey, $OnBottom)
            RefreshBackgrounds()

        Case $About
            MsgBox("", "About AeroBackgrounder", _
                            "AeroBackgrounder for Windows Vista/Seven" & @CRLF & _
                            "   By Komalo (Mohamed Kamal)" & @CRLF & _
                            "Version: 2.0" & @CRLF & _
                            "Homepage: komalo.deviantart.com")
        Case $Exit
            Exit
    EndSwitch
WEnd

Func Settings_Reverse($SettingName, ByRef $SettingVariable)
    If $SettingVariable = 0 Then
        $SettingVariable = 1
    Else
        $SettingVariable = 0
    EndIf
    ConfigSave($SettingName, $SettingVariable)
EndFunc ;==>Settings_Reverse

Func RefreshBackgrounds()
    $WinList = WinList()
    For $i = 1 To $WinList[0][0]
        If StringInStr(@AutoItExe, _ProcessGetName(WinGetProcess($WinList[$i][1]))) <> 0 Then
            If StringInStr(Background_GetName($WinList[$i][1]), $BackgroundSection) <> 0 Then
                Background_SetOptionsStyle($WinList[$i][1])
            EndIf
        EndIf
    Next
    ClearMemory()
EndFunc ;==>RefreshBackgrounds

Func Background_Create($Name)
    $BackgroundInfo = Background_GetData($Name)
    $GUI = GUICreate("", $BackgroundInfo[2], $BackgroundInfo[3], $BackgroundInfo[0], $BackgroundInfo[1], Default, $WS_EX_TOOLWINDOW)
    GUICtrlCreateLabel($Name, 10, 10, 100, 100,-1)
    GUIRegisterMsg(0x0232, "Background_OnMoving")
    GUIRegisterMsg($WM_NCHITTEST, "Background_onclick")
    GUIRegisterMsg($WM_NCLBUTTONDOWN, "Background_onclick")
    GUISetOnEvent($GUI_EVENT_CLOSE, "Background_onclickClose")
    GUISetState(@SW_SHOWNA)
    Background_SetOptionsStyle($GUI)
EndFunc ;==>Background_Create

Func Background_SetOptionsStyle($hWnd)
    Local $Styles = BitOR($WS_VISIBLE, $WS_POPUP)
    Local $ExStyles = $WS_EX_TOOLWINDOW
    If $EditMode = 1 Then
        $Styles = BitOR($Styles, $WS_SIZEBOX, $WS_CAPTION, $WS_SYSMENU)
    Else
        If $ShadowEdges = 1 Then
            $Styles = BitOR($Styles, $WS_CAPTION)
        EndIf
        If $OnBottom = 1 Then
            $ExStyles = BitOR($ExStyles, $WS_EX_NOACTIVATE)
            _WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOACTIVATE))
        EndIf
        If $CanMouseClick = 0 Then
            $ExStyles = BitOR($ExStyles, $WS_EX_TRANSPARENT, $WS_EX_LAYERED)
        EndIf
    EndIf
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $Styles)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $ExStyles)
    _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, BitOR($SWP_NOZORDER, $SWP_FRAMECHANGED, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOACTIVATE))

    If $EditMode = 0 Then
        If $ShadowEdges = 0 Then
            Background_ApplyAeroWithOutShadow($hWnd)
        Else
            Background_ApplyAeroWithShadow($hWnd)
        EndIf
    Else
        Background_ApplyAeroWithOutShadow($hWnd)
    EndIf
EndFunc ;==>Background_SetOptionsStyle

Func Background_GetName($hWnd)
    Return StringTrimRight(WinGetText($hWnd, ""),1)
EndFunc ;==>Background_GetName

Func Background_ApplyAeroWithShadow($hWnd)
    _Vista_EnableBlurBehind($hWnd, False)
    Local $Area[4] = [-1, -1, -1, -1]
    _Vista_ApplyGlassArea($hWnd, $Area)
EndFunc ;==>Background_ApplyAeroWithShadow

Func Background_ApplyAeroWithOutShadow($hWnd)
    Local $Area[4] = [0, 0, 0, 0]
    _Vista_ApplyGlassArea($hWnd, $Area)
    _Vista_EnableBlurBehind($hWnd)
EndFunc ;==>Background_ApplyAeroWithOutShadow

Func Background_onclick($hWndGUI, $MsgID, $WParam, $LParam)
    If $OnBottom = 1 And $EditMode = 0 Then
        $WParam = $HTERROR
        Return 0
    EndIf
EndFunc ;==>Background_onclick

Func Background_onclickClose()
    Dim $Name = Background_GetName(@GUI_WinHandle)
    IniDelete($ConfigFile, $Name)
    GUIDelete(@GUI_WinHandle)
EndFunc ;==>Background_onclickClose

Func Background_OnMoving($hWndGUI, $MsgID, $WParam, $LParam)
    Dim $Name = Background_GetName($hWndGUI)
    Dim $Bounds = WinGetPos($hWndGUI)
    Background_SaveData($Name, $Bounds)
EndFunc ;==>Background_OnMoving

Func Background_GetData($Name)
    Local $Info[5]
    $Info[0] = ConfigRead($Name, "X")
    $Info[1] = ConfigRead($Name, "Y")
    $Info[2] = ConfigRead($Name, "Width")
    $Info[3] = ConfigRead($Name, "Height")
    Return $Info
EndFunc ;==>Background_GetData


Func Background_SaveData($Name, $Bounds)
    ConfigWrite($Name, "X", $Bounds[0])
    ConfigWrite($Name, "Y", $Bounds[1])
    ConfigWrite($Name, "Width", $Bounds[2])
    ConfigWrite($Name, "Height", $Bounds[3])
EndFunc ;==>Background_SaveData

Func ConfigSave($SettingsName, $Value)
    ConfigWrite($ConfigSection, $SettingsName, $Value)
EndFunc ;==>ConfigSave

Func ConfigRead($Section, $Key)
    Return IniRead($ConfigFile, $Section, $Key, "")
EndFunc ;==>ConfigRead

Func ConfigWrite($Section, $Key, $Value)
    Return IniWrite($ConfigFile, $Section, $Key, $Value)
EndFunc ;==>ConfigWrite

Func ClearMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlassArea
; Description ...: Applys glass effect to a window area
; Syntax.........: _Vista_ApplyGlassArea($hWnd, $Area, [$bColor)
; Parameters ....: $hWnd - Window handle:
;   $Area - Array containing area points
;   $bColor - Background color
; Return values .: Success - No return
;   Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to monoceres!
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x00000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        If IsArray($Area) Then
            $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
            DllStructSetData($Struct, "cxLeftWidth", $Area[0])
            DllStructSetData($Struct, "cxRightWidth", $Area[1])
            DllStructSetData($Struct, "cyTopHeight", $Area[2])
            DllStructSetData($Struct, "cyBottomHeight", $Area[3])
            GUISetBkColor($bColor, $hWnd); Must be here!
            $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
            If @error Then
                Return 0
            Else
                Return $Ret
            EndIf
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
    EndIf
EndFunc ;==>_Vista_ApplyGlassArea

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_EnableBlurBehind
; Description ...: Enables the blur effect on the provided window handle.
; Syntax.........: _Vista_EnableBlurBehind($hWnd)
; Parameters ....: $hWnd - Window handle:
; Return values .: Success - No return
;   Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to komalo
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _Vista_EnableBlurBehind($hWnd, $bEnable = True, $bColor = 0x000000)
    Const $DWM_BB_ENABLE = 0x00000001

    $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
    $sStruct = DllStructCreate("dword;int;ptr;int")

    DllStructSetData($sStruct, 1, $DWM_BB_ENABLE)
    If $bEnable Then
        DllStructSetData($sStruct, 2, "1")
        DllStructSetData($sStruct, 4, "1")
    EndIf
    GUISetBkColor($bColor, $hWnd)
    $Ret = DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($sStruct))
    If @error Then
        Return 0
    Else
        Return $Ret
    EndIf
EndFunc ;==>_Vista_EnableBlurBehind
; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ICE
; Description ...: Returns 1 if DWM is enabled or 0 if not
; Syntax.........: _Vista_ICE()
; Parameters ....:
; Return values .: Success - Returns 1
;   Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to BrettF
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _Vista_ICE()
    $ICEStruct = DllStructCreate("int;")
    $Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))
    If @error Then
        Return 0
    Else
        Return DllStructGetData($ICEStruct, 1)
    EndIf
EndFunc ;==>_Vista_ICE

Please, Link back if you used it in a project

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

:suggestion: fix the Source Code that is shown in your post, currently its in a single line, instead of a Multiline, myself i find that using [ autoit][ /autoit] instead of the BlueTriangle for the code box helps alot with this, every now and then i get a single line code, instead of multiline when i use the BlueTriangle.

Link to comment
Share on other sites

  • 2 weeks later...

:suggestion: fix the Source Code that is shown in your post, currently its in a single line, instead of a Multiline, myself i find that using [ autoit][ /autoit] instead of the BlueTriangle for the code box helps alot with this, every now and then i get a single line code, instead of multiline when i use the BlueTriangle.

thanks for the suggestion, sorry for late in fixing it, but actually i was using the

autoit tag but now I used the normal code tag, anyway thnx again, hope u like it

---

version 2 is released

Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...