Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 20:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Problem] mit einer Uhr

Discussion on [Problem] mit einer Uhr within the AutoIt forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
iJonas's Avatar
 
elite*gold: 75
Join Date: May 2010
Posts: 934
Received Thanks: 1,285
[Problem] mit einer Uhr

Hallo liebe Community
Ich hätte eine Frage,
An folgendem Script funktionier irgendetwas nicht
Nur ich habe leider gar keine Ahnung was und wieso es nicht funktioniert.
Ich stelle das Script hier rein möchte aber nicht, dass es von irgendjemandem kopiert und dann als seins ausgegeben wird.
Ich freue mich wenn mir jemand helfen könnte:
Code:
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)
Global Const $iCenter           = 200
Global Const $iDotOpacity       = 250
Global Const $iHourRad          = 140
Global Const $iMinRad           = 200
Global Const $iOpacity          = 128
Global Const $nPI               = 3.1415926535897932384626433832795
Global Const $iRadius           = 200
Global Const $iSecRad           = 200
Global Const $iTickLen          = 0.02

Global Const $AC_SRC_ALPHA      = 1

Global Enum $eScrDC=0, $eMemDC, $eBitmap, $eWidth, $eHeight, $eGraphic, $ePen, $eCap, $eBrush, $eFormat, $eFamily, $eFont, $eLayout, $eLast

Global $hDial, $hTime, $hHour, $hMin, $hSec, $hDot, $aTime, $aHour, $aMin, $aSec, $aCurr[3][2], $aLast[3][2]

ClockInit()
DialDraw ()
Draw     ()
DotDraw  ()
ClockLoop()
ClockDone()

Func ClockDone()
  TimeDone()
  HourDone()
  MinDone ()
  SecDone ()

  _GDIPlus_Shutdown()
EndFunc

