AutoHotkey Community

It is currently May 27th, 2012, 6:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: [Lib] Aero_Libary
PostPosted: October 18th, 2010, 10:28 pm 
Offline

Joined: April 7th, 2010, 10:44 pm
Posts: 43
Aero_Libary
Writers: Bentschi & RaptorOne


All here work only with Vista and Win7 !!


@ first, Sorry for my bad English!!!

German Original Thread

The Lib based on my Techdemo DWM.

It use the Dwmapi.dll to Extend the Frame Area into the Client Area
or to enable a Blur behind a window.
The lib are also able to change system settings of the DWM and
to Draw Transparent Pictures on a DWM Gui.
(Draw_DWMText is in work)

The Lib contains 28 official functions.
All of them are explained.

You can download also a Testscript.

If there are questions, please represents it so that the google translator has no Problems with it. :D :D

Here Are the Downloadlink´s:
----->>>>>Aero_Libary<<<<<-----
----->>>>>Test_Aero_Libary<<<<<-----

Here 2 Pictures:
TestScript in Normal work:
Image


Halftransparent Picture drawt on the DWM Window
Image

reegards the developers Bentschi & RaptorOne


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2010, 10:40 pm 
Offline

Joined: May 2nd, 2006, 11:16 pm
Posts: 800
Location: Greeley, CO
Nice!

_________________
Image
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2010, 7:04 pm 
Offline

Joined: November 4th, 2008, 10:25 pm
Posts: 222
Location: Memphis, TN
Awesome! I can't wait to play tonight!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2010, 8:37 pm 
Offline

Joined: April 7th, 2010, 10:44 pm
Posts: 43
thx from me and Bentschi


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2010, 1:48 pm 
:mrgreen: :mrgreen: :mrgreen: good


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 3:41 am 
Offline

Joined: May 26th, 2009, 2:34 pm
Posts: 40
Location: Queensland, Australia
Great Lib, however my OS calls itself WIN_7 when called by A_OSVersion
My OS in particular is Windows 7 Ulitmiate x64

This may also becuase I am using AHK_L (I have just started using it)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 11:08 am 
Offline

Joined: December 17th, 2007, 6:39 pm
Posts: 235
Location: Galati, Romania
But what do I do if I need to have black text or a picture that contains black colour?

_________________
MusicSuite - play with and study music using MIDI


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2010, 11:59 am 
Offline

Joined: April 7th, 2010, 10:44 pm
Posts: 43
Petru wrote:
But what do I do if I need to have black text or a picture that contains black colour?

In this case you use a Transparent Color

here an easy Example:
Code:
#Include Aero_Lib.ahk

Aero_StartUp() ;Start Aero Libary

DWM_Win_TransColor:=0x123456 ;its your decision which color do you choose
Gui,Color,%DWM_Win_TransColor%
Gui,+LastFound ;Gui LastFound
MainHandle:=WinExist() ;get Handle of the Gui
Aero_ChangeFrameAreaAll(MainHandle) ;Extend the Fram Area over the whole Dwm Window
Gui,Add,Button,x5 y5 w200 h35,Sample Button`nText is visible`! ;Sample Button
Gui,Show,x5 y5 w500 h500,Aero Transparent Color Test
WinSet,TransColor,%DWM_Win_TransColor%,ahk_id %MainHandle%
Return

GuiClose:
Aero_End() ;Shutdown Aero Libary
ExitApp

_________________
Ahk_Ide_v3
Sry for my english.
Its very Bad! :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2011, 3:25 pm 
Offline

Joined: April 7th, 2010, 10:44 pm
Posts: 43
Little Bugfixes

The Lib is ready for Ahk_L

_________________
Ahk_Ide_v3
Sry for my english.
Its very Bad! :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2011, 5:23 pm 
i noticed that i cannot use translucent images using the normal gui,add,picture while still having the image's transparency on the blurred window with the black fix above.

is there any way i can fix that? i do not want to use the image functions in the library as it does not allow image overlapping (it removes the one behind after moving the window around for a while).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2011, 9:02 am 
here's a picture to visualise. the image Pb is supposed to have a dark outer glow instead of a solid color. the gui color i used was 0x123456.

