Hallo Leute,
in meinem Folgenden Skript wird mir ein merkwürdiger Fehler in der GDIPlus.au3 von AutoIt gemeldet. Das Skript soll jede Minute den Hintergrund ändern und dort z.B. die Uhrzeit anzeigen.
Nun kommt aber immer dieser Fehler
"C:\Program Files\AutoIt3\Include\GDIPlus.au3" (1661) : ==> Subscript used with non-Array variable.:
Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo^ ERROR
->21:09:00 AutoIt3.exe ended.rc:1
>Exit code: 1 Time: 33.472
Spoiler anzeigen
#include <Date.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
$sTime = _NowTime(4)
[/autoit] [autoit][/autoit] [autoit]While Sleep(20)
If $sTime <> _NowTime(4) Then
$sTime = _NowTime(4)
_New_Background($sTime)
;MsgBox(0, "", "Change")
EndIf
WEnd
Func _New_Background($Time)
Local $hGUI = GUICreate("BG-Dummy",@DesktopWidth,@DesktopHeight)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopWidth,@DesktopHeight,$hGraphic)
Local $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Local $hRed = _GDIPlus_BrushCreateSolid(0x99FF0000)
_GDIPlus_GraphicsFillEllipse($hBuffer,(@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 100,200,100,$hRed)
Local $iTextWidth = _GetTextLabelWidth($Time,"Arial",10)
ConsoleWrite($iTextWidth & @CRLF)
_GDIPlus_GraphicsDrawString($hBuffer,$Time,(@DesktopWidth / 2) - ($iTextWidth / 2),(@DesktopHeight / 2) - 5,"Arial",10,0x0001)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap,0,0)
;_GDIPlus_ImageSaveToFile($hBitmap,@TempDir & "\Image_" & StringReplace($Time,":","_") & ".jpg")
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", "0")
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", "0")
DllCall("user32.dll", "int", "SystemParametersInfo","uint",20,"uint",0,"str",$hBitmap,"uint",3)
EndFunc ;==>_New_Background
[/autoit] [autoit][/autoit] [autoit]Func _GetTextLabelWidth($s_WinText, $s_TextFont, $i_FontSize, $i_FontWeight = -1)
Local Const $DEFAULT_CHARSET = 0 ; ANSI character set
Local Const $OUT_CHARACTER_PRECIS = 2
Local Const $CLIP_DEFAULT_PRECIS = 0
Local Const $PROOF_QUALITY = 2
Local Const $FIXED_PITCH = 1
Local Const $RGN_XOR = 3
Local Const $LOGPIXELSY = 90
Local Const $dUser32 = DllOpen("user32.dll"), $dGDI32 = DllOpen("gdi32.dll"), $dKERN32 = DllOpen("kernel32.dll")
$h_WinTitle = "Get Label Width"
If $i_FontWeight = "" Or $i_FontWeight = -1 Then $i_FontWeight = 600 ; default Font weight
Local $h_GUI = GUICreate($h_WinTitle, 10, 10, -100, -100, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
Local $hDC = DllCall($dUser32, "int", "GetDC", "hwnd", $h_GUI)
Local $intDeviceCap = DllCall($dGDI32, "long", "GetDeviceCaps", "int", $hDC[0], "long", $LOGPIXELSY)
$intDeviceCap = $intDeviceCap[0]
Local $intFontHeight = DllCall($dKERN32, "long", "MulDiv", "long", $i_FontSize, "long", $intDeviceCap, "long", 72)
$intFontHeight = -$intFontHeight[0]
Local $hMyFont = DllCall($dGDI32, "hwnd", "CreateFont", "int", $intFontHeight, "int", 0, "int", 0, "int", 0, "int", $i_FontWeight, "int", 0, "int", 0, "int", 0, "int", $DEFAULT_CHARSET, "int", $OUT_CHARACTER_PRECIS, "int", $CLIP_DEFAULT_PRECIS, "int", $PROOF_QUALITY, "int", $FIXED_PITCH, "str", $s_TextFont)
DllCall($dGDI32, "hwnd", "SelectObject", "int", $hDC[0], "hwnd", $hMyFont[0])
Local $res = DllStructCreate("int;int")
Local $ret = DllCall($dGDI32, "int", "GetTextExtentPoint32", "int", $hDC[0], "str", $s_WinText, "long", StringLen($s_WinText), "ptr", DllStructGetPtr($res))
Local $intLabelWidth = DllStructGetData($res, 1)
GUIDelete($h_GUI)
Return $intLabelWidth
EndFunc ;==>_GetTextLabelWidth
Könnte mir jemand erklären wieso der Fehler in der GDIPlus.au3 liegt und wie man ihn behebt?
Vielen Dank