Das Ding läuft auch unter Vista+, wenn Aero abgeschaltet ist (macht das Skript)!
eukalyptus: gleiches gilt auch für deine beiden Skripte (BlackHole und Mauslupe)!
Gruß,
UEZ
Das Ding läuft auch unter Vista+, wenn Aero abgeschaltet ist (macht das Skript)!
eukalyptus: gleiches gilt auch für deine beiden Skripte (BlackHole und Mauslupe)!
Gruß,
UEZ
Klasse! Hast das Skript richtig gut optimiert ![]()
Das mit ClientToScreen() ist ja optimal, um die Position unabhängig vom Theme zu bekommen! ![]()
Wie gesagt, verwende ich WinXP nur noch sehr selten und der Aero Effekt ab Vista sieht echt klasse aus, zumal Win7 richtig stabil und schnell läuft.
Diesen Effekt hätte man vor 4 Jahren gut gebrauchen können, aber heute ist das "nur" noch eine Demo.
BlackHole und Mauslupe sind super Effekte ![]()
Gruß,
UEZ
Beim Testen von Windows Screenhooter unter WinXP ist mir aufgefallen, dass ich den Bildschirm hinter einer GUI herauslesen und darstellen kann.
Da kam mir die Idee, ob sich unter WinXP ein Aero Effekt implementieren lässt!
Heraus kam das Ding hier (optimierte Version von eukalyptus weiter unten!):
;Pseudo Aero Look für WindowsXP Build 2011-12-02 by UEZ
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global Const $hDwmApiDll = DllOpen("dwmapi.dll")
Global $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $aero = DllStructGetData($sChkAero, 1)
If $aero Then DllCall($hDwmApiDll, "int", "DwmEnableComposition", "uint", False)
Global $dy
If @OSBuild < 6000 Then
Global $aTheme = _WinAPI_GetCurrentThemeName()
If Not @error Then
$dy = -54
Else
$dy = -40
EndIf
Else
$dy = -47
EndIf
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]")
Global Const $aFullScreen = WinGetPos($hFullScreen)
Global Const $fW = 4
Global Const $fH = 32
Global Const $iW = 640
Global Const $iH = 400
Global Const $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_OVERLAPPEDWINDOW + $WS_EX_TOPMOST)
Global Const $idTitle = GUICtrlCreateLabel("Pseudo Aero Effect by UEZ", $fW + 16, $fh / 3, 150, 16)
GUICtrlSetFont(-1, 9, 800, 0, "Arial", 4)
GUICtrlSetBkColor(-1, -2)
;~ Global Const $idLabel = GUICtrlCreateLabel(@LF & @LF & @LF & @TAB & "Done by UEZ 2011", $fW, $fH, $iW - 2 * $fW - 2, $iH - $fH - $fW)
;~ GUICtrlSetFont(-1, 30, 400, 0, "Arial", 4)
;~ GUICtrlSetBkColor(-1, -2)
Global Const $idLabel_Min = GUICtrlCreateLabel("[_]", $iW - 50, $fH / 3, $fh / 2, $fh / 2)
GUICtrlSetBkColor(-1, -2)
Global Const $idLabel_Close = GUICtrlCreateLabel("[X]", $iW - 30, $fH / 3, $fh / 2, $fh / 2)
GUICtrlSetBkColor(-1, -2)
WinSetTrans($hGUI, "", 0xFF)
[/autoit] [autoit][/autoit] [autoit]Global Const $hGUI_Hidden = GUICreate("", $iW, $iH, 0, 0, Default, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hGUI)
GUISetState(@SW_HIDE, $hGUI_Hidden)
GUISetState(@SW_SHOW, $hGUI)
_SetGuiRoundCorners($hGUI, 16, True, False, True, False)
Global $hDev = _WinAPI_GetDC($hGUI)
Global $hDC_Area = _WinAPI_CreateCompatibleDC($hDev)
Global $hBitmap_Area = _WinAPI_CreateCompatibleBitmap($hDev, $aFullScreen[2], $aFullScreen[3])
Global Const $hDC_Zoom = _WinAPI_GetDC(0)
Global Const $hGUI_ZoomDC = _WinAPI_GetDC($hGUI_Hidden)
Global Const $memDC = _WinAPI_CreateCompatibleDC($hGUI_ZoomDC)
Global Const $memBmp = _WinAPI_CreateCompatibleBitmap($hGUI_ZoomDC, $iW, $iH)
_WinAPI_SelectObject($memDC, $memBmp)
Global $aPos = WinGetPos($hGUI)
_WinAPI_StretchBlt($hGUI_ZoomDC, 0, 0, $iW, $iH, $hDC_Zoom, $aPos[0], $aPos[1], $iW, $iH, $SRCCOPY)
_WinAPI_BitBlt($memDC, 0, 0, $iW, $iH, $hGUI_ZoomDC, 0, $dy, 0x00CC0020)
[/autoit] [autoit][/autoit] [autoit]Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global Const $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic)
Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global Const $GW_CHILD = 5
Global Const $GW_HWNDNEXT = 2
Global $hRegion = _GDIPlus_RegionCreateFromRect(_GDIPlus_RectFCreate(0, 0, $iW, $iH))
Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD)
Global $aRect, $msg
Do
$aRect = ControlGetPos($hChild, "", 0)
_GDIPlus_RegionCombineRect($hRegion, _GDIPlus_RectFCreate($aRect[0], $aRect[1], $aRect[2], $aRect[3]), 3)
$hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
Until Not $hChild
_GDIPlus_GraphicsSetClipRegion($hGraphic, $hRegion)
_GDIPlus_RegionDispose($hRegion)
Global $tRectF = _GDIPlus_RectFCreate(0, 0, $iW / 1.5, $iH / 1.5)
Global $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRectF, 0x80201010, 0xA0F0F0F0, -60, False, 1)
Global $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($memBmp)
Global $hBmp_Blur = _Blur($hBmp, $iW, $iH)
_GDIPlus_GraphicsDrawImage($hContext, $hBmp_Blur, 0, 0)
_GDIPlus_GraphicsFillRect($hContext, 0, 0, $iW, $iH, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_BitmapDispose($hBmp_Blur)
GUIRegisterMsg($WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
Global $exit = False
[/autoit] [autoit][/autoit] [autoit]GUISetOnEvent($GUI_EVENT_RESTORE, "Restored", $hGUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI)
GUICtrlSetOnEvent($idLabel_Close, "_Exit")
GUICtrlSetOnEvent($idLabel_Min, "_MinWin")
While Sleep(30)
;~ Repaint()
If $exit Then ExitLoop
WEnd
GUIRegisterMsg($WM_WINDOWPOSCHANGED, "")
_WinAPI_DeleteDC($memDC)
_WinAPI_DeleteObject($memBmp)
_WinAPI_DeleteObject($hBitmap_Area)
_WinAPI_ReleaseDC($hGUI, $hDev)
_WinAPI_ReleaseDC($hGUI, $hGUI_ZoomDC)
_WinAPI_ReleaseDC(0, $hDC_Zoom)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete()
$tRectF = 0
If $aero Then DllCall($hDwmApiDll, "int", "DwmEnableComposition", "uint", True)
Exit
Func _Exit()
$exit = True
EndFunc
Func _MinWin()
GUISetState(@SW_MINIMIZE, $hGUI)
EndFunc
Func Restored()
Repaint()
EndFunc
Func WM_WINDOWPOSCHANGED($hWnd, $iMsg, $StartWIndowPosaram, $lParam)
Repaint()
Return "GUI_RUNDEFMSG"
EndFunc
Func Repaint()
$aPos = WinGetPos($hGUI)
_WinAPI_StretchBlt($hGUI_ZoomDC, 0, 0, $iW, $iH, $hDC_Zoom, $aPos[0]+16, $aPos[1] + 3, $iW, $iH, $SRCCOPY)
_WinAPI_BitBlt($memDC, 0, 0, $iW, $iH, $hGUI_ZoomDC, 0, $dy, 0x00CC0020)
DllStructSetData($tRectF, "X", $aPos[0])
DllStructSetData($tRectF, "Y", $aPos[1])
$hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRectF, 0x80302020, 0xA0F0F0F0, -60, False, 1)
$hBmp = _GDIPlus_BitmapCreateFromHBITMAP($memBmp)
$hBmp_Blur = _Blur($hBmp, $iW, $iH)
_GDIPlus_GraphicsDrawImage($hContext, $hBmp_Blur, 0, 0)
_GDIPlus_GraphicsFillRect($hContext, 0, 0, $iW, $iH, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_BitmapDispose($hBmp_Blur)
_GDIPlus_BrushDispose($hBrush)
EndFunc
Func WM_NCHITTEST($hWndGUI, $MsgID, $WParam, $LParam)
If ($hWndGUI = $hGui) And ($MsgID = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func _Blur($hBitmap, $iW, $iH, $fScale = 0.30, $qual = 6); by eukalyptus
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBmpSmall = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Local $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxSmall, "int", 2)
Local $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxBig, "int", 2)
_GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale)
_GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $qual)
_GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale)
_GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $qual)
_GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, 0, $iW, $iH)
_GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, 0, $iW, $iH)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBmpSmall)
_GDIPlus_GraphicsDispose($hGfxSmall)
_GDIPlus_GraphicsDispose($hGfxBig)
Return $hBmpBig
EndFunc ;==>_Blur
Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop)
Local $Ret = DllCall("gdi32.dll", "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidthDest, "int", $iHeightDest, "hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc, "int", $iWidthSrc, "int", $iHeightSrc, "dword", $iRop)
If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0)
Return 1
EndFunc ;==>_WinAPI_StretchBlt
; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetCurrentThemeName
; Description....: Retrieves the name of the current visual styles, color scheme name, and size name.
; Syntax.........: _WinAPI_GetCurrentThemeName ( )
; Parameters.....: None
; Return values..: Success - The array that contains the following information:
;
; [0] - The theme path and file name.
; [1] - The color scheme name.
; [2] - The size name.
;
; Failure - 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.
; Author.........: Yashied
; Modified.......:
; Remarks........: None
; Related........:
; Link...........: @@MsdnLink@@ GetCurrentThemeName
; Example........: Yes
; ===============================================================================================================================
Func _WinAPI_GetCurrentThemeName()
Local $Ret = DllCall('uxtheme.dll', 'uint', 'GetCurrentThemeName', 'wstr', '', 'int', 4096, 'wstr', '', 'int', 2048, 'wstr', '', 'int', 2048)
If @error Then
Return SetError(1, 0, 0)
Else
If $Ret[0] Then
Return SetError(1, $Ret[0], 0)
EndIf
EndIf
Local $Result[3]
For $i = 0 To 2
$Result[$i] = $Ret[$i * 2 + 1]
Next
Return $Result
EndFunc ;==>_WinAPI_GetCurrentThemeName
Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True)
Local $hCornerRgn
Local $aGuiSize = WinGetPos($hGUI)
Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse)
If $iLeftUp = False Then
$hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2)
_WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR)
_WinAPI_DeleteObject($hCornerRgn)
EndIf
If $iLeftDown = False Then
$hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3])
_WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR)
_WinAPI_DeleteObject($hCornerRgn)
EndIf
If $iRightUp = False Then
$hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2)
_WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR)
_WinAPI_DeleteObject($hCornerRgn)
EndIf
If $iRightDown = False Then
$hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2] - 1, $aGuiSize[3] - 1)
_WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR)
_WinAPI_DeleteObject($hCornerRgn)
EndIf
_WinAPI_SetWindowRgn($hGUI, $hRgn)
EndFunc ;==>_SetGuiRoundCorners
#region additional GDI+ functions
Func _GDIPlus_GraphicsScaleTransform($hGraphics, $nScaleX, $nScaleY, $iOrder = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGraphics, "float", $nScaleX, "float", $nScaleY, "int", $iOrder)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsScaleTransform
Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphics, "int", $iInterpolationMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode
Func _GDIPlus_LineBrushCreateFromRectWithAngle($tRectF, $iARGBClr1, $iARGBClr2, $nAngle, $fIsAngleScalable = True, $iWrapMode = 0)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrushFromRectWithAngle", "ptr", $pRectF, "uint", $iARGBClr1, "uint", $iARGBClr2, "float", $nAngle, "int", $fIsAngleScalable, "int", $iWrapMode, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[7]
EndFunc ;==>_GDIPlus_LineBrushCreateFromRectWithAngle
Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRegion", "hwnd", $hGraphics, "hwnd", $hRegion, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc
Func _GDIPlus_RegionCreateFromRect($tRectF)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", $pRectF, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[2]
EndFunc
Func _GDIPlus_RegionCombineRect($hRegion, $tRectF, $iCombineMode = 2)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion, "ptr", $pRectF, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc
Func _GDIPlus_RegionDispose($hRegion)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc
#endregion
Ich persönlich benutze WinXP zum Kompatibilitätstest, wenn ich Lust habe und somit ist dies wirklich nur als experimentell anzusehen!
Einige Dinge, wie z.B. ständiges Update oder transparente Label fehlen noch. Wer Lust hat, kann ja herum basteln!
Außerdem ist das Ganze etwas langsam. Wenn die klassische Ansicht aktiviert ist, muss der Parameter für _WinAPI_BitBlt($memDC, 0, 0, $iW, $iH, $hGUI_ZoomDC, 0, -52, 0x00CC0020) auf -38 angepasst werden, damit die Darstellung einigermaßen stimmt.
Wenn jemand eine Möglichkeit kennt zwischen der klassischen Ansicht und Luna zu unterscheiden, dann her damit.
Gruß,
UEZ
Vielleicht das hier: [UDF] (Teil)transparente Bilder-GUIs nach einem Rezept von Meister UEZ
Das mit dem Meister darfst du nicht so ernst nehmen ![]()
Gruß,
UEZ
Schon mal im Forum gesucht?
Gruß,
UEZ
Kann es sein das leere Ordner nicht mitkopiert werden? Kann man den Timestamp vielleicht auch mitkopieren?
Ferner ist eine Restdauer Anzeige in Sekunden nicht leicht zu interpretieren; hh:mm:ss wäre da besser. Vielleicht sogar eine "verstrichene Zeit" als Info.
Wie wäre es mit einer Sicherung in ein Archive Format, wie z.B. ZIP?
Gruß,
UEZ
Happy Birthday euch beiden!
Gruß,
UEZ
Salut wakillon,
merci de vos commentaires - devrait maintenant fonctionner parfaitement.
Cordialement,
UEZ
Du kannst auch ein Bild laden und es in den Button senden. Siehe hier: File to Base64 String Code Generator v1.03 Build 2011-11-21 (1. Beispiel).
Oder:
;By Malkey
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
[/autoit] [autoit][/autoit] [autoit]Global $hGUI, $hGraphicGUI, $hBMPBuff
[/autoit] [autoit][/autoit] [autoit]_Main()
Func _Main()
Local $hBMP, $hBitmap, $hGraphic, $hImage, $iX, $iY, $hClone, $t, $aMPos
Local $GuiSizeX = 400, $GuiSizeY = 300
Local $pngFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") _
& "\Examples\GUI\Advanced\Images\Button.png"
; Create GUI
$hGUI = GUICreate("GDI+", $GuiSizeX, $GuiSizeY)
;GUISetBkColor(0xFFFFEF)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBitmap = _GDIPlus_ImageLoadFromFile($pngFile)
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)
GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize.
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
Do
$aMPos = MouseGetPos()
If ispressed("01") Then
Select
Case _WinAPI_PtInRectEx($aMPos[0], $aMPos[1], 5, 5, 112, 56)
MsgBox(0, "", " Top button clicked", 1)
Case _PointInEllipse($aMPos[0], $aMPos[1], 122, 100, 132, 45)
MsgBox(0, "", "Middle elliptic button clicked", 1)
Case _WinAPI_PtInRectEx($aMPos[0], $aMPos[1], 5, 192, 112, 243)
MsgBox(0, "", "Lowest button clicked", 1)
EndSelect
EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphicGUI)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBMPBuff)
_GDIPlus_Shutdown()
EndFunc ;==>_Main
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; ($xPt, $yPt) - x, y position of the point to check
; $xTL, $yTL, Top left x Pos, top left Y position of the rectangle encompassing the ellipse.
; $w, $h - The width an height of ellipse
; http://www.autoitscript.com/forum/index.ph…ndpost&p=639786
;
Func _PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
Local $bInside = False, $a = $w / 2, $b = $h / 2
Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
$c1X = $xc - ($a ^ 2 - $b ^ 2) ^ (1 / 2); 1st focal point x position
$c2X = $xc + ($a ^ 2 - $b ^ 2) ^ (1 / 2); 2nd focal point x position
$dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
If $dist <= $w Then $bInside = Not $bInside
Return $bInside
EndFunc ;==>_PointInEllipse
; ($iX, $iY) - x, y position of the point to check
; ($iLeft, $iTop) - x, y position of the top left corner of rectangle
; ($iRight, $iBottom) - x, y position of the bottom right corner of rectangle
; http://www.autoitscript.com/forum/index.ph…ndpost&p=639786
;
Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom)
Local $aResult
Local $tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, "Left", $iLeft)
DllStructSetData($tRect, "Top", $iTop)
DllStructSetData($tRect, "Right", $iRight)
DllStructSetData($tRect, "Bottom", $iBottom)
$aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0] <> 0
EndFunc ;==>_WinAPI_PtInRectEx
; Copied from ...\Include\Misc.au3 File
Func IsPressed($sHexKey)
Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x' & $sHexKey)
If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
Return 0
EndFunc ;==>IsPressed
;Func to redraw on PAINT MSG
Func MY_PAINT($hWnd, $msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
_WinAPI_RedrawWindow($hGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_FRAME, $RDW_ALLCHILDREN)) ;
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_PAINT
Oder:
;By smashly
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
_Main()
[/autoit] [autoit][/autoit] [autoit]Func _Main()
Local $hGUI, $iPicButton, $hGraphic, $hImage, $hBitmap1, $hGraphic1, $hBMP1, $iMsg
Local $pngFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") _
& "\Examples\GUI\Advanced\Images\Button.png"
$hGUI = GUICreate("GDI+", 400, 300)
GUISetBkColor(0x000000, $hGUI)
$iPicButton = GUICtrlCreatePic("", 10, 10, 82, 36)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hImage = _GDIPlus_ImageLoadFromFile($pngFile)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap1 = _GDIPlus_BitmapCreateFromGraphics(82, 36, $hGraphic)
$hGraphic1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic1, $hImage, 11, 145, 82, 36, 0, 0, 82, 36)
$hBMP1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap1)
_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_BitmapDispose($hBitmap1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
_WinAPI_DeleteObject(GUICtrlSendMsg($iPicButton, 0x0172, 0, $hBMP1))
[/autoit] [autoit][/autoit] [autoit]While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($hBMP1)
ExitLoop
Case $iPicButton
MsgBox(64, "Picture Clicked", "Yep picture has been clicked")
EndSwitch
WEnd
EndFunc ;==>_Main
Gruß,
UEZ
Happy Birthday to you und alles Gute!
Gruß,
UEZ
Die Lösung des Problems ist hier: _GuiCtrlSetPath
Gruß,
UEZ
Ich habe mal die WinAPIEx gecheckt und da ist bereits die Funktion implementiert... Aber egal!
Gruß,
UEZ
Hilft dir vielleicht _GDIPlus_StringFormatSetAlign() weiter?
Gruß,
UEZ
Cool, was so in der WinAPI alles steckt!
Gruß,
UEZ
Du kannst das Skript extrem beschleunigen, wenn du _GDIPlus_Startup() / _GDIPlus_Shutdown() vorher aufrufst!
#include <GDIPlus.au3>
_GDIPlus_Startup()
$iFontSize = 24
$sFontname = 'Times New Roman'
;~ $sFontname = 'Courier New'
$hGui = GUICreate('Test', 600, 200)
GUISetFont($iFontSize, 400, 0, $sFontname)
$hPath1 = GUICtrlCreateLabel('', 10, 10, 300, 50)
GUICtrlSetBkColor(-1, 0xCCCCCC)
$hPath2 = GUICtrlCreateLabel('', 10, 80, 580, 50)
GUICtrlSetBkColor(-1, 0xCCCCCC)
GUISetState()
; Beispiel 1
$sPath1 = 'c:\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$iTimer = TimerInit()
$sPath1 = _FilePathTrimToLabelWidth($sPath1, $hGui, $hPath1, $iFontSize, $sFontname)
ConsoleWrite(Int(TimerDiff($iTimer)) & ' mSec.' & @CR)
GUICtrlSetData($hPath1, $sPath1)
; Beispiel 2
$sPath2 = '\\Server\d\Backup\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$iTimer = TimerInit()
$sPath2 = _FilePathTrimToLabelWidth($sPath2, $hGui, $hPath2, $iFontSize, $sFontname)
ConsoleWrite(Int(TimerDiff($iTimer)) & ' mSec.' & @CR)
GUICtrlSetData($hPath2, $sPath2)
Do
Until GUIGetMsg() = -3
_GDIPlus_Shutdown()
;===============================================================================
; Function Name: _FilePathTrimToLabelWidth($sFilepath, $CtrlID, $iFontSize, $sFontname)
; Description:: Begrenzt einen Dateipfad auf die Breite eines Labels.
; Dabei wird er aber nicht vorn oder hinten abgeschnitten,
; sondern es bleibt das Device erhalten und der rechte Teil
; des Pfades.
; Parameter(s): $sFilepath = der Pfad, der gekürzt werden soll
; $hGui = das Handle des Fensters
; $CtrlID = die Control ID des Label
; $iFontSize = Fontgröße
; $sFontname = Fontname
; Requirement(s): #include <GDIPlus.au3>
; Return Value(s): Der gekürzte Pfad
; Author(s): Oscar + UEZ + peethebee (http://www.autoit.de)
;===============================================================================
Func _FilePathTrimToLabelWidth($sFilepath, $hGui, $CtrlID, $iFontSize, $sFontname)
Local $sDevice, $iLen = StringLen($sFilepath)
Local $iSize = _GetStringSize($sFilepath, $sFontname, $iFontSize, 0)
Local $aPosCtrl = ControlGetPos($hGui, '', $CtrlID)
If $iSize < $aPosCtrl[2] Then Return $sFilepath
$sDevice = StringRegExpReplace($sFilepath, '([a-z]:\\|\\\\.+?\\[a-z]\\).+', '$1') & '...'
For $i = $iLen - StringLen($sDevice) To 1 Step -1
$iSize = _GetStringSize($sDevice & StringRight($sFilepath, $i), $sFontname, $iFontSize, 0)
If $iSize < $aPosCtrl[2] Then ExitLoop
Next
Return $sDevice & StringRight($sFilepath, $i)
EndFunc ;==>_FilePathTrimToLabelWidth
Func _GetStringSize($string, $font, $fontsize, $fontstyle)
Local $GDIp = False
Local $iWidth = StringLen($string) * $fontsize
Local $iHeight = 2 * $fontsize
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$GDIp = True
EndIf
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', 0, 'int', 0x0026200A, 'ptr', 0, 'int*', 0)
Local $hBitmap = $aResult[6]
Local $hGrphContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($font)
Local $hFont = _GDIPlus_FontCreate($hFamily, $fontsize, $fontstyle)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGrphContext, $string, $hFont, $tLayout, $hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGrphContext)
If $GDIp Then _GDIPlus_Shutdown()
Return Int(DllStructGetData($aInfo[0], 'Width'))
EndFunc ;==>_GetStringSize
Gruß,
UEZ
War auch nur eine "Studie". Leider dauert das Erstellen in _FilePathTrimToLabelWidth zu lange.
Ich schaue mal, ob mir dazu noch was einfällt....
Gruß,
UEZ
Z.B. das IE Fenster im Vollbildmodus unter Win7:
[autoit]
$hIE = WinGetHandle("[CLASS:IEFrame; INSTANCE:1]", "")
WinSetState($hIE, "", @SW_RESTORE)
Gruß,
UEZ
Und dies hier?
#include <GDIPlus.au3>
$iFontSize = 12
$sFontname = 'Courier New'
$hGui = GUICreate('Test', 400, 200)
GUISetFont($iFontSize, 400, 0, $sFontname)
$hPath1 = GUICtrlCreateLabel('', 10, 10, 280, 20)
GUICtrlSetBkColor(-1, 0xCCCCCC)
$hPath2 = GUICtrlCreateLabel('', 10, 60, 300, 20)
GUICtrlSetBkColor(-1, 0xCCCCCC)
GUISetState()
; Beispiel 1
$sPath1 = 'c:\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$sPath1 = _FilePathTrimToLimit($sPath1, $hPath1, $iFontSize, $sFontname)
GUICtrlSetData($hPath1, $sPath1)
; Beispiel 2
$sPath2 = '\\Server\d\Backup\Users\Oscar\Pictures\Urlaub2011\Pic1045.jpg'
$sPath2 = _FilePathTrimToLimit($sPath2, $hPath2, $iFontSize, $sFontname)
GUICtrlSetData($hPath2, $sPath2)
Do
Until GUIGetMsg() = -3
;===============================================================================
; Function Name: _FilePathTrimToLimit($sFilepath, $iLimit)
; Description:: Begrenzt einen Dateipfad auf eine anzugebene Stringlänge.
; Dabei wird er aber nicht vorn oder hinten abgeschnitten,
; sondern es bleibt das Device erhalten und der rechte Teil
; des Pfades.
; Parameter(s): $sFilepath = der Pfad, der gekürzt werden soll
; $CtrlID = die Control ID des Label
; $iFontSize = die Fontgröße des Labels
; $sFontname = Font Name
; Requirement(s): ---
; Return Value(s): Der gekürzte Pfad
; Author(s): Oscar (http://www.autoit.de)
;===============================================================================
Func _FilePathTrimToLimit($sFilepath, $CtrlID, $iFontSize, $sFontname)
Local $aSize = GetStringSize($sFilepath, $sFontname, $iFontSize, 0)
Local $aPosCtrl = ControlGetPos("", "", $CtrlID)
Local $iLimit = StringLen($sFilepath) - Ceiling(Ceiling(1 + ($aSize[0] - $aPosCtrl[2]) / 100) + ($aSize[0] - $aPosCtrl[2]) / $iFontSize)
Local $sDevice, $iLen = StringLen($sFilepath)
If $iLimit < 1 Or $iLimit >= $iLen Then Return $sFilepath
$sDevice = StringRegExpReplace($sFilepath, '([a-z]:\\|\\\\.+?\\[a-z]\\).+', '$1') & '...'
Return $sDevice & StringRight($sFilepath, $iLimit - StringLen($sDevice))
EndFunc ;==>_FilePathTrimToLimit
Func GetStringSize($string, $font, $fontsize, $fontstyle)
Local $GDIp = False
Local $iWidth = StringLen($string) * $fontsize
Local $iHeight = 2 * $fontsize
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$GDIp = True
EndIf
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
Local $hBitmap = $aResult[6]
Local $hGrphContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;~ Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($font)
Local $hFont = _GDIPlus_FontCreate($hFamily, $fontsize, $fontstyle)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGrphContext, $string, $hFont, $tLayout, $hFormat)
;~ _GDIPlus_GraphicsDrawStringEx($hGrphContext, $string, $hFont, $aInfo[0], $hFormat, $hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
;~ _GDIPlus_BrushDispose($hBrush)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGrphContext)
If $GDIp Then _GDIPlus_Shutdown()
Local $aDim[2] = [Int(DllStructGetData($aInfo[0], "Width")), Int(DllStructGetData($aInfo[0], "Height"))]
Return $aDim
EndFunc
Gruß,
UEZ