Image


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2011, 11:52 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Here's a version that actually works with AutoHotkey_L (all builds, including x64):
Code:
/*

Aero_Libary

DWM - - Desktop Window Manager
Name: Aero_Lib
Autors:= Bentschi ; RaptorOne ;
Beta From 11.10.10

Funktions:
Aero_StartUp() ; Load important dll Files for more perfomance. ; Line: 52
Aero_Enable() ; Enable or disable the DWM. ; Line: 82
Aero_IsEnabled() ; Return True if DWM is enabled, False if it disabled. ; Line: 104
Aero_BlurWindow() ; Set a Blur behind a window. ; Line: 135
Aero_GuiBlurWindow() ; Set a Blur behind a window. ; Line: 174
Aero_ChangeFrameArea() ; Extend the Frame Area into the Client Area. ; Line: 220
Aero_GuiChangeFrameArea() ; Extend the Frame Area into the Client Area. ; Line: 261
Aero_ChangeFrameAreaAll() ; Extend the Frame Area into the whole Client Area. ; Line: 291
Aero_GuiChangeFrameAreaAll() ; Extend the Frame Area into the whole Client Area. ; Line: 316
Aero_GetDWMColor() ; Gets the Color of the current DWM options. ; Line: 337
Aero_GetDWMTrans() ; Gets the Transparent of the Current DWM options. ; Line: 362
Aero_SetDWMColor() ; Set�s the DWM Window Color. ; Line: 389
Aero_SetTrans() ; Set�s the DWM Transparent value. ; Line: 416
Aero_DrawPicture() ; Draws a Picture onto a DWM Gui. ; Line: 454
Aero_CreateBuffer() ; Creates a buffer from a Handle. ; Line: 481
Aero_CreateGuiBuffer() ; Creates a buffer from a GuiCount. ; Line: 502
Aero_DeleteBuffer() ; Deletes a buffer. ; Line: 523
Aero_UpdateWindow() ; Updates a window where is a DWM draw. ; Line: 550
Aero_UpdateGui() ; Updates a window where is a DWM draw. ; Line: 574
Aero_AutoRepaint() ; Set a Buffer to Autoredraw, everytime it is need it. ; Line: 598
Aero_AutoRepaintGui() ; Set a Buffer to Autoredraw, everytime it is need it. ;Line: 622
Aero_DisableAutoRepaint() ; Disables the AutoRedraw. ; Line: 643
Aero_DisableAutoRepaintGui() ; Disables the AutoRedraw. ; Line: 664
Aero_ClearBuffer() ; Clears a Buffer. ; Line: 685
Aero_LoadImage() ; Load image in a variable. ; Line: 714
Aero_DeleteImage() ; Deletes a loaded image. ; Line: 745
Aero_DrawImage() ; Draw the Picture on the Window. ; Line: 779
Aero_End() ; Unload the dll Files. ; Line: 805
*/