Func ClockInit()
  Local $iX, $iY

  $iX = -(_WinAPI_GetSystemMetrics($SM_CXFRAME))
  $iY = -(_WinAPI_GetSystemMetrics($SM_CYCAPTION) + _WinAPI_GetSystemMetrics($SM_CYFRAME))

  $hDial = GUICreate("Clock", $iRadius * 2, $iRadius * 2,  -1,  -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
  GUISetState()
  $hTime = GUICreate("Time" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
  GUISetState()
  $hHour = GUICreate("Hour" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
  GUISetState()
  $hMin  = GUICreate("Min"  , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
  GUISetState()
  $hSec  = GUICreate("Sec"  , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
  GUISetState()
  $hDot  = GUICreate("Dot"  , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
  GUISetState()

  _GDIPlus_Startup()

  TimeInit()
  HourInit()
  MinInit ()
  SecInit ()

  GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
EndFunc

Func ClockLoop()
  do
    Draw()
  until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc

  Local $aDot

Func DotDraw()
  $aDot = ResourceInit($iRadius * 2, $iRadius * 2)
  _GDIPlus_GraphicsFillEllipse($aDot[$eGraphic], $iRadius-10, $iRadius-10, 20, 20)
  ResourceSet ($hDot, $aDot, $iDotOpacity)
  ResourceDone($aDot)
EndFunc


Func Draw()

  $aLast = $aCurr
  $aCurr[0][0] = $iCenter + Cos(TimeToRadians("sec" )) * $iSecRad
  $aCurr[0][1] = $iCenter - Sin(TimeToRadians("sec" )) * $iSecRad
  $aCurr[1][0] = $iCenter + Cos(TimeToRadians("min" )) * $iMinRad
  $aCurr[1][1] = $iCenter - Sin(TimeToRadians("min" )) * $iMinRad
  $aCurr[2][0] = $iCenter + Cos(TimeToRadians("hour")) * $iHourRad
  $aCurr[2][1] = $iCenter - Sin(TimeToRadians("hour")) * $iHourRad

  TimeDraw()
  HourDraw()
  MinDraw ()
  SecDraw ()
EndFunc


Func DialDraw()
  Local $aDial, $hPen1, $hPen2, $iI, $iN, $iX1, $iY1, $iX2, $iY2

  $aDial = ResourceInit($iRadius * 2, $iRadius * 2)
  $hPen1 = _GDIPlus_PenCreate()
  $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 4)
  for $iI = 0 to 2 * $nPI Step $nPI / 30
    $iX1 = $iCenter + Cos($iI) * ($iRadius * (1.00 - $iTickLen))
    $iY1 = $iCenter - Sin($iI) * ($iRadius * (1.00 - $iTickLen))
    $iX2 = $iCenter + Cos($iI) * $iRadius
    $iY2 = $iCenter - Sin($iI) * $iRadius
    if Mod($iN, 5) = 0 then
      _GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1, $iY1, $iX2, $iY2, $hPen2)
    else
      _GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1, $iY1, $iX2, $iY2, $hPen1)
    endif
    $iN += 1
  next
  _GDIPlus_PenDispose($hPen2)
  _GDIPlus_PenDispose($hPen1)

  ResourceSet ($hDial, $aDial)
  ResourceDone($aDial)
EndFunc


Func HourDone()
  _GDIPlus_PenDispose($aHour[$ePen])
  _GDIPlus_ArrowCapDispose($aHour[$eCap])
  ResourceDone($aHour)
EndFunc


Func HourDraw()
  if ($aLast[2][0] = $aCurr[2][0]) and ($aLast[2][1] = $aCurr[2][1]) then Return
  _GDIPlus_GraphicsDrawLine($aHour[$eGraphic], $iCenter, $iCenter, $aCurr[2][0], $aCurr[2][1], $aHour[$ePen])
  ResourceSet($hHour, $aHour)
EndFunc


Func HourInit()
  $aHour = ResourceInit($iRadius * 2, $iRadius * 2)
  $aHour[$ePen] = _GDIPlus_PenCreate(0xFFFF00FF)
  $aHour[$eCap] = _GDIPlus_ArrowCapCreate($iHourRad / 2, 8)
  _GDIPlus_PenSetCustomEndCap($aHour[$ePen], $aHour[$eCap])
EndFunc


Func MinDone()
  _GDIPlus_PenDispose($aMin[$ePen])
  _GDIPlus_ArrowCapDispose($aMin[$eCap])
  ResourceDone($aMin)
EndFunc


Func MinDraw()
  if ($aLast[1][0] = $aCurr[1][0]) and ($aLast[1][1] = $aCurr[1][1]) then Return
  _GDIPlus_GraphicsFillRect($aMin[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
  _GDIPlus_GraphicsDrawLine($aMin[$eGraphic], $iCenter, $iCenter, $aCurr[1][0], $aCurr[1][1], $aMin[$ePen])
  ResourceSet($hMin, $aMin)
EndFunc


Func MinInit()
  $aMin = ResourceInit($iRadius * 2, $iRadius * 2)
  $aMin[$ePen] = _GDIPlus_PenCreate(0xFFFF0000)
  $aMin[$eCap] = _GDIPlus_ArrowCapCreate($iMinRad / 2, 8)
  _GDIPlus_PenSetCustomEndCap($aMin[$ePen], $aMin[$eCap])
EndFunc


Func SecDone()
  _GDIPlus_PenDispose($aSec[$ePen])
  ResourceDone($aSec)
EndFunc


Func SecDraw()
  if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  _GDIPlus_GraphicsFillRect($aSec[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
  _GDIPlus_GraphicsDrawLine($aSec[$eGraphic], $iCenter, $iCenter, $aCurr[0][0], $aCurr[0][1], $aSec[$ePen])
  ResourceSet($hSec, $aSec)
EndFunc


Func SecInit()
  $aSec = ResourceInit($iRadius * 2, $iRadius * 2)
  $aSec[$ePen] = _GDIPlus_PenCreate(0xFF000000)
EndFunc


Func ResourceDone(ByRef $aInfo)
  _GDIPlus_GraphicsDispose($aInfo[$eGraphic])
  _WinAPI_ReleaseDC   (0, $aInfo[$eScrDC])
  _WinAPI_DeleteObject($aInfo[$eBitmap])
  _WinAPI_DeleteDC    ($aInfo[$eMemDC ])
EndFunc


Func ResourceInit($iWidth, $iHeight)
  Local $aInfo[$eLast + 1]

  $aInfo[$eScrDC  ] = _WinAPI_GetDC(0)
  $aInfo[$eMemDC  ] = _WinAPI_CreateCompatibleDC($aInfo[$eScrDC])
  $aInfo[$eBitmap ] = _WinAPI_CreateCompatibleBitmap($aInfo[$eScrDC], $iWidth, $iHeight)
  _WinAPI_SelectObject($aInfo[$eMemDC], $aInfo[$eBitmap])
  $aInfo[$eWidth  ] = $iWidth
  $aInfo[$eHeight ] = $iHeight
  $aInfo[$eGraphic] = _GDIPlus_GraphicsCreateFromHDC($aInfo[$eMemDC])
  _GDIPlus_GraphicsFillRect($aInfo[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
  Return $aInfo
EndFunc

Func ResourceSet($hGUI, ByRef $aInfo, $iAlpha=-1)
  Local $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

  if $iAlpha = -1 then $iAlpha = $iOpacity
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", $aInfo[$eWidth ])
  DllStructSetData($tSize, "Y", $aInfo[$eHeight])
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend )
  DllStructSetData($tBlend, "Alpha" , $iAlpha      )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _WinAPI_UpdateLayeredWindow($hGUI, $aInfo[$eScrDC], 0, $pSize, $aInfo[$eMemDC], $pSource, 0, $pBlend, $ULW_ALPHA)
EndFunc


Func TimeDone()
  _GDIPlus_FontDispose        ($aTime[$eFont  ])
  _GDIPlus_FontFamilyDispose  ($aTime[$eFamily])
  _GDIPlus_StringFormatDispose($aTime[$eFormat])
  _GDIPlus_BrushDispose       ($aTime[$eBrush ])
  ResourceDone($aTime)
EndFunc


Func TimeDraw()
  Local $sString, $aSize

  if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  $sString = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  $aSize   = _GDIPlus_GraphicsMeasureString($aTime[$eGraphic], $sString, $aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat])
  DllStructSetData($aTime[$eLayout], "X", $iRadius - (DllStructGetData($aSize[0], "Width") / 2))
  DllStructSetData($aTime[$eLayout], "Y", $iRadius / 3)
  _GDIPlus_GraphicsFillRect($aTime[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
  _GDIPlus_GraphicsDrawStringEx($aTime[$eGraphic], $sString, $aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat], $aTime[$eBrush])
  ResourceSet($hTime, $aTime)
EndFunc


Func TimeInit()
  $aTime = ResourceInit($iRadius * 2, $iRadius * 2)
  $aTime[$eBrush ] = _GDIPlus_BrushCreateSolid(0xFF008080)
  $aTime[$eFormat] = _GDIPlus_StringFormatCreate()
  $aTime[$eFamily] = _GDIPlus_FontFamilyCreate("Arial")
  $aTime[$eFont  ] = _GDIPlus_FontCreate($aTime[$eFamily], 24, 1)
  $aTime[$eLayout] = _GDIPlus_RectFCreate(0, 0, $iRadius * 2, 40)
EndFunc


Func TimeToRadians($sTimeType)
  Switch $sTimeType
    case "sec"
      Return ($nPI / 2) - (@SEC  * ($nPI / 30))
    case "min"
      Return ($nPI / 2) - (@MIN  * ($nPI / 30)) - (Int(@SEC / 10) * ($nPI / 180))
    case "hour"
      Return ($nPI / 2) - (@HOUR * ($nPI / 6 )) - (@MIN / 12) * ($nPI / 30)
  EndSwitch
EndFunc


Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
  if $hWnd = $hDial then Return $HTCAPTION
EndFunc
Dankeschön schon einmal im Voraus.
iJonas is offline  
Thanks
1 User
Old 11/16/2010, 19:56   #2
 
amnesi's Avatar
 
elite*gold: 25
Join Date: Jun 2010
Posts: 1,076
Received Thanks: 290
Ähm ist das nicht ein Beispiescript von AutoIt ?

PHP Code:
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars"1)
Global Const 
$iCenter           200
Global Const $iDotOpacity       250
Global Const $iHourRad          140
Global Const $iMinRad           200
Global Const $iOpacity          128
Global Const $nPI               3.1415926535897932384626433832795
Global Const $iRadius           200
Global Const $iSecRad           200
Global Const $iTickLen          0.02

Global Const $AC_SRC_ALPHA      1

Global Enum $eScrDC=0$eMemDC$eBitmap$eWidth$eHeight$eGraphic$ePen$eCap$eBrush$eFormat$eFamily$eFont$eLayout$eLast

Global $hDial$hTime$hHour$hMin$hSec$hDot$aTime$aHour$aMin$aSec$aCurr[3][2], $aLast[3][2]

ClockInit()
DialDraw ()
Draw     ()
DotDraw  ()
ClockLoop()
ClockDone()

Func ClockDone()
  
TimeDone()
  
HourDone()
  
MinDone ()
  
SecDone ()

  
_GDIPlus_Shutdown()
EndFunc

Func ClockInit
()
  
Local $iX$iY

  $iX 
= -(_WinAPI_GetSystemMetrics($SM_CXFRAME))
  
$iY = -(_WinAPI_GetSystemMetrics($SM_CYCAPTION) + _WinAPI_GetSystemMetrics($SM_CYFRAME))

  
$hDial GUICreate("Clock"$iRadius 2$iRadius 2,  -1,  -10BitOR($WS_EX_LAYERED$WS_EX_TOPMOST))
  
GUISetState()
  
$hTime GUICreate("Time" $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hHour GUICreate("Hour" $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hMin  GUICreate("Min"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hSec  GUICreate("Sec"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hDot  GUICreate("Dot"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()

  
_GDIPlus_Startup()

  
TimeInit()
  
HourInit()
  
MinInit ()
  
SecInit ()

  
GUIRegisterMsg($WM_NCHITTEST"WM_NCHITTEST")
EndFunc

Func ClockLoop
()
  do
    
Draw()
  
until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc



Func DotDraw
()
      
Local $aDot
  $aDot 
ResourceInit($iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsFillEllipse($aDot[$eGraphic], $iRadius-10$iRadius-102020)
  
ResourceSet ($hDot$aDot$iDotOpacity)
  
ResourceDone($aDot)
EndFunc


Func Draw
()

  
$aLast $aCurr
  $aCurr
[0][0] = $iCenter Cos(TimeToRadians("sec" )) * $iSecRad
  $aCurr
[0][1] = $iCenter Sin(TimeToRadians("sec" )) * $iSecRad
  $aCurr
[1][0] = $iCenter Cos(TimeToRadians("min" )) * $iMinRad
  $aCurr
[1][1] = $iCenter Sin(TimeToRadians("min" )) * $iMinRad
  $aCurr
[2][0] = $iCenter Cos(TimeToRadians("hour")) * $iHourRad
  $aCurr
[2][1] = $iCenter Sin(TimeToRadians("hour")) * $iHourRad

  TimeDraw
()
  
HourDraw()
  
MinDraw ()
  
SecDraw ()
EndFunc


Func DialDraw
()
  
Local $aDial$hPen1$hPen2$iI$iN$iX1$iY1$iX2$iY2

  $aDial 
ResourceInit($iRadius 2$iRadius 2)
  
$hPen1 _GDIPlus_PenCreate()
  
$hPen2 _GDIPlus_PenCreate(0xFF0000FF4)
  for 
$iI 0 to 2 $nPI Step $nPI 30
    $iX1 
$iCenter Cos($iI) * ($iRadius * (1.00 $iTickLen))
    
$iY1 $iCenter Sin($iI) * ($iRadius * (1.00 $iTickLen))
    
$iX2 $iCenter Cos($iI) * $iRadius
    $iY2 
$iCenter Sin($iI) * $iRadius
    
if Mod($iN5) = 0 then
      _GDIPlus_GraphicsDrawLine
($aDial[$eGraphic], $iX1$iY1$iX2$iY2$hPen2)
    else
      
_GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1$iY1$iX2$iY2$hPen1)
    endif
    
$iN += 1
  next
  _GDIPlus_PenDispose
($hPen2)
  
_GDIPlus_PenDispose($hPen1)

  
ResourceSet ($hDial$aDial)
  
ResourceDone($aDial)
EndFunc


Func HourDone
()
  
_GDIPlus_PenDispose($aHour[$ePen])
  
_GDIPlus_ArrowCapDispose($aHour[$eCap])
  
ResourceDone($aHour)
EndFunc


Func HourDraw
()
  if (
$aLast[2][0] = $aCurr[2][0]) and ($aLast[2][1] = $aCurr[2][1]) then Return
  
_GDIPlus_GraphicsDrawLine($aHour[$eGraphic], $iCenter$iCenter$aCurr[2][0], $aCurr[2][1], $aHour[$ePen])
  
ResourceSet($hHour$aHour)
EndFunc


Func HourInit
()
  
$aHour ResourceInit($iRadius 2$iRadius 2)
  
$aHour[$ePen] = _GDIPlus_PenCreate(0xFFFF00FF)
  
$aHour[$eCap] = _GDIPlus_ArrowCapCreate($iHourRad 28)
  
_GDIPlus_PenSetCustomEndCap($aHour[$ePen], $aHour[$eCap])
EndFunc


Func MinDone
()
  
_GDIPlus_PenDispose($aMin[$ePen])
  
_GDIPlus_ArrowCapDispose($aMin[$eCap])
  
ResourceDone($aMin)
EndFunc


Func MinDraw
()
  if (
$aLast[1][0] = $aCurr[1][0]) and ($aLast[1][1] = $aCurr[1][1]) then Return
  
_GDIPlus_GraphicsFillRect($aMin[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawLine($aMin[$eGraphic], $iCenter$iCenter$aCurr[1][0], $aCurr[1][1], $aMin[$ePen])
  
ResourceSet($hMin$aMin)
EndFunc


Func MinInit
()
  
$aMin ResourceInit($iRadius 2$iRadius 2)
  
$aMin[$ePen] = _GDIPlus_PenCreate(0xFFFF0000)
  
$aMin[$eCap] = _GDIPlus_ArrowCapCreate($iMinRad 28)
  
_GDIPlus_PenSetCustomEndCap($aMin[$ePen], $aMin[$eCap])
EndFunc


Func SecDone
()
  
_GDIPlus_PenDispose($aSec[$ePen])
  
ResourceDone($aSec)
EndFunc


Func SecDraw
()
  if (
$aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  
_GDIPlus_GraphicsFillRect($aSec[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawLine($aSec[$eGraphic], $iCenter$iCenter$aCurr[0][0], $aCurr[0][1], $aSec[$ePen])
  
ResourceSet($hSec$aSec)
EndFunc


Func SecInit
()
  
$aSec ResourceInit($iRadius 2$iRadius 2)
  
$aSec[$ePen] = _GDIPlus_PenCreate(0xFF000000)
EndFunc


Func ResourceDone
(ByRef $aInfo)
  
_GDIPlus_GraphicsDispose($aInfo[$eGraphic])
  
_WinAPI_ReleaseDC   (0$aInfo[$eScrDC])
  
_WinAPI_DeleteObject($aInfo[$eBitmap])
  
_WinAPI_DeleteDC    ($aInfo[$eMemDC ])
EndFunc


Func ResourceInit
($iWidth$iHeight)
  
Local $aInfo[$eLast 1]

  
$aInfo[$eScrDC  ] = _WinAPI_GetDC(0)
  
$aInfo[$eMemDC  ] = _WinAPI_CreateCompatibleDC($aInfo[$eScrDC])
  
$aInfo[$eBitmap ] = _WinAPI_CreateCompatibleBitmap($aInfo[$eScrDC], $iWidth$iHeight)
  
_WinAPI_SelectObject($aInfo[$eMemDC], $aInfo[$eBitmap])
  
$aInfo[$eWidth  ] = $iWidth
  $aInfo
[$eHeight ] = $iHeight
  $aInfo
[$eGraphic] = _GDIPlus_GraphicsCreateFromHDC($aInfo[$eMemDC])
  
_GDIPlus_GraphicsFillRect($aInfo[$eGraphic], 00$iRadius 2$iRadius 2)
  Return 
$aInfo
EndFunc

Func ResourceSet
($hGUIByRef $aInfo$iAlpha=-1)
  
Local $pSize$tSize$pSource$tSource$pBlend$tBlend

  
if $iAlpha = -1 then $iAlpha $iOpacity
  $tSize   
DllStructCreate($tagSIZE)
  
$pSize   DllStructGetPtr($tSize  )
  
DllStructSetData($tSize"X"$aInfo[$eWidth ])
  
DllStructSetData($tSize"Y"$aInfo[$eHeight])
  
$tSource DllStructCreate($tagPOINT)
  
$pSource DllStructGetPtr($tSource)
  
$tBlend  DllStructCreate($tagBLENDFUNCTION)
  
$pBlend  DllStructGetPtr($tBlend )
  
DllStructSetData($tBlend"Alpha" $iAlpha      )
  
DllStructSetData($tBlend"Format"$AC_SRC_ALPHA)
  
_WinAPI_UpdateLayeredWindow($hGUI$aInfo[$eScrDC], 0$pSize$aInfo[$eMemDC], $pSource0$pBlend$ULW_ALPHA)
EndFunc


Func TimeDone
()
  
_GDIPlus_FontDispose        ($aTime[$eFont  ])
  
_GDIPlus_FontFamilyDispose  ($aTime[$eFamily])
  
_GDIPlus_StringFormatDispose($aTime[$eFormat])
  
_GDIPlus_BrushDispose       ($aTime[$eBrush ])
  
ResourceDone($aTime)
EndFunc


Func TimeDraw
()
  
Local $sString$aSize

  
if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  
$sString StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  
$aSize   _GDIPlus_GraphicsMeasureString($aTime[$eGraphic], $sString$aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat])
  
DllStructSetData($aTime[$eLayout], "X"$iRadius - (DllStructGetData($aSize[0], "Width") / 2))
  
DllStructSetData($aTime[$eLayout], "Y"$iRadius 3)
  
_GDIPlus_GraphicsFillRect($aTime[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawStringEx($aTime[$eGraphic], $sString$aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat], $aTime[$eBrush])
  
ResourceSet($hTime$aTime)
EndFunc


Func TimeInit
()
  
$aTime ResourceInit($iRadius 2$iRadius 2)
  
$aTime[$eBrush ] = _GDIPlus_BrushCreateSolid(0xFF008080)
  
$aTime[$eFormat] = _GDIPlus_StringFormatCreate()
  
$aTime[$eFamily] = _GDIPlus_FontFamilyCreate("Arial")
  
$aTime[$eFont  ] = _GDIPlus_FontCreate($aTime[$eFamily], 241)
  
$aTime[$eLayout] = _GDIPlus_RectFCreate(00$iRadius 240)
EndFunc


Func TimeToRadians
($sTimeType)
  Switch 
$sTimeType
    
case "sec"
      
Return ($nPI 2) - (@SEC  * ($nPI 30))
    case 
"min"
      
Return ($nPI 2) - (@MIN  * ($nPI 30)) - (Int(@SEC 10) * ($nPI 180))
    case 
"hour"
      
Return ($nPI 2) - (@HOUR * ($nPI )) - (@MIN 12) * ($nPI 30)
  EndSwitch
EndFunc


Func WM_NCHITTEST
($hWnd$iMsg$iwParam$ilParam)
  if 
$hWnd $hDial then Return $HTCAPTION
EndFunc 
Du hast eine Variable falsch/nicht deklariert.....
So geht es ;D
amnesi is offline  
Thanks
1 User
Old 11/16/2010, 19:58   #3
 
iJonas's Avatar
 
elite*gold: 75
Join Date: May 2010
Posts: 934
Received Thanks: 1,285
Kumpel hats mir geschickt, und gefragt was daran falsch sein könnte, und ich hatte auch kein Plan
Deswegen will ich auch nicht das das jmd kopiert.
Soweit ich weiß ist das kein Example
iJonas is offline  
Thanks
1 User
Old 11/16/2010, 20:09   #4
 
amnesi's Avatar
 
elite*gold: 25
Join Date: Jun 2010
Posts: 1,076
Received Thanks: 290
So habs grad geändert ;D
amnesi is offline  
Thanks
1 User
Old 11/16/2010, 20:09   #5
 
iJonas's Avatar
 
elite*gold: 75
Join Date: May 2010
Posts: 934
Received Thanks: 1,285
Mal schaun obs funktioniert.
Ist das denn jetzt ein Beispiel Script?
iJonas is offline  
Thanks
1 User
Old 11/16/2010, 20:13   #6
 
amnesi's Avatar
 
elite*gold: 25
Join Date: Jun 2010
Posts: 1,076
Received Thanks: 290
ich poste mal kurz das Beispiel Script aus dem AutoIt Ordner :
kannst ja mal vergleichen aber so wie ich das sehe is das eig. das gleiche ;D
Nur ohne Kommentare...
kannst das Beispiel Script ja ma starten...

PHP Code:
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars"1)

; ===============================================================================================================================
Description ...: Simple clock using layered windows
Author ........: Paul Campbell (PaulIA)
Notes .........:
; ===============================================================================================================================

; ===============================================================================================================================
; Global 
constants
; ===============================================================================================================================

Global Const 
$iCenter           200
Global Const $iDotOpacity       250
Global Const $iHourRad          140
Global Const $iMinRad           200
Global Const $iOpacity          128
Global Const $nPI               3.1415926535897932384626433832795
Global Const $iRadius           200
Global Const $iSecRad           200
Global Const $iTickLen          0.02

Global Const $AC_SRC_ALPHA      1

Global Enum $eScrDC=0$eMemDC$eBitmap$eWidth$eHeight$eGraphic$ePen$eCap$eBrush$eFormat$eFamily$eFont$eLayout$eLast

; ===============================================================================================================================
; Global 
variables
; ===============================================================================================================================

Global 
$hDial$hTime$hHour$hMin$hSec$hDot$aTime$aHour$aMin$aSec$aCurr[3][2], $aLast[3][2]

; ===============================================================================================================================
Main
; ===============================================================================================================================

ClockInit()
DialDraw ()
Draw     ()
DotDraw  ()
ClockLoop()
ClockDone()

; ===============================================================================================================================
Finalize clock
; ===============================================================================================================================
Func ClockDone()
  ; 
Finalize GDIresources
  TimeDone
()
  
HourDone()
  
MinDone ()
  
SecDone ()

  ; 
Finalize GDIlibrary
  _GDIPlus_Shutdown
()
EndFunc

; ===============================================================================================================================
Initialize clock
; ===============================================================================================================================
Func ClockInit()
  
Local $iX$iY

  
Calculate the dial frame caption size
  $iX 
= -(_WinAPI_GetSystemMetrics($SM_CXFRAME))
  
$iY = -(_WinAPI_GetSystemMetrics($SM_CYCAPTION) + _WinAPI_GetSystemMetrics($SM_CYFRAME))

  ; 
Allocate the window resources
  $hDial 
GUICreate("Clock"$iRadius 2$iRadius 2,  -1,  -10BitOR($WS_EX_LAYERED$WS_EX_TOPMOST))
  
GUISetState()
  
$hTime GUICreate("Time" $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hHour GUICreate("Hour" $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hMin  GUICreate("Min"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hSec  GUICreate("Sec"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()
  
$hDot  GUICreate("Dot"  $iRadius 2$iRadius 2$iX$iY0BitOR($WS_EX_LAYERED$WS_EX_MDICHILD), $hDial)
  
GUISetState()

  ; 
Initialize GDIlibrary
  _GDIPlus_Startup
()

  ; 
Initialize GDIresources
  TimeInit
()
  
HourInit()
  
MinInit ()
  
SecInit ()

  ; 
Hook non client hit test message so we can move the clock
  GUIRegisterMsg
($WM_NCHITTEST"WM_NCHITTEST")
EndFunc

; ===============================================================================================================================
Loop until user exits
; ===============================================================================================================================
Func ClockLoop()
  do
    
Draw()
  
until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc

; ===============================================================================================================================
Draw the center dot
; ===============================================================================================================================
Func DotDraw()
  
Local $aDot

  $aDot 
ResourceInit($iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsFillEllipse($aDot[$eGraphic], $iRadius-10$iRadius-102020)
  
ResourceSet ($hDot$aDot$iDotOpacity)
  
ResourceDone($aDot)
EndFunc

; ===============================================================================================================================
Draw the clock elements
; ===============================================================================================================================
Func Draw()
  ; 
Calculate current time element position
  $aLast 
$aCurr
  $aCurr
[0][0] = $iCenter Cos(TimeToRadians("sec" )) * $iSecRad
  $aCurr
[0][1] = $iCenter Sin(TimeToRadians("sec" )) * $iSecRad
  $aCurr
[1][0] = $iCenter Cos(TimeToRadians("min" )) * $iMinRad
  $aCurr
[1][1] = $iCenter Sin(TimeToRadians("min" )) * $iMinRad
  $aCurr
[2][0] = $iCenter Cos(TimeToRadians("hour")) * $iHourRad
  $aCurr
[2][1] = $iCenter Sin(TimeToRadians("hour")) * $iHourRad

  
Draw time elements
  TimeDraw
()
  
HourDraw()
  
MinDraw ()
  
SecDraw ()
EndFunc

; ===============================================================================================================================
Draw the clock dial
; ===============================================================================================================================
Func DialDraw()
  
Local $aDial$hPen1$hPen2$iI$iN$iX1$iY1$iX2$iY2

  $aDial 
ResourceInit($iRadius 2$iRadius 2)
  
$hPen1 _GDIPlus_PenCreate()
  
$hPen2 _GDIPlus_PenCreate(0xFF0000FF4)
  for 
$iI 0 to 2 $nPI Step $nPI 30
    $iX1 
$iCenter Cos($iI) * ($iRadius * (1.00 $iTickLen))
    
$iY1 $iCenter Sin($iI) * ($iRadius * (1.00 $iTickLen))
    
$iX2 $iCenter Cos($iI) * $iRadius
    $iY2 
$iCenter Sin($iI) * $iRadius
    
if Mod($iN5) = 0 then
      _GDIPlus_GraphicsDrawLine
($aDial[$eGraphic], $iX1$iY1$iX2$iY2$hPen2)
    else
      
_GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1$iY1$iX2$iY2$hPen1)
    endif
    
$iN += 1
  next
  _GDIPlus_PenDispose
($hPen2)
  
_GDIPlus_PenDispose($hPen1)

  
ResourceSet ($hDial$aDial)
  
ResourceDone($aDial)
EndFunc

; ===============================================================================================================================
Finalize resources for the hour hand
; ===============================================================================================================================
Func HourDone()
  
_GDIPlus_PenDispose($aHour[$ePen])
  
_GDIPlus_ArrowCapDispose($aHour[$eCap])
  
ResourceDone($aHour)
EndFunc

; ===============================================================================================================================
Draw the hour hand
; ===============================================================================================================================
Func HourDraw()
  if (
$aLast[2][0] = $aCurr[2][0]) and ($aLast[2][1] = $aCurr[2][1]) then Return
  
_GDIPlus_GraphicsDrawLine($aHour[$eGraphic], $iCenter$iCenter$aCurr[2][0], $aCurr[2][1], $aHour[$ePen])
  
ResourceSet($hHour$aHour)
EndFunc

; ===============================================================================================================================
Initialize resources for the hour hand
; ===============================================================================================================================
Func HourInit()
  
$aHour ResourceInit($iRadius 2$iRadius 2)
  
$aHour[$ePen] = _GDIPlus_PenCreate(0xFFFF00FF)
  
$aHour[$eCap] = _GDIPlus_ArrowCapCreate($iHourRad 28)
  
_GDIPlus_PenSetCustomEndCap($aHour[$ePen], $aHour[$eCap])
EndFunc

; ===============================================================================================================================
Finalize resources for the minute hand
; ===============================================================================================================================
Func MinDone()
  
_GDIPlus_PenDispose($aMin[$ePen])
  
_GDIPlus_ArrowCapDispose($aMin[$eCap])
  
ResourceDone($aMin)
EndFunc

; ===============================================================================================================================
Draw the minute hand
; ===============================================================================================================================
Func MinDraw()
  if (
$aLast[1][0] = $aCurr[1][0]) and ($aLast[1][1] = $aCurr[1][1]) then Return
  
_GDIPlus_GraphicsFillRect($aMin[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawLine($aMin[$eGraphic], $iCenter$iCenter$aCurr[1][0], $aCurr[1][1], $aMin[$ePen])
  
ResourceSet($hMin$aMin)
EndFunc

; ===============================================================================================================================
Initialize resources for the minute hand
; ===============================================================================================================================
Func MinInit()
  
$aMin ResourceInit($iRadius 2$iRadius 2)
  
$aMin[$ePen] = _GDIPlus_PenCreate(0xFFFF0000)
  
$aMin[$eCap] = _GDIPlus_ArrowCapCreate($iMinRad 28)
  
_GDIPlus_PenSetCustomEndCap($aMin[$ePen], $aMin[$eCap])
EndFunc

; ===============================================================================================================================
Finalize resources for the second hand
; ===============================================================================================================================
Func SecDone()
  
_GDIPlus_PenDispose($aSec[$ePen])
  
ResourceDone($aSec)
EndFunc

; ===============================================================================================================================
Draw the second hand
; ===============================================================================================================================
Func SecDraw()
  if (
$aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  
_GDIPlus_GraphicsFillRect($aSec[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawLine($aSec[$eGraphic], $iCenter$iCenter$aCurr[0][0], $aCurr[0][1], $aSec[$ePen])
  
ResourceSet($hSec$aSec)
EndFunc

; ===============================================================================================================================
Initialize resources for the second hand
; ===============================================================================================================================
Func SecInit()
  
$aSec ResourceInit($iRadius 2$iRadius 2)
  
$aSec[$ePen] = _GDIPlus_PenCreate(0xFF000000)
EndFunc

; ===============================================================================================================================
Finalize drawing resources
; ===============================================================================================================================
Func ResourceDone(ByRef $aInfo)
  
_GDIPlus_GraphicsDispose($aInfo[$eGraphic])
  
_WinAPI_ReleaseDC   (0$aInfo[$eScrDC])
  
_WinAPI_DeleteObject($aInfo[$eBitmap])
  
_WinAPI_DeleteDC    ($aInfo[$eMemDC ])
EndFunc

; ===============================================================================================================================
Initialize bitmap resources
; ===============================================================================================================================
Func ResourceInit($iWidth$iHeight)
  
Local $aInfo[$eLast 1]

  
$aInfo[$eScrDC  ] = _WinAPI_GetDC(0)
  
$aInfo[$eMemDC  ] = _WinAPI_CreateCompatibleDC($aInfo[$eScrDC])
  
$aInfo[$eBitmap ] = _WinAPI_CreateCompatibleBitmap($aInfo[$eScrDC], $iWidth$iHeight)
  
_WinAPI_SelectObject($aInfo[$eMemDC], $aInfo[$eBitmap])
  
$aInfo[$eWidth  ] = $iWidth
  $aInfo
[$eHeight ] = $iHeight
  $aInfo
[$eGraphic] = _GDIPlus_GraphicsCreateFromHDC($aInfo[$eMemDC])
  
_GDIPlus_GraphicsFillRect($aInfo[$eGraphic], 00$iRadius 2$iRadius 2)
  Return 
$aInfo
EndFunc

; ===============================================================================================================================
Update layered window with resource information
; ===============================================================================================================================
Func ResourceSet($hGUIByRef $aInfo$iAlpha=-1)
  
Local $pSize$tSize$pSource$tSource$pBlend$tBlend

  
if $iAlpha = -1 then $iAlpha $iOpacity
  $tSize   
DllStructCreate($tagSIZE)
  
$pSize   DllStructGetPtr($tSize  )
  
DllStructSetData($tSize"X"$aInfo[$eWidth ])
  
DllStructSetData($tSize"Y"$aInfo[$eHeight])
  
$tSource DllStructCreate($tagPOINT)
  
$pSource DllStructGetPtr($tSource)
  
$tBlend  DllStructCreate($tagBLENDFUNCTION)
  
$pBlend  DllStructGetPtr($tBlend )
  
DllStructSetData($tBlend"Alpha" $iAlpha      )
  
DllStructSetData($tBlend"Format"$AC_SRC_ALPHA)
  
_WinAPI_UpdateLayeredWindow($hGUI$aInfo[$eScrDC], 0$pSize$aInfo[$eMemDC], $pSource0$pBlend$ULW_ALPHA)
EndFunc

; ===============================================================================================================================
Finalize resources for the digital time
; ===============================================================================================================================
Func TimeDone()
  
_GDIPlus_FontDispose        ($aTime[$eFont  ])
  
_GDIPlus_FontFamilyDispose  ($aTime[$eFamily])
  
_GDIPlus_StringFormatDispose($aTime[$eFormat])
  
_GDIPlus_BrushDispose       ($aTime[$eBrush ])
  
ResourceDone($aTime)
EndFunc

; ===============================================================================================================================
Draw the digital time
; ===============================================================================================================================
Func TimeDraw()
  
Local $sString$aSize

  
if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
  
$sString StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  
$aSize   _GDIPlus_GraphicsMeasureString($aTime[$eGraphic], $sString$aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat])
  
DllStructSetData($aTime[$eLayout], "X"$iRadius - (DllStructGetData($aSize[0], "Width") / 2))
  
DllStructSetData($aTime[$eLayout], "Y"$iRadius 3)
  
_GDIPlus_GraphicsFillRect($aTime[$eGraphic], 00$iRadius 2$iRadius 2)
  
_GDIPlus_GraphicsDrawStringEx($aTime[$eGraphic], $sString$aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat], $aTime[$eBrush])
  
ResourceSet($hTime$aTime)
EndFunc

; ===============================================================================================================================
Initialize resources for the digital time
; ===============================================================================================================================
Func TimeInit()
  
$aTime ResourceInit($iRadius 2$iRadius 2)
  
$aTime[$eBrush ] = _GDIPlus_BrushCreateSolid(0xFF008080)
  
$aTime[$eFormat] = _GDIPlus_StringFormatCreate()
  
$aTime[$eFamily] = _GDIPlus_FontFamilyCreate("Arial")
  
$aTime[$eFont  ] = _GDIPlus_FontCreate($aTime[$eFamily], 241)
  
$aTime[$eLayout] = _GDIPlus_RectFCreate(00$iRadius 240)
EndFunc

; ===============================================================================================================================
Convert time value to radians
; ===============================================================================================================================
Func TimeToRadians($sTimeType)
  Switch 
$sTimeType
    
case "sec"
      
Return ($nPI 2) - (@SEC  * ($nPI 30))
    case 
"min"
      
Return ($nPI 2) - (@MIN  * ($nPI 30)) - (Int(@SEC 10) * ($nPI 180))
    case 
"hour"
      
Return ($nPI 2) - (@HOUR * ($nPI )) - (@MIN 12) * ($nPI 30)
  EndSwitch
EndFunc

; ===============================================================================================================================
Handle the WM_NCHITTEST message so our window can be dragged
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd$iMsg$iwParam$ilParam)
  if 
$hWnd $hDial then Return $HTCAPTION
EndFunc 
amnesi is offline  
Thanks
1 User
Old 11/16/2010, 20:14   #7
 
iJonas's Avatar
 
elite*gold: 75
Join Date: May 2010
Posts: 934
Received Thanks: 1,285
Tzz, da kann mein Kumpel aber was zuhören bekommen..
Ein Beispiel Script nehmen und es dann nicht schaffen
So ein Dummkopf.
Naja das Problem hat sich dann ja erledigt!
#Close requested
iJonas is offline  
Thanks
1 User
Old 11/16/2010, 20:59   #8
 
elite*gold: 0
Join Date: Feb 2009
Posts: 542
Received Thanks: 112
maxi39 is offline  
Closed Thread


Similar Threads Similar Threads
[Frage] Problem bei einer Art Übersetzter
09/09/2010 - AutoIt - 13 Replies
Hey Leute, also mal wieder habe ich in Problem mit AutoIt. Ich habe vor eine Art Übersetzter zu scripten. Bis jetzt sieht es so aus. GuiCreate("Der lateinische - deutsche Wortübersetzer",384,140,595,364) $input1=GuiCtrlCreateInput("",23,79,150 ,20)
Problem Mit einer Domain
07/04/2010 - Metin2 Private Server - 4 Replies
Hallo habe folgendes Problem wenn ich die Domain aufrufe kommt dieser Fehler Forbidden You don't have permission to access / on this server. Könnt ihr mir helfen ?
[HILFE] Problem mit einer Quest
05/16/2010 - Metin2 PServer Guides & Strategies - 6 Replies
Hi ich wollt mir ne eigene Quest schreiben die foolgendes machen soll: In der Quest muss man 250 Wildhunde killen und 250 Hungrige Wildhunde wenn man das gemacht hat bekommt man den Regenbogenstein (50512) aber ich bekomms nich hin!!! kann mir wer da helfen plsssssss! Bekommt auch THX
Problem mit einer Quest
01/01/2010 - Metin2 Private Server - 9 Replies
Hallo, ich hab mir eine eigne Quest geschreiben. Quest: -- Koe-Pung quest koe-pung_warp begin state start begin when 20093.chat."Möchtest du zum Wasserdrachen?" begin
[HILFE]Problem mit einer Online/Offline Box!!!
10/12/2008 - Flyff Private Server - 0 Replies
Hi leute, Also wie mein Titel schon sagt habe ich ein kleines Problem mit meiner Online/Offline box... Also hier ist mal ein Downloadlink:SpeedShare - Download Online_Offline_Box.rar und hier mal der link der seite wo die BOX ist: ENTER Also das problem ist: Wie ihr auf dem link sehen könnt werden die online.png und, oder Offline.png nicht angezeigt je nach serverstatus...



All times are GMT +1. The time now is 20:08.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.