Hallo,
Ich habe eine Desktop Udf geschrieben.
Es war ein mehr Arbeit als gedacht aber hier ist das Ergebnis ![]()
Es gibt eigentlich gar nicht viel dazu zu sagen, die Funktionen sind im Script ausführlich beschrieben.
Code
#include <GdiPlus.au3>
[/autoit] [autoit][/autoit] [autoit]Global Const $Wallpaper = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ======================================================================================
; Name ..........: _GDIPlus_DrawImageToDesktop()
; Description ...: Malt ein Bild auf den Desktop das bei beenden des Scriptes wieder verschwindet.
; Syntax ........: _GDIPlus_DrawImageToDesktop($ImagePath,$posX,$posY[,$output = 'C:\WallpaperBackup.bmp'])
; Parameters ....: $ImagePath - Pfad zum Bild
; $posX - Positon auf der Y Achse
; $posY - Positon auf der Y Achse
; $output- [optional] Pfad an dem der erstellte Desktop zwischengespeichert wird. (default:'C:\WallpaperBackup.bmp')
; Author ........: Ubuntu
; Remarks .......: All rights reserved by Ubuntu
; Related .......: _GDIPlus_DrawStringToDesktop
; =================================================================================================
Func _GDIPlus_DrawImageToDesktop($ImagePath,$posX,$posY,$output = 'C:\WallpaperBackup.bmp')
OnAutoItExitRegister("Wallpaper_Clear")
$LoadWallpaper = _GDIPlus_ImageLoadFromFile($Wallpaper)
$Image = _GDIPlus_ImageLoadFromFile($ImagePath)
$hGraphics = _GDIPlus_ImageGetGraphicsContext ($LoadWallpaper)
_GDIPlus_GraphicsDrawImage($hGraphics, $Image, $posX, $posY)
_GDIPlus_ImageSaveToFile($LoadWallpaper,$output)
_GDIPlus_ImageDispose($LoadWallpaper)
_GDIPlus_ImageDispose($Image)
DllCall("user32.dll", "int", "SystemParametersInfo", "uint", 20, "uint", 0, "str", $output, "uint", BitOR(0x2,0x1))
EndFunc
; #FUNCTION# ======================================================================================
; Name ..........: _GDIPlus_DrawStringToDesktop()
; Description ...: Malt einen String auf den Desktop der bei beenden des Scriptes wieder verschwindet.
; Syntax ........: _GDIPlus_DrawStringToDesktop($String,$posX,$posY[,$Font = 'Arial'[,$FontSize = '24'[,$output = 'C:\WallpaperBackup.bmp'[,$color = 0xFF00FF00]]]])
; Parameters ....: $String - String der angezeigt werden soll
; $posX - Positon auf der Y Achse
; $posY - Positon auf der Y Achse
; $Font - [optional] (default:'Arial')
; $FontSize - [optional] (default:'24')
; $output - [optional] Pfad an dem der erstellte Desktop zwischengespeichert wird. (default:'C:\WallpaperBackup.bmp')
; $color- [optional] (default:0xFF00FF00)
; Author ........: Ubuntu
; Remarks .......: All rights reserved by Ubuntu
; Related .......: _GDIPlus_DrawImageToDesktop
; =================================================================================================
Func _GDIPlus_DrawStringToDesktop($String,$posX,$posY,$Font = 'Arial',$FontSize = '24',$output = 'C:\WallpaperBackup.bmp',$color = 0xFF00FF00)
OnAutoItExitRegister("Wallpaper_Clear")
$LoadWallpaper = _GDIPlus_ImageLoadFromFile($Wallpaper)
$hGraphics = _GDIPlus_ImageGetGraphicsContext ($LoadWallpaper)
$hBrush = _GDIPlus_BrushCreateSolid($color)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($Font)
$hFont = _GDIPlus_FontCreate($hFamily, $FontSize, 2)
$tLayout = _GDIPlus_RectFCreate($posX,$posY)
$Layout = _GDIPlus_GraphicsMeasureString($hGraphics, $String, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphics, $String, $hFont, $Layout[0], $hFormat, $hBrush)
_GDIPlus_ImageSaveToFile($LoadWallpaper,$output)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_ImageDispose($LoadWallpaper)
DllCall("user32.dll", "int", "SystemParametersInfo", "uint", 20, "uint", 0, "str", $output, "uint", BitOR(0x2,0x1))
EndFunc
; #FUNCTION# ======================================================================================
; Name ..........: _DesktopRestore()
; Description ...: Aktualisiert den Desktop
; Syntax ........: _DesktopRestore([$output = $Wallpaper])
; Parameters ....: $output - [optional] Pfad an dem der erstellte Desktop zwischengespeichert wird. (default:$Wallpaper)
; Remarks .......: All rights reserved by Ubuntu
; =================================================================================================
Func _DesktopRestore($output = $Wallpaper)
DllCall("user32.dll", "int", "SystemParametersInfo", "uint", 20, "uint", 0, "str", $output, "uint", BitOR(0x2,0x1))
EndFunc
; #FUNCTION# ======================================================================================
; Name ..........: Wallpaper_Clear()
; Description ...: Just internal use.
; =================================================================================================
Func Wallpaper_Clear()
DllCall("user32.dll", "int", "SystemParametersInfo", "uint", 20, "uint", 0, "str", $Wallpaper, "uint", BitOR(0x2,0x1))
EndFunc
Beispiel
#include "DrawToDesktop-Udf.au3"
#include <GdiPLus.au3>;muss nicht sein
#RequireAdmin ;unter Vista oder Win7
_GDIPlus_Startup()
_GDIPlus_DrawImageToDesktop("C:\_D_\meinBild.gif",200,200);bei Draw_string ist es das gleiche
Sleep(3000)
_GDIPlus_Shutdown()
_DesktopRestore()
Exit
mfg Ubuntu
Edit: WICHTIG: Die Bilder können wenn der Desktop hintergrund verzerrt ist ebenfalls verzerrt sein.