Die Credits gebühren MOD (?) von freebasic.net http://www.freebasic.net/forum/viewtopic.php?t=15164
Hier noch der FreeBasic Sourcecode der DLL: autoit.de/wcf/attachment/14721/
evtl. kannst du da noch etwas Geschwindigkeit rausschinden...
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: autoit.de/wcf/attachment/14721/
evtl. kannst du da noch etwas Geschwindigkeit rausschinden...
E
Mit dieser Dll ist MD5 etwa 20% schneller: autoit.de/wcf/attachment/14720/
[autoit]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:autoit.de/wcf/attachment/14667/
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
Einer der beiden Ram Module ist fehlerhaft! Das erklärt mal die Bluescreens und evtl. das fehlerhafte starten von Comodo Firewall.
Dass Antivir jedoch "deaktiviert" startete und sich auch nicht aktivieren ließ, und bei einem Update meldete, dass ein CRC-Check eines Modules nicht passt und es möglicherweise von einem Virus verändert wurde, könnte tatsächlich von einem Virus verursacht worden sein - welcher auch nach dem ersten ReImage weg war.
Waren halt dummerweise 2 Sachen gleichzeitig, also Ramspeicher defekt und ein "normaler" Virus... - hoffentlich
Bei Windows 7 Home gibts das leider nicht, man muss alles manuell einstellen.
Oder gibt es vielleicht ein Freeware-Tool, bei dem man das auch einstellen kann?
Scheiße! Grad wieder Bluescreen und MemTest findet tatsächlich Fehler im Speicher
Werd mal schauen, ob ich mehrere RamRiegel hab, damit ich mal einen davon ausbauen kann...
Hi
Hab grad Probleme mit meinem Laptop.
Ich beschreibe mal, was so alles passiert ist bzw. was ich gemacht hab...
Vorgestern stoppte der Laptop beim Bootvorgang einmal im Dual-Boot-Menü (WinXP & Win7)
und dann noch einmal während des Ladebalkens beim Starten von XP.
Das kam mir zwar etwas seltsam vor, hab mir aber noch nichts ernstes dabei gedacht.
Heute morgen verabschiedete sich WinXP mit einem Bluescreen.
Ich hab dann mal das Netzwerkkabel abgezogen und neu gestartet.
Antivir startete im "deaktivierten Modus" und Comodo Firewall meldete einen Fehler
Ich wollte mit HiJackThis einen Scan machen -> Bluescreen!
Glücklicherweise hab ich von den Systempartitionen von XP und Win7 Images, welche ich via Norton Ghost raufgespielt hab.
Beim neuerlichen booten starteten AntiVir und Comodo wieder normal - allerdings hatte ich bald wieder einen Bluescreen!
Ich dachte in diesem Moment an einen Hardwaredefekt, denn auch Win7 verabschiedete sich beim Starten...
Nochmals XP booten - Antivir manuell updaten (Update auf einem anderen Rechner runtergeladen) - AntiVir meldet, dass irgendein Modul geändert wurde, möglicherweise ein Virus...
Nun hab ich zuerst das Bios neu geflasht, dann die beiden Images wieder raufgezogen - jetzt scheint wieder alles gut zu laufen...
Momentan mache ich einen kompletten Scan mit einem geupdateten Antivir
Wenn es ein Virus war, dann konnte der doch nur im Bios sitzen!?
Denn beim Imageraufspielen wird doch die ganze Partition überschrieben, incl. Bootsektoren, oder?
Kann ein Virus überhaupt vom Bios aus agieren, bzw. wie geht das?
Befindet sich der Schadcode vielleicht auf einer "freien" Stelle meiner Festplatte, welche auch von Norton Ghost nicht überschrieben wird?
Ich hoffe, dass mein System jetzt wieder einwandfrei läuft!
thx
E
Das gefällt mir schon mal!
Wenn der Taskmanager gesperrt ist, hat der User sonst noch irgeneine Möglichkeit etwas "falsches" zu machen?
Gibt es vielleicht eine Tastenkombination, welche Explorer.exe startet oder sowas?
thx
E
Ich kenne mich mit Win7 noch nicht richtig aus und benötige daher eure Hilfe für die Konfiguration eines Laptops, welcher folgendermassen funktionieren soll:
Beim Einschalten startet automatisch meine eigene Software statt der Explorershell.
Alle Anschlüsse sind deaktiviert, also WLAN, LAN, Flashdrive, USB, Bluetooth usw... sollen nicht funktionieren.
Jedoch darf der User am USB ein Midi-Interface anschließen und soll auch den Treiber dafür installieren dürfen (evtl. geht das auch nur über den Admin-Account)
Taskmanager soll deaktiviert sein, aber ein Admin soll trotzdem zum Admin-Account wechseln bzw. in speziellen Fällen auch die normale Explorershell starten können.
Mein Plan sieht bisher so aus:
Ich erstelle einen passwortgeschützen Admin-Account und einen ungeschützten User-Account.
Via den Registry Einträgen:
Current_User\Software\Microsoft\CurrentVersion\WinLogon Shell = Software.exe
Local_Machine\Software\Microsoft\CurrentVersion\WinLogon AutoAdminLogon = 1
Local_Machine\Software\Microsoft\CurrentVersion\WinLogon DefaultUserName = User
startet automatisch der Useraccount mit Software.exe als Shellersatz
Wie deaktiviere ich nun den Taskmanager?
Ich könnte in Software.exe alle Tastatureingaben mit Keyboard_ll-Hook blockieren und nur mittels spezieller Tastenfolge freigeben...
Oder gibt es da eine elegantere Lösung?
Wie deaktiviere ich alle Schnittstellen, mit Ausnahme des Midiinterfaces und einer Maus am USB Port?
Geht das in Win7 (Home Premium) ganz elegant, oder soll ich das via AutoItscript und WMI machen?
Wenn WMI, wie?
Wie soll der User einen Treiber für ein neues Midi-Interface installieren können?
Dazu müsste der User kurzfristig einen USB-Stick verwenden können, bzw. auch über Admin-Rechte verfügen?!
Oder kann ein Admin über seinen Account diesen Treiber für den User-Account installieren?
Hoffe, ihr könnt mir etwas weiterhelfen - Danke
E