Tach auch
Ich wollte nen kleinen Macro recorder schreiben.
Habe hier mal angefangen, mit nur ein paar Tasten, jedoch scheint mir Autoit zu langsam um die Zeiten exakt einzuhalten
ich denke der Code versteht sich von selbst
Spoiler anzeigen
#Include <Misc.au3>
#Include <Array.au3>
HotKeySet('{ESC}','_exit')
HotKeySet('r','Aufzeichnen')
HotKeySet('p','Abspielen')
While 1
Sleep(200)
WEnd
Func Aufzeichnen()
Local $aKeys[5] = [25,26,27,28,20], $aCommands[1], $tTimer, $aTmpPressedKeys[1]
Local $hDll = DllOpen("user32.dll")
$tTimer = TimerInit()
Do
For $i = 0 To UBound($aKeys)-1
If _IsPressed($aKeys[$i],$hDll) Then
$bIsPressed = False
For $j = 1 To UBound($aTmpPressedKeys)-1
If $aKeys[$i] = $aTmpPressedKeys[$j] Then $bIsPressed = True
Next
If Not $bIsPressed Then
_ArrayAdd($aCommands,TimerDiff($tTimer))
_ArrayAdd($aCommands,$aKeys[$i] & ';1')
_ArrayAdd($aTmpPressedKeys,$aKeys[$i])
$tTimer = TimerInit()
EndIf
Else
$bIsPressed = False
For $j = 1 To UBound($aTmpPressedKeys)-1
If $aKeys[$i] = $aTmpPressedKeys[$j] Then $bIsPressed = True
Next
If $bIsPressed Then
_ArrayAdd($aCommands,TimerDiff($tTimer))
_ArrayAdd($aCommands,$aKeys[$i] & ';0')
For $j = 1 To UBound($aTmpPressedKeys)-1
If $aKeys[$i] = $aTmpPressedKeys[$j] Then
_ArrayDelete($aTmpPressedKeys,$j)
ExitLoop
EndIf
Next
$tTimer = TimerInit()
EndIf
EndIf
Next
Until _IsPressed('53',$hDll)
_ArrayDisplay($aCommands)
FileWrite(@ScriptDir & '\commands.txt',_ArrayToString($aCommands,'|',1))
EndFunc
Func Abspielen()
Local $aKeys[5][2] = [[25,'LEFT'],[26,'UP'],[27,'RIGHT'],[28,'DOWN'],[20,'SPACE']]
Local $File = FileRead(@ScriptDir & '\commands.txt')
If @error Then ExitWithErrorMsg("Fehler",'Datei wurde nicht gefunden!')
Local $aFile = StringSplit($File,'|',2)
If @error Then ExitWithErrorMsg("Fehler",'Datei ist nicht im richtigen Format!')
_ArrayDisplay($aFile)
For $i = 0 To UBound($aFile)-1
If StringInStr($aFile[$i],';') Then
Local $aTmp_Comamnd = StringSplit($aFile[$i],';',2)
If $aTmp_Comamnd[1] = '1' Then
For $j = 0 To UBound($aKeys)-1
If $aKeys[$j][0] = $aTmp_Comamnd[0] Then Send('{' & $aKeys[$j][1] & ' down}')
Next
ElseIf $aTmp_Comamnd[1] = '0' Then
For $j = 0 To UBound($aKeys)-1
If $aKeys[$j][0] = $aTmp_Comamnd[0] Then Send('{' & $aKeys[$j][1] & ' up}')
Next
EndIf
Else
Local $ttint = TimerInit()
Do
Until TimerDiff($ttint) >= $aFile[$i]
EndIf
Next
MsgBox(0,"","")
EndFunc
Func ExitWithErrorMsg($Title, $Msg)
MsgBox(0, $Title, $Msg)
Exit
EndFunc
Func _exit()
Exit
EndFunc