Das sieht wirklich gut aus, jedoch sind die downloadlinks von drv.zip und svc.zip down.
Und ich hab drv.zip bis jetzt leider noch nicht gefunden...
E
Das sieht wirklich gut aus, jedoch sind die downloadlinks von drv.zip und svc.zip down.
Und ich hab drv.zip bis jetzt leider noch nicht gefunden...
E
Hab schnell was gebastelt
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hDll = DllOpen("DMX.dll")
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $iWidth = 1200
Global $iHeight = 400
Global $iLayer = 0
Global $aDMX[513]
Global $tByte = DllStructCreate("Byte[510];")
Global $hGui = GUICreate("DMX 510", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $cDummy1 = GUICtrlCreateDummy()
For $i = 0 To 15
GUICtrlCreateRadio($i * 16 + 1 & "-" & ($i + 1) * 16, 25 + ($iWidth - 100) / 15 * $i, 10, 50, 20, 0x1000)
GUICtrlSetOnEvent(-1, "_SetLayer")
Next
For $i = 0 To 15
GUICtrlCreateRadio($i * 16 + 257 & "-" & ($i + 1) * 16 + 256, 25 + ($iWidth - 100) / 15 * $i, 40, 50, 20, 0x1000)
GUICtrlSetOnEvent(-1, "_SetLayer")
Next
GUICtrlSetState($cDummy1 + 1, $GUI_CHECKED)
Global $cDummy2 = GUICtrlCreateDummy()
For $i = 0 To 15
GUICtrlCreateLabel($i + 1, 30 + ($iWidth - 120) / 15 * $i, 90, 60, 20, BitOR(0x01, 0x0200))
GUICtrlSetBkColor(-1, 0x008800)
GUICtrlSetOnEvent(-1, "_SetDMXValue")
Next
Global $cDummy3 = GUICtrlCreateDummy()
For $i = 0 To 15
GUICtrlCreateSlider(30 + ($iWidth - 120) / 15 * $i, 120, 34, $iHeight - 140, BitOR(0x0002, 0x0008))
GUICtrlSetLimit(-1, 0xFF)
GUICtrlSetData(-1, 0xFF)
GUICtrlSetOnEvent(-1, "_SetDMXValue")
Next
Global $cDummy4 = GUICtrlCreateDummy()
For $i = 0 To 15
GUICtrlCreateProgress(70 + ($iWidth - 120) / 15 * $i, 130, 20, $iHeight - 160, BitOR(0x01, 0x04))
Next
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUISetState()
While Sleep(100)
WEnd
Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
Local $iCode = BitAND($wParam, 0x0000FFFF)
Local $iPos = 0xFF - BitShift($wParam, 16)
If $iCode = 5 Then
Local $iIDX = 0
For $i = 1 To 16
If $lParam = GUICtrlGetHandle($cDummy3 + $i) Then
$iIDX = $i
ExitLoop
EndIf
Next
If $iIDX Then
Local $iDMX = $iLayer * 16 + $iIDX
$aDMX[$iDMX] = $iPos
GUICtrlSetData($cDummy4 + $iIDX, $aDMX[$iDMX] / 0xFF * 100)
_SendValueToController($iDMX, $aDMX[$iDMX])
EndIf
EndIf
EndFunc ;==>WM_VSCROLL
Func _SetDMXValue()
Local $iDMX = $iLayer * 16 + (@GUI_CtrlId - $cDummy3)
$aDMX[$iDMX] = 0xFF - GUICtrlRead(@GUI_CtrlId)
GUICtrlSetData(@GUI_CtrlId + 17, $aDMX[$iDMX] / 0xFF * 100)
_SendValueToController($iDMX, $aDMX[$iDMX])
EndFunc ;==>_SetDMXValue
Func _SetLayer()
$iLayer = @GUI_CtrlId - $cDummy1 - 1
Local $iDMX1 = $iLayer * 16
For $i = 1 To 16
GUICtrlSetData($cDummy2 + $i, $iDMX1 + $i)
GUICtrlSetData($cDummy3 + $i, 0xFF - $aDMX[$iDMX1 + $i])
GUICtrlSetData($cDummy4 + $i, $aDMX[$iDMX1 + $i] / 0xFF * 100)
Next
EndFunc ;==>_SetLayer
Func _SendValueToController($iIDX, $iValue)
If $iIDX < 1 Or $iIDX > 510 Then Return
DllStructSetData($tByte, 1, $iValue, $iIDX)
DllCall($hDll, "bool", "SetLevel", "ptr", DllStructGetPtr($tByte))
EndFunc ;==>_SendValueToController
Func _Exit()
Exit
EndFunc ;==>_Exit
Bei größeren Scripten sollte man die Dummy-Controls jedoch anders benennen
E
DllStructSetData($tByte, 1, 100, 7) ![]()
Sollte so gehen:
[autoit]$tByte = DllStructCreate("Byte[510];")
DllCall($hDll, "bool", "SetLevel", "ptr", DllStructGetPtr($tByte))
Ich hab einen Treiber, welchen ich ohne Neustart starten und stoppen möchte.
Das Starten geht eigentlich ganz einfach mit
[autoit]RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32", "midi4", "REG_SZ", "MIDItest.drv")
[/autoit]
Dieser Aufruf genügt und der Treiber ist Sekunden später betriebsbereit. (Vorrausgesetzt er befindet sich in System32)
Um ihn allerdings zu stoppen, muss ich den Reg Eintrag löschen und einen Neustart durchführen.
Wie kann ich den Treiber ohne Neustart stoppen?
Kann auch eine "radikale" Lösung sein, denn ich brauche das nur zu Testzwecken...
Gibt es evtl. auch eine elegantere Load-Lösung als RegWrite?
Danke
E
Ich habs nicht getestet, aber ich nehme an, dass die Version von Yashied auch funktioniert.
Falls nicht, dann benenne einfach meine Version um...
E
Die Credits gebühren MOD (?) von freebasic.net http://www.freebasic.net/forum/viewtopic.php?t=15164
Hier noch der FreeBasic Sourcecode der DLL:
evtl. kannst du da noch etwas Geschwindigkeit rausschinden...
E
Mit dieser Dll ist MD5 etwa 20% schneller:
Global $hDLL_MD5 = DllOpen(@ScriptDir & "\MD5.dll")
[/autoit][autoit][/autoit][autoit]Func _FileCreateMD5($sFile)
Local $tMD5 = DllStructCreate("char[32];")
Local $aResult = DllCall($hDLL_MD5, "int", "FileCreateMD5", "str", $sFile, "ptr", DllStructGetPtr($tMD5))
If @error Then Return SetError(1, 1, "")
Return SetError($aResult[0], 0, DllStructGetData($tMD5, 1))
EndFunc ;==>_FileCreateMD5
FreeBasic-Sourcecode hätte ich dazu auch
E
Edit: bei vielen kleinen Dateien, lässt sich auch noch so Zeit sparen:
[autoit]Global $hDLL_MD5 = DllOpen(@ScriptDir & "\MD5.dll")
Global $tMD5 = DllStructCreate("char[32];")
Global $pMD5 = DllStructGetPtr($tMD5)
Func _FileCreateMD5($sFile)
Local $aResult = DllCall($hDLL_MD5, "int", "FileCreateMD5", "str", $sFile, "ptr", $pMD5)
Return DllStructGetData($tMD5, 1)
EndFunc
Probiers mal aus.
Hier ein abgewandeltes Script aus der Hilfe:
#AutoIt3Wrapper_UseX64=n
#include "bass.au3"
#include "bassmidi.au3"
#include <Array.au3>
HotKeySet("{ESC}", "_Exit")
[/autoit] [autoit][/autoit] [autoit]$sFile = FileOpenDialog("Open Midi-file", "..\audiofiles", "(*.mid)")
___DeBug($sFile = "", $sFile)
_BASS_Startup()
___DeBug(@error, "load bass.dll")
_BASS_MIDI_Startup()
___DeBug(@error, "load bassmidi.dll")
_BASS_Init(0, -1, 44100, 0, "")
___DeBug(@error, "initialize bass")
$hMidiStream = _BASS_MIDI_StreamCreateFile(False, $sFile)
___DeBug(@error, "creating midifile stream")
_BASS_ChannelSetSync($hMidiStream, $BASS_SYNC_MIDI_EVENT, $MIDI_EVENT_NOTE, "_SyncProc", 0)
___DeBug(@error, "set sync" & @error)
_BASS_ChannelPlay($hMidiStream, False)
___DeBug(@error, "play stream")
$iLen = _BASS_ChannelGetLength($hMidiStream, $BASS_POS_BYTE)
[/autoit] [autoit][/autoit] [autoit]While _BASS_ChannelIsActive($hMidiStream)
Sleep(20)
$iPos = _BASS_ChannelGetPosition($hMidiStream, $BASS_POS_BYTE)
ToolTip(Round($iPos * 100 / $iLen, 1) & "% played")
WEnd
_Exit()
Func _SyncProc($handle, $channel, $data, $user)
Local Static $iCnt = 0
$iCnt += 1
Local $iKeyNumber = _BASS_LoByte($data)
Local $iVelocity = _BASS_HiByte($data)
ConsoleWrite("! Midi event: " & $iCnt & @TAB & $iKeyNumber & "/" & $iVelocity & @CRLF)
[/autoit] [autoit][/autoit] [autoit]Return True
EndFunc ;==>_SyncProc
Func _Exit()
_BASS_StreamFree($hMidiStream)
___DeBug(@error, "free stream")
_BASS_Free()
___DeBug(@error, "free bass")
Exit
EndFunc ;==>_Exit
Func ___DeBug($iError, $sAction)
Switch $iError
Case -1
ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
Case 0
ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
Case Else
ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
Exit
EndSwitch
EndFunc ;==>___DeBug
Ich glaube, dass AutoIt immer dann abstürtzt, wenn mehrere Callbackfunktionen zur selben Zeit aufgerufen werden...
Sollte deine Midi-Datei immer nur einen Event auslösen (und der nächste erst, wenn die Funktion längst abgearbeitet wurde), dann könnte das durchaus stabil laufen.
Ich würde aber trotzdem die Callback-Funktion in einer höheren Sprache schreiben...
E
Vielleicht hilft dir diese UDF: UDF - TrueType Fonts im Script mitgeben und verwenden
E
Kommt drauf an, ob du die Noten in Echtzeit "abspielen" willst.
Wenn nicht, dann bekommst du mit "_BASS_MIDI_StreamGetEvents" ein Array mit allen Events, welche du dann einzelen auswerten kannst.
Wenn es in Echtzeit gehen soll, dann gibt es zwei Möglichkeiten:
1) wie oben, nur die Event-Funktionen erst ausführen, wenn der Timecode der abgespielten Mididatei den Eventzeitstempel erreicht...
2) Mit einer SyncProc:
[autoit]_BASS_ChannelSetSync($hMidiStream, $BASS_SYNC_MIDI_EVENT, $MIDI_EVENT_NOTE, "_SyncProc", 0)
[/autoit][autoit][/autoit][autoit]Func _SyncProc($handle, $channel, $data, $user)
Local Static $iCnt = 0
$iCnt += 1
Local $iKeyNumber = _BASS_LoByte($data)
Local $iVelocity = _BASS_HiByte($data)
ConsoleWrite("! Midi event: " & $iCnt & @TAB & $iKeyNumber & "/" & $iVelocity & @CRLF)
[/autoit][autoit][/autoit][autoit]Return True
EndFunc ;==>_SyncProc
ACHTUNG: für diese Variante ist AutoIt nicht geeignet! und wird bei zu vielen Events abstürzen!
Du könntest aber eine DLL in einer höheren Programmiersprache erstellen...
E
Sehr geiles Script!
Du brauchst nicht auf die eingestellte Ansicht zu achten - mit ClientToScreen bekommst du die genauen Screen Koordinaten des Clientbereichs...
Ich hab versucht das Script mit einer anderen Methode schneller zu machen:
hBitmap vom Desktop wird direkt in ein Gdiplus-Bitmap umgewandelt.
Dieses verkleinert und dann vergrößert (Blur-Effekt)
Farbverlauf darüber und dann auf das Fenster geblittet - das wars
Dadurch ist die Funktion etwa 10ms schneller (25ms statt 35ms bei mir)
Das Ruckeln ist aber immer noch vorhanden. Das liegt aber nicht (nur) an der Geschwindigkeit, sondern am Verschieben des Fensters.
Ich hab mich damit schon ein paar mal beschäftigt, aber noch keine Lösung gefunden.
Bei meinen Scripten BlackHole und Mauslupe hab ich dann einfach ein Fullscreenfenster genommen und so das Verschiebe-ruckeln umgangen ![]()
Hier mal meine Version von Aero:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iWidth = 600
Global $iHeight = 400
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $hGui = GUICreate("Test", $iWidth, $iHeight, Default, Default, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
_GDIPlus_Startup()
Global $hDC = _WinAPI_GetDC($hGui)
Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
_WinAPI_DeleteObject($hBMP)
$hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
_GDIPlus_BitmapDispose($hBmpTmp)
Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
Global $iBlurW = Ceiling($iWidth * 0.4)
Global $iBlurH = Ceiling($iHeight * 0.4)
Global $hBmpBlur = _GDIPlus_BitmapCreateFromGraphics($iBlurW, $iBlurH, $hGfxBuffer)
Global $hGfxBlur = _GDIPlus_ImageGetGraphicsContext($hBmpBlur)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxBlur, "int", 2)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfxBlur, "int", 6)
Global $hDC_Screen = _WinAPI_GetDC(0)
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
GUIRegisterMsg($WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
WinSetTrans($hGui, "", 0xFF)
GUISetState()
_SetGuiRoundCorners($hGui, 16, True, False, True, False)
_RePaint()
While 1
Sleep(100)
WEnd
Func _RePaint()
Local $aResult = DllCall("gdi32.dll", "hwnd", "GetCurrentObject", "hwnd", $hDC_Screen, "int", 7)
Local $hBmpScreen = _GDIPlus_BitmapCreateFromHBITMAP($aResult[0])
Local $tPoint = DllStructCreate("int X; int Y;")
_WinAPI_ClientToScreen($hGui, $tPoint)
Local $tRectF = _GDIPlus_RectFCreate(DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2), $iWidth, $iHeight)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrushFromRectWithAngle", "ptr", DllStructGetPtr($tRectF), "uint", 0x60202040, "uint", 0xA0F0F0F0, "float", -60, "int", False, "int", 1, "int*", 0)
Local $hBrush = $aResult[7]
_GDIPlus_GraphicsDrawImageRectRect($hGfxBlur, $hBmpScreen, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2), $iWidth, $iHeight, 0, 0, $iBlurW, $iBlurH)
_GDIPlus_GraphicsDrawImageRect($hGfxBuffer, $hBmpBlur, 0, 0, $iWidth, $iHeight)
_GDIPlus_GraphicsFillRect($hGfxBuffer, 0, 0, $iWidth, $iHeight, $hBrush)
_GDIPlus_BitmapDispose($hBmpScreen)
_GDIPlus_BrushDispose($hBrush)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
EndFunc ;==>_RePaint
Func WM_WINDOWPOSCHANGED($hWnd, $iMsg, $StartWIndowPosaram, $lParam)
_RePaint()
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_WINDOWPOSCHANGED
Func WM_NCHITTEST($hWndGUI, $MsgID, $WParam, $lParam)
If ($hWndGUI = $hGui) And ($MsgID = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Func WM_PAINT($hWnd, $uMsgm, $WParam, $lParam)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_PAINT
Func _Exit()
_WinAPI_ReleaseDC(0, $hDC_Screen)
_GDIPlus_GraphicsDispose($hGfxBlur)
_GDIPlus_BitmapDispose($hBmpBlur)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_WinAPI_SelectObject($hCDC, $hOBJ)
_WinAPI_DeleteObject($hBMP)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hGui, $hDC)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
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
und ich nutze gleich die Gelegenheit nochmals BlackHole und Mauslupe zu posten
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
If @OSBuild > 5999 Then Exit MsgBox(16, "Error", "Working on WinXP only", 30)
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}", "_Exit")
[/autoit] [autoit][/autoit] [autoit]Opt("MustDeclareVars", 1)
[/autoit] [autoit][/autoit] [autoit]Global $fArea = 0.3
Global $iSize = 200
Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight
_GDIPlus_Startup()
Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT), _WinAPI_GetDesktopWindow())
Global $hDC = _WinAPI_GetDC($hGui)
Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
Global $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC)
Global $hBmpSize = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGfx)
Global $hGfxSize = _GDIPlus_ImageGetGraphicsContext($hBmpSize)
_GDIPlus_GraphicsDispose($hGfx)
Global $hBrush = _CreateBrush()
[/autoit] [autoit][/autoit] [autoit]Global $tSize = DllStructCreate($tagSIZE)
Global $pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iWidth)
DllStructSetData($tSize, "Y", $iHeight)
Global $tSource = DllStructCreate($tagPOINT)
Global $pSource = DllStructGetPtr($tSource)
Global $tBlend = DllStructCreate($tagBLENDFUNCTION)
Global $pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 0xFF)
DllStructSetData($tBlend, "Format", 1)
Global $hMod = _WinAPI_GetModuleHandle(0)
Global $hProc = DllCallbackRegister("_MouseProc", "int", "int;ptr;ptr")
Global $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hProc), $hMod, 0)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]While Sleep(10)
WEnd
Func _Draw($iMX, $iMY)
Local $hCAP = _ScreenCapture_Capture("", $iMX, $iMY, $iMX + $iSize, $iMY + $iSize, False)
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hCAP)
_WinAPI_DeleteObject($hCAP)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hBitmap, "int", 0, "int*", 0)
Local $hTexture = $aResult[3]
_GDIPlus_BitmapDispose($hBitmap)
Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Local $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hCDC)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hContext, "int", 7)
Local $hMatrix = _GDIPlus_MatrixCreate()
Local $fScale
Local $fTmp = 0
For $i = 1 To Floor($iSize / 2) Step 2
$fTmp = $i * ($iSize * $fArea) / ($iSize / 2) * 2.3
$fScale = (($iSize - $fTmp) / ($iSize - $i * 2))
DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
_GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
_GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
_GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
_GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hContext, "handle", $hTexture, "float", $i, "float", $i, "float", $iSize - $i * 2, "float", $iSize - $i * 2)
Next
DllCall($ghGDIPDll, "uint", "GdipResetWorldTransform", "hwnd", $hContext)
_GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, $iMX, $iMY)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_BrushDispose($hTexture)
_GDIPlus_GraphicsDispose($hGraphics)
_WinAPI_UpdateLayeredWindow($hGui, $hDC, 0, $pSize, $hCDC, $pSource, 0, $pBlend, $ULW_ALPHA)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_SelectObject($hCDC, $hOBJ)
_WinAPI_DeleteObject($hBMP)
EndFunc ;==>_Draw
[/autoit] [autoit][/autoit] [autoit]Func _CreateBrush()
Local $fTmp = $iSize * $fArea
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
Local $hPath = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipAddPathEllipse", "hwnd", $hPath, "float", $fTmp, "float", $fTmp, "float", $iSize - $fTmp * 2, "float", $iSize - $fTmp * 2)
[/autoit] [autoit][/autoit] [autoit]$aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePathGradientFromPath", "hwnd", $hPath, "int*", 0)
Local $hBrush = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipSetPathGradientCenterColor", "hwnd", $hBrush, "uint", 0xFF000000)
Local $aColor[2] = [1, 0x00000000]
Local $tColor = DllStructCreate("uint")
DllCall($ghGDIPDll, "uint", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", DllStructGetPtr($tColor), "int*", 1)
DllCall($ghGDIPDll, "uint", "GdipSetPathGradientFocusScales", "hwnd", $hBrush, "float", 0.7, "float", 0.7)
DllCall($ghGDIPDll, "uint", "GdipSetPathGradientGammaCorrection", "hwnd", $hBrush, "int", True)
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
Return $hBrush
EndFunc ;==>_CreateBrush
Func _MouseProc($nCode, $wParam, $lParam)
If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
Local $tStruct = DllStructCreate("int X;int Y;dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo", $lParam)
_Draw(DllStructGetData($tStruct, 1) - ($iSize / 2), DllStructGetData($tStruct, 2) - ($iSize / 2))
Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_MouseProc
Func _Exit()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hProc)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hGui, $hDC)
_GDIPlus_BitmapDispose($hBmpSize)
_GDIPlus_GraphicsDispose($hGfxSize)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
If @OSBuild > 5999 Then Exit MsgBox(16, "Error", "Working on WinXP only", 30)
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}", "_Exit")
[/autoit] [autoit][/autoit] [autoit]Opt("MustDeclareVars", 1)
[/autoit] [autoit][/autoit] [autoit]Global $iSize = 200
Global $iSize_D2 = $iSize / 2
Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight
Global Const $PI = ATan(1) * 4
Global Const $PI_M2 = $PI * 2
Global Const $PI_D2 = $PI / 2
_GDIPlus_Startup()
Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT), _WinAPI_GetDesktopWindow())
Global $hDC = _WinAPI_GetDC($hGui)
Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
Global $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC)
Global $hBmpSize = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGfx)
Global $hGfxSize = _GDIPlus_ImageGetGraphicsContext($hBmpSize)
_GDIPlus_GraphicsDispose($hGfx)
Global $tSize = DllStructCreate($tagSIZE)
Global $pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iWidth)
DllStructSetData($tSize, "Y", $iHeight)
Global $tSource = DllStructCreate($tagPOINT)
Global $pSource = DllStructGetPtr($tSource)
Global $tBlend = DllStructCreate($tagBLENDFUNCTION)
Global $pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 0xFF)
DllStructSetData($tBlend, "Format", 1)
Global $hMod = _WinAPI_GetModuleHandle(0)
Global $hProc = DllCallbackRegister("_MouseProc", "int", "int;ptr;ptr")
Global $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hProc), $hMod, 0)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]While Sleep(10)
WEnd
Func _Draw($iMX, $iMY)
Local $hCAP = _ScreenCapture_Capture("", $iMX, $iMY, $iMX + $iSize, $iMY + $iSize, False)
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hCAP)
_WinAPI_DeleteObject($hCAP)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hBitmap, "int", 0, "int*", 0)
Local $hTexture = $aResult[3]
_GDIPlus_BitmapDispose($hBitmap)
Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Local $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hCDC)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hContext, "int", 7)
Local $hMatrix = _GDIPlus_MatrixCreate()
Local $fScale
For $i = 1 To $iSize_D2 Step 2
$fScale = ((Sin($i * $PI_M2 / $iSize - $PI_D2) + 1) / 2) * 0.4 + 1
DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
_GDIPlus_MatrixTranslate($hMatrix, $iSize_D2, $iSize_D2)
_GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
_GDIPlus_MatrixTranslate($hMatrix, -$iSize_D2, -$iSize_D2)
_GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hContext, "handle", $hTexture, "float", $i, "float", $i, "float", $iSize - $i * 2, "float", $iSize - $i * 2)
Next
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, $iMX, $iMY)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_BrushDispose($hTexture)
_GDIPlus_GraphicsDispose($hGraphics)
_WinAPI_UpdateLayeredWindow($hGui, $hDC, 0, $pSize, $hCDC, $pSource, 0, $pBlend, $ULW_ALPHA)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_SelectObject($hCDC, $hOBJ)
_WinAPI_DeleteObject($hBMP)
EndFunc ;==>_Draw
Func _MouseProc($nCode, $wParam, $lParam)
If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
Local $tStruct = DllStructCreate("int X;int Y;dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo", $lParam)
_Draw(DllStructGetData($tStruct, 1) - ($iSize / 2), DllStructGetData($tStruct, 2) - ($iSize / 2))
Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_MouseProc
Func _Exit()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hProc)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hGui, $hDC)
_GDIPlus_BitmapDispose($hBmpSize)
_GDIPlus_GraphicsDispose($hGfxSize)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Schade eigentlich, dass die Scripte nur unter XP funktionieren ![]()
E
Mit MouseGetCursor kannst du auslesen, welcher Mauszeiger grad angezeigt wird.
Warum dies keine Sinuskurve ist, und warum es eigentlich egal ist, was ich für eine Kurve sende (Ob Sinus oder Block oder Dreieck), die Kurve trotzdem immer relativ gleich aussieht (aber auch nicht ganz gleich) ist mir zwar bisher ein Rätsel
Vielleicht ist nur die Abtastrate zu niedrig, das könnte das Ergebnis erklären - siehe Bild:
Die Abtastrate muss mindestens doppelt so groß sein, wie die abzutastende Frequenz (deshalb auch 44100Hz bei einer Audio-CD um 20000Hz wiederzugeben ;))
=============
Um mehr Punkte zu verwenden, und trotzem eine höhere Framerate zu erzielen, kannst du auch einen zusätzlichen, kleineren Grafik-Buffer verwenden und diesen dann mit DrawImageRect auf die endgültige Größe skalieren.
Das Ergebnis ist dann zwar nicht mehr so schön, aber mit ein paar Einstellungen (Smoothingmode, Interpolationmode) kann das ERgebnis durchaus annehmbar sein...
E
Gerade eukalyptus´ Post gelesen^^
[autoit]Global $iPnt = 20
[/autoit]Ist natürlich geschönt^^, aber selbst bei 200 Punkten erreicht man noch 30-40FPS
Die Frage ist, ob Bezier-splines gewünscht sind^^
Selbstverständlich ist das geschönt
Das Script soll ja zeigen, wieviel fps GDI+/GDI schafft, und nicht, wie lange AutoIt benötigt, um die Daten zu verwerten...
Um die Daten in das passende Format zu bringen, damit GDI+ etwas damit anfangen kann, würde ich sowieso nicht AutoIt verwenden (wenn es mehr als 200 Werte sind),
sondern eine Dll dafür schreiben, oder FASM verwenden...
Falls keine Glättung erwünscht ist, kann man auch das hier verwenden:
[autoit]DllCall($ghGDIPDll, "uint", "GdipDrawCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPen, "ptr", $pOsc, "int", $iPnt, "float", 0)
[/autoit]
oder auch das hier:
DllCall($ghGDIPDll, "int", "GdipDrawPolygon", "handle", $hGfxBuffer, "handle", $hPen, "ptr", $pOsc, "int", $iPnt)
[/autoit]EDIT: Jetzt hab ich erst verstanden, was Andy gemeint hat
Auch die GDI+ Funktion dauert länger bei mehreren Punkten
Ich komme bei 200 Punkten auf einen Framrate von 86fps...
E
Ich halte GDI+ definitiv NICHT für zu langsam
Und auch für die angenehmste, einfachste und umfangreichste Methode
Zum Testen der Framerate, wenn nur eine Kurve gezeichnet wird:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iWidth = 1280
Global $iHeight = 1024
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $hGui = GUICreate("Sine", $iWidth, $iHeight, 0, 0, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
_GDIPlus_Startup()
Global $hDC = _WinAPI_GetDC($hGui)
Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
_WinAPI_DeleteObject($hBMP)
$hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
_GDIPlus_BitmapDispose($hBmpTmp)
Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
;_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2)
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
GUISetState()
Global $iPnt = 20
Global $tOsc = DllStructCreate("float[" & $iPnt * 2 & "];")
Global $pOsc = DllStructGetPtr($tOsc)
For $i = 0 To $iPnt - 1
DllStructSetData($tOsc, 1, $i * $iWidth / ($iPnt - 1), $i * 2 + 1)
Next
Global $iFrms = 0
Global $iTimer = TimerInit()
While 1
$iFrms += 1
If Mod($iFrms, 10) = 0 Then ToolTip(Round($iFrms / (TimerDiff($iTimer) / 1000), 2) & "fps")
_Draw()
;Sleep(10)
WEnd
Func _Draw()
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
For $i = 0 To $iPnt
DllStructSetData($tOsc, 1, Random(0, $iHeight), $i * 2 + 2)
Next
DllCall($ghGDIPDll, "int", "GdipDrawCurve", "handle", $hGfxBuffer, "handle", $hPen, "ptr", $pOsc, "int", $iPnt)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
EndFunc ;==>_Draw
Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_PAINT
Func _Exit()
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_WinAPI_SelectObject($hCDC, $hOBJ)
_WinAPI_DeleteObject($hBMP)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hGui, $hDC)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
E
Alles Gute, ihr beiden!
Hey, natürlich auch noch die besten Beglückwünsche von mir!
Alles Gute, Xeno!
Sehr gut - Danke!
Ich hab zwar noch nie mit GpEdit gearbeitet, aber zumindest funktioniert er unter Win7 Home schon mal ![]()
E