;============================================================================
; Funktion
; Api Name: LoadLibary (Kernel32.dll)
;
; Aero_StartUp()
;
; Load important dll Files for more perfomance.
;
;
; Return: Module Id�s (splittet with "|") (or false if OS is not compatible)
;
Aero_StartUp(){
   global
   local pack
   pack := DllCall("GetVersion", "uint") & 0xFFFF
   _Aero_WinVer := (pack & 0xFF) "." (pack >> 8)
   if _Aero_WinVer >= 6.0
   {
      MODULEID3:=DllCall("LoadLibrary", "str", "dwmapi", "Ptr")
      MODULEID2:=DllCall("LoadLibrary", "str", "uxtheme", "Ptr") ;zwar noch nicht gebraucht aber egal
      MODULEID:=MODULEID3 . "|" . MODULEID2
      Return,MODULEID
   }Else{
      MsgBox, 4112, DWM Stop, DWM cannot applied with these OS version.
      Return,False
   }
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmEnableComposition (dwmapi.dll)
;
; Aero_Enable()
;
; Enable or disable the DWM.
;
; Params:
;
; 1. enableBool (True == 1)
;    TRUE change to Aero Theme, False change to Windows Basic Theme.
;
; Return: A_LastError
;
Aero_Enable(enableBool=1){
   global
   If(!MODULEID)
      Aero_StartUp()
   If _Aero_WinVer >= 6.0
      DllCall("dwmapi\DwmEnableComposition","UInt",enableBool)
   Else
      MsgBox, 4112, DWM Stop, Dwm cannot applied with these OS version.
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmIsCompositionEnabled (dwmapi.dll)
;
; Aero_IsEnabled()
;
; Return True if DWM is enabled, False if it disabled.
;
; Return: EnabledBool
;
Aero_IsEnabled(){
   global
   If(!MODULEID)
      Aero_StartUp()
   DllCall("dwmapi\DwmIsCompositionEnabled","IntP",_ISENABLED)
   Return,_ISENABLED
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmEnableBlurBehindWindow (dwmapi.dll)
;
; Aero_BlurWindow()
;
; Set a Blur behind a window.
;
; Params:
;
; 1. hwndWin
;    The handle to the window on which the blur behind data is applied.
;
; 2. enableBool (True == 1)
;    TRUE to register the window handle to DWM blur behind; FALSE to unregister the window handle from DWM blur behind.
;
; 3. region (False == 0)
;    The region within the client area to apply the blur behind. A NULL value will apply the blur behind the entire client area.
;
; Return: A_LastError
;
Aero_BlurWindow(hwndWin ,enableBool=1 ,region=0){
   global
   local dwmConstant, DWM_BLURBEHIND
   If(!MODULEID)
      Aero_StartUp()
   If(region)
      dwmConstant:=0x00000001 | 0x00000002 ;DWM_BB_ENABLE | DWM_BB_BLURREGION
   Else
      dwmConstant:=0x00000001 ;DWM_BB_ENABLE
   VarSetCapacity(DWM_BLURBEHIND,16)
      NumPut(dwmConstant,&DWM_BLURBEHIND,0,"UInt")
      NumPut(enableBool,&DWM_BLURBEHIND,4,"UInt")
      NumPut(region,&DWM_BLURBEHIND,8,"UInt")
      NumPut(False,&DWM_BLURBEHIND,12,"UInt")
   DllCall("dwmapi\DwmEnableBlurBehindWindow","Ptr",hwndWin,"Ptr",&DWM_BLURBEHIND)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmEnableBlurBehindWindow (dwmapi.dll)
;
; Aero_GuiBlurWindow()
;
; Set a Blur behind a window.
;
; Params:
;
; 1. GuiNum (deafult == current Gui)
;    Gui Number.
;
; 2. enableBool (True == 1)
;    TRUE to register the window handle to DWM blur behind; FALSE to unregister the window handle from DWM blur behind.
;
; 3. region (False == 0)
;    The region within the client area to apply the blur behind. A NULL value will apply the blur behind the entire client area.
;
; Return: A_LastError
;
Aero_GuiBlurWindow(GuiNum="default" ,enableBool=1 ,region=0){
   global
   local dwmConstant, DWM_BLURBEHIND
   If(!MODULEID)
      Aero_StartUp()
   If(region)
      dwmConstant:=0x00000001 | 0x00000002 ;DWM_BB_ENABLE | DWM_BB_BLURREGION
   Else
      dwmConstant:=0x00000001 ;DWM_BB_ENABLE
   VarSetCapacity(DWM_BLURBEHIND,16)
      NumPut(dwmConstant,&DWM_BLURBEHIND,0,"UInt")
      NumPut(enableBool,&DWM_BLURBEHIND,4,"UInt")
      NumPut(region,&DWM_BLURBEHIND,8,"UInt")
      NumPut(False,&DWM_BLURBEHIND,12,"UInt")
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   DllCall("dwmapi\DwmEnableBlurBehindWindow","Ptr",WinExist(),"Ptr",&DWM_BLURBEHIND)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmExtendFrameIntoClientArea (dwmapi.dll)
;
; Aero_ChangeFrameArea()
;
; Extend the Frame Area into the Client Area.
;
; Params:
;
; 1. hwndWin
;    The handle to the window for which the frame is extended into the client area.
;
; 2. leftPos (0)
;    Width of the left border that retains its size.
;
; 3. rightPos (0)
;    Width of the right border that retains its size.
;
; 2. topPos (0)
;    Height of the top border that retains its size.
;
; 3. bottomPos (0)
;    Height of the bottom border that retains its size.
;
; Return: A_LastError
;
Aero_ChangeFrameArea(hwndWin, leftPos=0, rightPos=0, topPos=0, bottomPos=0){
   global
   local _MARGINS
   If(!MODULEID)
      Aero_StartUp()
   VarSetCapacity(_MARGINS,16)
      NumPut(leftPos,&_MARGINS,0,"UInt")
      NumPut(rightPos,&_MARGINS,4,"UInt")
      NumPut(topPos,&_MARGINS,8,"UInt")
      NumPut(bottomPos,&_MARGINS,12,"UInt")
   DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", hwndWin, "Ptr", &_MARGINS)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmExtendFrameIntoClientArea (dwmapi.dll)
;
; Aero_GuiChangeFrameArea()
;
; Extend the Frame Area into the Client Area.
;
; Params:
;
; 1. GuiNum (default == current Gui)
;    Gui Number.
;
; 2. leftPos (0)
;    Width of the left border that retains its size.
;
; 3. rightPos (0)
;    Width of the right border that retains its size.
;
; 2. topPos (0)
;    Height of the top border that retains its size.
;
; 3. bottomPos (0)
;    Height of the bottom border that retains its size.
;
; Return: A_LastError
;
Aero_GuiChangeFrameArea(GuiNum="default", leftPos=0, rightPos=0, topPos=0, bottomPos=0){
   global
   local _MARGINS
   If(!MODULEID)
      Aero_StartUp()
   VarSetCapacity(_MARGINS,16)
      NumPut(leftPos,&_MARGINS,0,"UInt")
      NumPut(rightPos,&_MARGINS,4,"UInt")
      NumPut(topPos,&_MARGINS,8,"UInt")
      NumPut(bottomPos,&_MARGINS,12,"UInt")
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", WinExist(), "Ptr", &_MARGINS)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmExtendFrameIntoClientArea (dwmapi.dll)
;
; Aero_ChangeFrameAreaAll()
;
; Extend the Frame Area into the whole Client Area.
;
; Params:
;
; 1. hwndWin
;    The handle to the window for which the frame is extended into the client area.
;
; Return: A_LastError
;
Aero_ChangeFrameAreaAll(hwndWin){
   global
   local _AllMARGINS
   If(!MODULEID)
      Aero_StartUp()
   VarSetCapacity(_AllMARGINS,16,-1)
   DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", hwndWin, "Ptr", &_AllMARGINS)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmExtendFrameIntoClientArea (dwmapi.dll)
;
; Aero_GuiChangeFrameAreaAll()
;
; Extend the Frame Area into the whole Client Area.
;
; Params:
;
; 1. GuiNum (default == current Gui)
;    Number of a Gui
;
; Return: A_LastError
;
Aero_GuiChangeFrameAreaAll(GuiNum="default"){
   global
   local _AllMARGINS
   If(!MODULEID)
      Aero_StartUp()
   VarSetCapacity(_AllMARGINS,16,-1)
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", WinExist(), "Ptr", &_AllMARGINS)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DwmGetColorizationColor (dwmapi.dll)
;
; Aero_GetDWMColor()
;
; Gets the Color of the current DWM options.
;
; Return: dwmColor (0xAARRGGBB)
;
Aero_GetDWMColor(){
   global
   local dwmColor, dwmColor2, dwmNotTrans, oldf
   If(!MODULEID)
      Aero_StartUp()
   DllCall("dwmapi\DwmGetColorizationColor", "UIntP", dwmColor, "IntP", dwmNotTrans)
   oldf := A_FormatInteger
   SetFormat,IntegerFast,H
   dwmColor2:=(dwmColor+0) ""
   SetFormat,IntegerFast,%oldf%
   Return,dwmColor2 ""
}
;============================================================================


;============================================================================
; Funktion
; Api Name: DwmGetColorizationColor (dwmapi.dll)
;
; Aero_GetDWMTrans()
;
; Gets the Transparent of the Current DWM options.
;
; Return: dwmTransparent (True==Transparent ; False==Not Transparent)
;
Aero_GetDWMTrans(){
   global
   local dwmColor, dwmNotTrans
   If(!MODULEID)
      Aero_StartUp()
   DllCall("dwmapi\DwmGetColorizationColor", "UIntP", dwmColor, "IntP", dwmNotTrans)
   return !dwmNotTrans
}
;============================================================================


;============================================================================
; Funktion
; Api Name: none ()
;
; Aero_SetDWMColor()
;
; Set�s the DWM Window Color.
;
; Params:
;
; 1. dwmColor
;    A 32 bit Color (0xAARRGGBB)
;
; Return: A_LastError
;
Aero_SetDWMColor(dwmColor=0x910047ab){
   global
   If(!MODULEID)
      Aero_StartUp()
   RegWrite,REG_DWORD,HKCU,Software\Microsoft\Windows\DWM,ColorizationColor,%dwmColor%
   RegWrite,REG_DWORD,HKCU,Software\Microsoft\Windows\DWM,ColorizationAfterglow,%dwmColor%
   DllCall("dwmapi\DwmEnableComposition","UInt",False)
   DllCall("dwmapi\DwmEnableComposition","UInt",True)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: none ()
;
; Aero_SetTrans()
;
; Set�s the DWM Transparent value.
;
; Params:
;
; 1. dwmTrans
;    A Bool. False is transparent, True is not Transparent.
;
; Return: A_LastError
;
Aero_SetTrans(dwmTrans){
   global
   If(!MODULEID)
      Aero_StartUp()
   RegWrite,REG_DWORD,HKCU,Software\Microsoft\Windows\DWM,ColorizationOpaqueBlend,%dwmTrans%
   DllCall("dwmapi\DwmEnableComposition","UInt",False)
   DllCall("dwmapi\DwmEnableComposition","UInt",True)
   Return,A_LastError
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many xD (view in source)
;
; Aero_DrawPicture()
;
; Draws a Picture onto a DWM Gui.
;
; Params:
;
; 1. hwnd
;    Handle of the Window which the Picture is to draw.
;
; 2. picturePath
;    Path to a Picture (All supportet Gdi32 Pictures (also Transparent Pictures))
;
; 3. xPos (0)
;    X Position where the Picture is to draw.
;
; 4. yPos (0)
;    Y Position where the Picture is to draw.
;
; 5. autoUpdate (True==1)
;    Redraw the Picture everytime need it.
;
; Return: The Buffer of the Picture.
;
Aero_DrawPicture(hwnd,picturePath,xPos=0,yPos=0,autoUpdate=1){
   hBuffer := Aero_CreateBuffer(hwnd)
   hImage := Aero_LoadImage(picturePath)
   Aero_DrawImage(hBuffer, hImage, xPos, yPos)
   If(autoUpdate)
      Aero_AutoRepaintGui(hBuffer)
   Aero_DeleteImage(hImage)
   Return,hBuffer
}
;============================================================================


;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_CreateBuffer()
;
; Creates a buffer from a Handle.
;
; Params:
;
; 1. hWnd
;    Handle of the Window which the buffer is applied.
;
; Return: Created buffer.
;
Aero_CreateBuffer(hWnd){
   hDC := DllCall("GetDC", "Ptr", hWnd, "Ptr")
   Return Aero_CreateBufferFromBuffer(hDC)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_CreateGuiBuffer()
;
; Creates a buffer from a GuiCount.
;
; Params:
;
; 1. GuiNum (default==current Gui)
;    Gui number
;
; Return: Created buffer.
;
Aero_CreateGuiBuffer(GuiNum="default"){
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   Return Aero_CreateBuffer(WinExist())
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_DeleteBuffer()
;
; Deletes a buffer.
;
; Params:
;
; 1. hBuffer
;    Handle of a Buffer.
;
; Return: True
;
Aero_DeleteBuffer(byref hBuffer){
   hBitmap := DllCall("GetCurrentObject", "Ptr", hBuffer, "uint", 7, "Ptr")
   DllCall("DeleteDC", "Ptr", hBuffer)
   DllCall("DeleteObject", "Ptr", hBitmap)
   hBuffer := 0
   Return 1
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_UpdateWindow()
;
; Updates a window where is a DWM draw.
;
; Params:
;
; 1. hWnd
;    Handle of the window who is to update.
;
; 2. hBuffer
;    A handle of a Buffer
;
; Return: NonZero if succes otherwise NULL
;
Aero_UpdateWindow(hWnd, hBuffer){
   hDC := DllCall("GetDC", "Ptr", hWnd, "Ptr")
   Return Aero_Blit(hDC, hBuffer)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_UpdateGui()
;
; Updates a window where is a DWM draw.
;
; Params:
;
; 1. hBuffer
;    Handle of a Buffer.
;
; 2. GuiNum (default == current Gui)
;    Gui number.
;
; Return: NonZero if succes otherwise NULL
;
Aero_UpdateGui(hBuffer, GuiNum="default"){
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   Return Aero_UpdateWindow(WinExist(), hBuffer)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_AutoRepaint()
;
; Set a Buffer to Autoredraw, everytime it is need it.
;
; Params:
;
; 1. hWnd
;    Handle of a Window.
;
; 2. hBuffer
;    handle of a Buffer.
;
; Return: Errorlevel
;
Aero_AutoRepaint(hWnd, hBuffer){
   OnMessage(0x0F, "Aero_AutoRepaintCallback")
   Return Aero_AutoRepaintCallback(hBuffer, 0, "register", hWnd)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_AutoRepaintGui()
;
; Set a Buffer to Autoredraw, everytime it is need it.
;
; Params:
;
; 1. hBuffer
;    Handle of a buffer.
;
; 2. GuiNum (default == current Gui)
;    Gui Number.
;
; Return: ErrorLevel
;
Aero_AutoRepaintGui(hBuffer, GuiNum="default"){
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   Return Aero_AutoRepaint(WinExist(), hBuffer)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_DisableAutoRepaint()
;
; Disables the AutoRedraw.
;
; Params:
;
; 1. hWnd
;    Handle of the Window.
;
; Return: True
;
Aero_DisableAutoRepaint(hWnd){
   Aero_AutoRepaint(hWnd, "")
   Return 1
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_DisableAutoRepaintGui()
;
; Disables the AutoRedraw.
;
; Params:
;
; 1. GuiNum (default == current Gui)
;    Gui Number.
;
; Return: True
;
Aero_DisableAutoRepaintGui(GuiNum="default"){
   Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
   Return Aero_DisableAutoRepaint(WinExist())
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_ClearBuffer()
;
; Clears a Buffer.
;
; Params:
;
; 1. hBuffer
;    Handle of a Buffer.
;
; Return: True for succes otherwise False
;
Aero_ClearBuffer(hBuffer){
   VarSetCapacity(Img, 24, 0)
   hBitmap := DllCall("GetCurrentObject", "Ptr", hBuffer, "uint", 7, "Ptr")
   DllCall("GetObject", "Ptr", hBitmap "uInt", 24, "Ptr", &Img)
   VarSetCapacity(rect, 16, 0)
      NumPut(((NumGet(Img, 4, "Int")=0) ? A_ScreenWidth : NumGet(Img, 4, "Int")), rect, 8, "int")
      NumPut(((NumGet(Img, 8, "Int")=0) ? A_ScreenHeight : NumGet(Img, 8, "Int")), rect, 12, "int")
   hBrush := DllCall("CreateSolidBrush", "uint", 0, "Ptr")
   retval := DllCall("FillRect", "Ptr", hBuffer, "Ptr", &rect, "Ptr", hBrush)
   DllCall("DeleteObject", "Ptr", hBrush)
   Return ((retval!=0) ? 1 : 0)
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_LoadImage()
;
; Load image in a variable.
;
; Params:
;
; 1. FileName
;    Path to a Picture (All suportet Gdi32 Pictures)
;
; Return: The Image.
;
Aero_LoadImage(Filename){
   t := DllCall("LoadLibrary", "str", "gdiplus", "Ptr")
   VarSetCapacity(pGdiplusInput, 16, 0)
      NumPut(1, pGdiplusInput, "UInt")
   DllCall("gdiplus\GdiplusStartup", "PtrP", pGdiplusToken, "Ptr", &pGdiplusInput, "Ptr", 0)
   DllCall("gdiplus\GdipCreateBitmapFromFile", "wstr", Filename, "PtrP", GdiplusBitmap)
   DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Ptr", GdiplusBitmap, "Ptr*", hImage, "uint", 0xFF000000)
   DllCall("gdiplus\GdipDisposeImage", "Ptr", GdiplusBitmap)
   DllCall("gdiplus\GdiplusShutdown", "Ptr", pGdiplusToken)
   DllCall("FreeLibrary", "Ptr", t)
   Return hImage
}
;============================================================================

;============================================================================
; Funktion
; Api Name: DeleteObject (Gdi32.dll)
;
; Aero_DeleteImage()
;
; Deletes a loaded image.
;
; Params:
;
; 1. hImage
;    A Image in a variable.
;
; Return: True
;
Aero_DeleteImage(byref hImage){
   DllCall("DeleteObject", "Ptr", hImage)
   hImage := 0
   Return 1
}
;============================================================================

;============================================================================
; Funktion
; Api Name: many (view in source)
;
; Aero_DrawImage()
;
; Draw the Picture on the Window.
;
; Params:
;
; 1. hBuffer
;    Handle to a Buffer
;
; 2. hImage
;    An Image.
;
; 3. x (0)
;    X Position of the Picture
;
; 3. y (0)
;    Y Position of the Picture
;
; 3. alpha (256 (0xFF))
;    Alpha Value.
;
; Return: Selected Buffer.
;
Aero_DrawImage(hBuffer, hImage, x=0, y=0, alpha=0xFF){
   If (hImage = 0)   
      Return 0
   hBufferSrc := DllCall("CreateCompatibleDC", "Ptr", hBuffer, "Ptr")
   DllCall("SelectObject", "Ptr", hBufferSrc, "Ptr", hImage)
   retval := Aero_AlphaBlend(hBuffer, hBufferSrc, x, y, alpha)
   DllCall("DeleteDC", "Ptr", hBufferSrc)
   Return retval
}
;============================================================================

;============================================================================
; Funktion
; Api Name: FreeLibary (Kernel32.dll)
;
; Aero_End()
;
; Unload the dll Files.
;
; Params:
;
; 1. MODUELIDPARAM_ (""nonzero"")
;    The Return MODULID from Aero_StartUp() .
;
; Return: True for succes otherwise False for fail
;
Aero_End(MODUELIDPARAM_=""){
   global
   If(MODUELIDPARAM_)
   {
      StringSplit,MODULEIDARRAY,MODULEID,% "|"
      Loop,%MODULEIDARRAY0%
         DllCall("FreeLibary", "Uint", MODULEIDARRAY%A_Index%)
      Return,True   
   }Else{
      If(MODULEID)
      {
         StringSplit,MODULEIDARRAY,MODULEID,% "|"
         Loop,%MODULEIDARRAY0%
            DllCall("FreeLibary", "Uint", MODULEIDARRAY%A_Index%)
         Return,True   
      }Else{
         MsgBox, 4144, DWM Stop, No Loaded Libarys found.`n`nAero_End() fail !
         Return,False
      }
   }
}
;============================================================================


;============================================================================
;============================================================================
;============================================================================
;=============================PRIVATE FUNKTIONS==============================
;============================================================================
;============================================================================
Aero_CreateBufferFromBuffer(hBuffer)
{
  hNewBuffer := DllCall("CreateCompatibleDC", "Ptr", hBuffer, "Ptr")
  if (hBufferOut=0)
    Return 0
  w := DllCall("GetDeviceCaps", "Ptr", hBuffer, "int", 8)
  h := DllCall("GetDeviceCaps", "Ptr", hBuffer, "int", 10)
  VarSetCapacity(bmi, 40, 0)
  NumPut(40, bmi, 0, "uint")
  NumPut(((w=0) ? A_ScreenWidth : w), bmi, 4, "int")
  NumPut(((h=0) ? A_ScreenHeight : h), bmi, 8, "int")
  NumPut(1, bmi, 12, "ushort")
  NumPut(32, bmi, 14, "ushort")
  hBitmap := DllCall("CreateDIBSection", "Ptr", hBuffer, "Ptr", &bmi, "uint", 0, "PtrP", diBits, "Ptr", 0, "uint", 0, "Ptr")
  if (hBitmap=0)
    Return 0
  DllCall("SelectObject", "Ptr", hNewBuffer, "Ptr", hBitmap)
  Return hNewBuffer
}
;============================================================================
Aero_AutoRepaintCallback(wParam, lParam, msg, hWnd)
{
  static
  oldf := A_FormatInteger
  SetFormat, IntegerFast, h
  hWnd += 0
  SetFormat, IntegerFast, %oldf%
  if (msg="register")
  {
    Buffer%hWnd% := wParam
    Return Aero_UpdateWindow(hWnd, wParam)
  }
  if ((Buffer%hWnd%!=""))
  {
    Aero_UpdateWindow(hWnd, Buffer%hWnd%)
    SendMessage, % msg, % wParam, % lParam,, ahk_id %hWnd%
    Return errorlevel
  }
  SendMessage, % msg, % wParam, % lParam,, ahk_id %hWnd%
  Return errorlevel
}
;============================================================================
Aero_AlphaBlend(hBufferDst, hBufferSrc, x=0, y=0, alpha=0xFF)
{
  VarSetCapacity(ImgSrc, 24, 0)
  VarSetCapacity(ImgDst, 24, 0)
  hBitmapSrc := DllCall("GetCurrentObject", "Ptr", hBufferSrc, "uint", 7, "Ptr")
  hBitmapDst := DllCall("GetCurrentObject", "Ptr", hBufferDst, "uint", 7, "Ptr")
  DllCall("GetObject", "Ptr", hBitmapSrc, "uInt", 24, "Ptr", &ImgSrc)
  DllCall("GetObject", "Ptr", hBitmapDst, "uInt", 24, "Ptr", &ImgDst)
  w := ((NumGet(ImgSrc, 4, "Int")<=NumGet(ImgDst, 4, "Int")) ? NumGet(ImgSrc, 4, "Int") : NumGet(ImgDst, 4, "Int"))
  h := ((NumGet(ImgSrc, 8, "Int")<=NumGet(ImgDst, 8, "Int")) ? NumGet(ImgSrc, 8, "Int") : NumGet(ImgDst, 8, "Int"))
  alpha := ((alpha>0xFF) ? 0xFF : (alpha<0) ? 0 : alpha)
  Return DllCall("GdiAlphaBlend", "Ptr", hBufferDst, "int", x, "int", y, "int", w, "int", h, "Ptr", hBufferSrc
      , "int", 0, "int", 0, "int", w, "int", h, "uint", 0x01000000 | (alpha*0x10000))
}
;============================================================================
Aero_Blit(hBufferDst, hBufferSrc, x=0, y=0)
{
  VarSetCapacity(ImgSrc, 24, 0)
  VarSetCapacity(ImgDst, 24, 0)
  hBitmapSrc := DllCall("GetCurrentObject", "uint", hBufferSrc, "uint", 7)
  hBitmapDst := DllCall("GetCurrentObject", "uint", hBufferDst, "uint", 7)
  DllCall("GetObject", "uInt", hBitmapSrc, "uInt", 24, "uInt", &ImgSrc)
  DllCall("GetObject", "uInt", hBitmapDst, "uInt", 24, "uInt", &ImgDst)
  w := ((NumGet(ImgSrc, 4, "Int")<=NumGet(ImgDst, 4, "Int")) ? NumGet(ImgSrc, 4, "Int") : NumGet(ImgDst, 4, "Int"))
  h := ((NumGet(ImgSrc, 8, "Int")<=NumGet(ImgDst, 8, "Int")) ? NumGet(ImgSrc, 8, "Int") : NumGet(ImgDst, 8, "Int"))
  Return DllCall("BitBlt", "Ptr", hBufferDst, "int", x, "int", y, "int", w, "int", h, "Ptr", hBufferSrc
      , "int", 0, "int", 0, "uint", 0xCC0020)
}
;============================================================================

Aero_DrawText(hBuffer, Text, x=10, y=10, color="", glowsize=14) ;BUGGY , DONT WORK , DONT USE IT
{
  Gui, +LastFound ;Zum verwenden des Theme
  hTheme := DllCall("uxtheme\OpenThemeData", "Ptr", WinExist(), "wstr", "CompositedWindow::Window", "Ptr")
  hTmpBuffer := Aero_CreateBufferFromBuffer(hBuffer)
  hFont := DllCall("GetCurrentObject", "Ptr", hBuffer, "uint", 6, "Ptr")
  DllCall("SelectObject", "Ptr", hTmpBuffer, "Ptr", hFont)

  VarSetCapacity(Img, 24, 0)
  hBitmap := DllCall("GetCurrentObject", "Ptr", hBuffer, "uint", 7, "Ptr")
  DllCall("GetObject", "Ptr", hBitmap, "uint", 24, "Ptr", &Img)

  VarSetCapacity(rect, 16, 0)
  NumPut(x, rect, 0, "int")
  NumPut(y, rect, 4, "int")
  NumPut(NumGet(Img, 4, "Int")-x, rect, 8, "int")
  NumPut(NumGet(Img, 8, "Int")-y, rect, 12, "int")

  VarSetCapacity(dttopts, 64, 0)
  NumPut(64, dttopts, 0, "uint") ;dwSize
  NumPut(0x2800 + ((color!="") ? 1 : 0), dttopts, 4, "uint") ;dwFlags (DTT_COMPOSITED | DTT_GLOWSIZE)
  if (color!="")
    NumPut(((color&0xFF0000)>>16) | (color&0xFF00) | ((color&0xFF)<<16), dttopts, 8, "uint") ;RGB to BGR
  NumPut(glowsize, dttopts, 52, "int")

  DllCall("uxtheme\DrawThemeTextEx", "Ptr", hTheme, "Ptr", hTmpBuffer, "int", 0, "int", 0, "wstr", Text, "int", -1, "uint", 0x40000, "Ptr", &rect, "Ptr", &dttopts)
  Aero_AlphaBlend(hBuffer, hTmpBuffer)
  Aero_DeleteBuffer(hTmpBuffer)
}

Aero_UseFont(hWnd, hBuffer)
{
  hDC := DllCall("GetDC", "Ptr", hWnd, "Ptr")
  hFont := DllCall("GetCurrentObject", "Ptr", hDC, "uint", 6, "Ptr")
  DllCall("SelectObject", "Ptr", hBuffer, "Ptr", hFont)
  return 1
}

Aero_UseGuiFont(hBuffer, GuiNum="default")
{
  Gui, % ((GuiNum="default") ? "" : GuiNum ":") "+LastFound"
  return Aero_UseFont(WinExist(), hBuffer)
}

IDE_DrawTransImage(hwnd,Path="")
{
   If(!Path)
      Return,False
   hDC := DllCall("GetDC", "Ptr", hwnd, "Ptr")
   hBuffer:=Aero_CreateBuffer(hwnd)
   hImage:=Aero_LoadImage(Path)
   hBuffer:=Aero_DrawImage(hBuffer, hImage)
   Aero_Blit(hDC, hBuffer)
   Aero_DeleteImage(hImage)
}


Note: I've dropped support for Basic.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2011, 11:25 am 
any idea how/where can i find/change the default transparency color in this function? :/


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2011, 8:32 pm 
Offline

Joined: May 8th, 2008, 2:58 pm
Posts: 39
Location: C:\ESTONIA\adavere\RIST.rar
Image
Code:
#Include Aero_Lib.ahk

Aero_StartUp() ;Start Aero Libary

Gui,+LastFound ;Gui LastFound
MainHandle:=WinExist() ;get Handle of the Gui
Aero_ChangeFrameAreaAll(MainHandle) ;Extend the Fram Area over the whole Dwm Window
Gui,Show, w677 h300,Administrator: C:\Windows\system32\cmd.exe

; Styles we want to remove from the console window:
WS_POPUP := 0x80000000
WS_CAPTION := 0xC00000
WS_THICKFRAME := 0x40000
WS_EX_CLIENTEDGE := 0x200

; Styles we want to add to the console window:
WS_CHILD := 0x40000000

; Styles we want to add to the Gui:
WS_CLIPCHILDREN := 0x2000000

; Flags for SetWindowPos:
SWP_NOACTIVATE := 0x10
SWP_SHOWWINDOW := 0x40
SWP_NOSENDCHANGING := 0x400

; Create Gui and get window ID.
Gui, +LastFound +%WS_CLIPCHILDREN%
GuiWindow := WinExist()

; Launch hidden cmd.exe and store process ID in pid.
Run, %ComSpec%,, Hide, pid

; Wait for console window to be created, store its ID.
DetectHiddenWindows, On
WinWait, ahk_pid %pid%
ConsoleWindow := WinExist()

; Get size of console window, excluding caption and borders:
VarSetCapacity(ConsoleRect, 16)
DllCall("GetClientRect", "uint", ConsoleWindow, "uint", &ConsoleRect)
ConsoleWidth := NumGet(ConsoleRect, 8)
ConsoleHeight:= NumGet(ConsoleRect, 12)

; Apply necessary style changes.
WinSet, Style, % -(WS_POPUP|WS_CAPTION|WS_THICKFRAME)
WinSet, Style, +%WS_CHILD%
WinSet, ExStyle, -%WS_EX_CLIENTEDGE%

; Put the console into the Gui.
DllCall("SetParent", "uint", ConsoleWindow, "uint", GuiWindow)

; Move and resize console window. Note that if SWP_NOSENDCHANGING
; is omitted, it incorrectly readjusts the size of its client area.
DllCall("SetWindowPos", "uint", ConsoleWindow, "uint", 0
    , "int", 0, "int", 0, "int", ConsoleWidth, "int", ConsoleHeight
    , "uint", SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOSENDCHANGING)

; Show the Gui. Specify width since auto-sizing won't account for the console.
;Gui, Show, % "W" ConsoleWidth+0
W1:=(ConsoleWidth+0)
Gui, Show,x180 y180 w%W1%

; Be sure to close cmd.exe later.
OnExit, Exiting

; If cmd.exe exits prematurely, fall through to ExitApp below.
Process, WaitClose, %pid%

GuiEscape:
GuiClose:
Exiting:
OnExit
Process, Close, %pid% ; May be a bit forceful? No effect if it already closed.
ExitApp

:)
http://www.autohotkey.com/forum/post-278986.html#278986

_________________
Keegi Siin ka Eestlane? :)


Last edited by RIST on January 6th, 2012, 11:59 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2011, 5:59 am 
Well, I've always used and loved XP... But I told myself that if I ever got a third PC (Since I won't upgrade my OSs) that this would be the first thing I toy around with. Look forward to trying it on my new laptop. :).


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Google [Bot], rbrtryn, Stigg and 26 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group