Makrogenerator ?

  • Hi,

    also ich suche einen Makrogenerator, so ähnlich wie AU3Record nur mit einem zusatz: Er sollte auch die Zeit speichern, die eine Taste gedrückt wird, da das mein Hauptproblem ist. Ich weiß nicht wie lange die Taste gedrückt wird.

    Die Aufzeichnung könnte ja evtl. so aus :

    [autoit]


    "{Pfeilnachoben}" ;--For 2 Seconds
    "{Pfeilnachrechts}" ;-- For 1 Second
    "{Pfeilnachlinks}" ;--For 0,43 Seconds

    [/autoit]

    Naja so oder so ähnlich..das der auch die Länge der Tastendrücke aufzeichnet...

    Thx in Advance

    the
    MrWong

    3 Mal editiert, zuletzt von MrWong (22. März 2009 um 09:28)

  • hehe xD Das war jetz so eine Antwort nach dem Motto : "Hier ist der Ansatz den Rest machste allein!" ^^ Aber erstmal danke schön..werde mich gleich mal ransetzen ^^ Je nach Ergebnis das Präfix des Topics ändern oder halt nochmal hier posten ^^

    the
    MrWong

  • Soo ich hab dir ebn ma was zusammengebastelt:

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    While _IsPressedMod($dll); clear buffer
    WEnd
    While 1
    Sleep(250)
    $typed = _IsPressedMod($dll)
    If $typed Then ExitLoop
    WEnd
    DllClose($dll)

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0,'HexKey',$typed & @LF)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    If _isPressed($typed) Then
    $time = TimerInit()
    While _isPressed($typed)
    sleep(100)
    Wend
    ExitLoop
    Endif
    Wend

    [/autoit] [autoit][/autoit] [autoit]

    $diff = INT(Timerdiff($time))
    MsgBox(0,"Info!", "Time you pressed the button (in ms): " & $diff)

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $bRv, $hexKey, $i
    For $i = 1 To 256
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then Return Hex($i,2)
    Next
    Return 0
    EndFunc ;==>_IsPressedMod

    [/autoit]
  • Zitat

    Halleluja !

    Das nennst du mal eben ^^ Hatte mich auch grad rangesetzt, aber deins sieht viel Erfolgversprechender aus wie das was ich da hab xD Gleich mal ausprobieren schon jetz ein dickes Thx für deine Hilfe.

    the
    MrWong

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    $dll = DllOpen("user32.dll")
    $log = @UserName&"zeitlog.html"
    HotKeySet("{NUMPADDIV}","Start")
    HotKeySet("{NUMPADMULT}","Ende")

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($log) = 1 Then
    FileDelete($log)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    While (1)
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Start()
    While _IsPressedMod($dll); clear buffer
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(250)
    $typed = _IsPressedMod($dll)
    If $typed Then ExitLoop
    WEnd
    DllClose($dll)

    [/autoit] [autoit][/autoit] [autoit]

    FileWrite($log, $typed)
    ;~ MsgBox(0,'HexKey',$typed & @LF)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    If _isPressed($typed) Then
    $time = TimerInit()
    While _isPressed($typed)
    sleep(100)
    Wend
    ExitLoop
    Endif

    [/autoit] [autoit][/autoit] [autoit]

    $diff = INT(Timerdiff($time))
    FileWrite($log,"<br><BR>"&$diff)
    ;~ MsgBox(0,"Info!", "Time you pressed the button (in ms): " & $diff)
    Wend

    [/autoit] [autoit][/autoit] [autoit]

    Start()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $bRv, $hexKey, $i
    For $i = 1 To 256
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then Return Hex($i,2)
    Next
    Return 0
    EndFunc ;==>_IsPressedMod

    [/autoit] [autoit][/autoit] [autoit]

    Func Ende()
    Exit
    EndFunc

    [/autoit]

    Und da haperts wieder ^^ Habs jetzt versucht in eine Func einzubauen und somit zu erreichen, dass ich nicht nur jeweils EINE Taste speichern kann, sondern mehrere. Diese werden dann in die UsernameLog.html gespeichert und können danach ausgelesen werden..Aber funzen tut das nicht. 1.Speichert der sich die Zeit nicht und zweitens kommt nach dem drücken der ersten aufzuzeichnden Taste diese Fehlermeldung:

    Error Line 51
    "If $aR[0] <> 0 Then Return Hex($i,2)"

    Variable used without Non-Array variable...oder so ähnlich halt, aber ich denke ihr kennt die Fehlermeldung ^^

    Pls help?

    the
    MrWong

  • Au hey... ehm das war im Prinzip nurn Beispiel ;) Für deinen Fall is es glaub ich besser das so zu machen:

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")
    $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $pressed = _IsPressedMod($dll)
    MsgBox(0,"Info:","Time you pressed the button(in ms): " & $pressed)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $hexKey, $i
    While 1
    For $i = 1 To 128
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then
    $hexKey = Hex($i,2)
    $time = TimerInit()
    While _isPressed($hexKey)
    sleep(100)
    Wend
    $diff = INT(Timerdiff($time))
    Return $diff
    EndIf
    Next
    Wend
    EndFunc ;==>_IsPressedMod

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    DllClose($dll)
    Exit
    EndFunc

    [/autoit]
  • So wie ich das sehe und auch jetz hab abspeichern lassen läuft das schon bestens..nur da fehlt der Button den ich gedrückt hab...Also z.B. Pfeil nach oben..da wird nur die Zeit angezeigt wie lange ich die entsprechende Taste gedrückt hab..lässt sich da was machen? Hab schon aus deinem vorherigen Code versucht rauszusuchen wie ich die Taste rausfinde, aber dazu bräuchte ich die _IsPressed Funktion wieder einzeln ohne direkte Zeit Ausrechnung...hmm ist gar nicht so einfach xDD

    Trotzdem erstmal seeehr großes Lob und riesen danke für deine bisherige super Hilfe =)

    the
    MrWong

    EDIT: So hab mir das jetzt etwas umgebaut...aber was der dadurch speichert ist unsinn...

    Hier mein Ergebnis:

    Spoiler anzeigen

    435

    422

    1625

    1196

    1408

    1202

    97

    102

    108

    216

    107

    101

    203

    108

    648

    102

    96

    102

    104

    99

    654

    208

    104

    214

    108

    106

    104

    103

    101

    98

    101

    96

    105

    100

    108

    99

    107

    103

    102

    107

    116

    105

    105

    434

    107

    206

    543

    107

    107

    100

    643

    102

    101

    101

    103

    95

    107

    3168

    106

    94

    378

    214

    106

    105

    96

    95

    322

    100

    102

    95

    106

    109

    100

    106

    106

    103

    208

    107

    105

    98

    105

    105

    216

    106

    95

    108

    106

    104

    104

    106

    97

    98

    98

    102

    106

    103

    93

    99

    105

    212

    103

    106

    108

    100

    106

    99

    102

    106

    106

    107

    102

    95

    210

    99

    95

    106

    95

    96

    102

    107

    104

    95

    212

    106

    106

    106

    206

    102

    103

    106

    98

    106

    94

    101

    108

    205

    106

    107

    213

    106

    216

    105

    105

    106

    99

    100

    105

    103

    214

    106

    105

    216

    108

    99

    99

    106

    105

    95

    210

    105

    98

    106

    106

    107

    210

    106

    97

    107

    105

    106

    107

    94

    106

    106

    315

    104

    99

    106

    98

    100

    210

    98

    542

    206

    103

    107

    99

    102

    100

    98

    106

    105

    99

    102

    109

    105

    106

    107

    215

    102

    99

    109

    98

    107

    95

    97

    105

    95

    216

    107

    96

    105

    102

    101

    106

    98

    105

    104

    105

    104

    107

    100

    216

    214

    105

    107

    96

    103

    103

    102

    102

    109

    95

    105

    106

    107

    102

    94

    108

    210

    106

    100

    107

    105

    106

    106

    211

    97

    104

    106

    109

    216

    108

    106

    106

    103

    218

    100

    106

    105

    106

    98

    106

    106

    105

    101

    106

    105

    106

    106

    106

    108

    326

    96

    204

    108

    105

    96

    433

    1082

    104

    105

    108

    103

    106

    106

    212

    106

    216

    213

    213

    95

    105

    105

    99

    106

    209

    326

    106

    104

    106

    106

    105

    212

    210

    108

    100

    104

    106

    105

    107

    94

    106

    106

    107

    100

    101

    98

    106

    107

    104

    95

    106

    106

    105

    106

    203

    105

    215

    106

    107

    212

    105

    106

    107

    106

    97

    94

    102

    97

    107

    208

    105

    105

    105

    435

    204

    107

    216

    105

    100

    213

    208

    96

    105

    97

    103

    107

    210

    105

    106

    105

    105

    106

    427

    96

    108

    107

    207

    105

    103

    209

    106

    95

    94

    94

    102

    216

    105

    211

    106

    211

    106

    107

    207

    96

    101

    105

    105

    106

    106

    205

    108

    213

    214

    107

    100

    107

    100

    106

    104

    105

    103

    96

    105

    106

    106

    102

    106

    105

    98

    218

    94

    106

    105

    105

    107

    215

    98

    105

    96

    102

    214

    106

    107

    99

    106

    95

    213

    105

    107

    96

    98

    216

    216

    94

    100

    101

    1092

    106

    97

    106

    107

    107

    215

    102

    102

    210

    106

    217

    207

    103

    204

    325

    109

    210

    104

    95

    204

    868

    106

    102

    95

    94

    99

    107

    317

    98

    214

    103

    425

    103

    106

    318

    105

    103

    99

    105

    108

    209

    1735

    209

    103

    105

    546

    216

    327

    106

    106

    216

    106

    316

    106

    102

    543

    215

    99

    543

    641

    102

    97

    213

    106

    102

    314

    1191

    210

    215

    532

    217

    325

    538

    94

    208

    207

    217

    753

    104

    101

    97

    98

    102

    96

    0 - 546

    0 - 546

    0 - 644

    0 - 105

    0 - 108

    Und der Code der dazu geführt hat:

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")
    $dll = DllOpen("user32.dll")
    $log = @UserName&"File.html"
    While 1
    $pressed = _IsPressedMod($dll)
    $pressed2= _IsPressedMod2($dll)
    FileWrite($log,$pressed2&" - "&$pressed&"<br><BR>")
    ;~ MsgBox(0,"Info:","Time you pressed the button(in ms): " & $pressed)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $hexKey, $i
    While 1
    For $i = 1 To 128
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then
    $hexKey = Hex($i,2)
    $time = TimerInit()
    While _isPressed($hexKey)
    sleep(100)
    Wend
    $diff = INT(Timerdiff($time))
    Return $diff
    EndIf
    Next
    Wend
    _IsPressedMod2()
    EndFunc ;==>_IsPressedMod

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod2($dll = "user32.dll")
    Local $aR, $bRv, $hexKey, $i
    For $i = 1 To 256
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then Return Hex($i,2)
    Next
    Return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    DllClose($dll)
    Exit
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von MrWong (21. März 2009 um 16:59)

  • Und du machst es dir schon wieder zu kompliziert :D

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")
    $dll = DllOpen("user32.dll")
    $log = @UserName&"File.html"

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $pressed = _IsPressedMod($dll)
    ;~ MsgBox(64,"Info:","Time you pressed the button(in ms): " & $pressed)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $hexKey, $i
    While 1
    For $i = 1 To 128
    $hexKey = '0x' & Hex($i, 2)
    $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
    If $aR[0] <> 0 Then
    $hexKey = Hex($i,2)
    $time = TimerInit()
    While _isPressed($hexKey)
    Wend
    $diff = INT(Timerdiff($time))
    $hexKey = HexEscape($hexKey)
    Filewrite($log,$hexKey & " - " & $diff & "<br><BR>")
    Return 0
    EndIf
    Next
    Wend
    EndFunc ;==>_IsPressedMod

    [/autoit] [autoit][/autoit] [autoit]

    Func HexEscape($hexKey)
    Switch $hexKey
    Case 01
    $hexKey = "L-Maus"
    Case 02
    $hexKey = "R-Maus"
    ;.... Und so weiter: Was die jeweiligen Hexkeys bedeuten findeste in der hilfe unter _isPressed! ;]
    EndSwitch
    return $hexKey
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    DllClose($dll)
    Exit
    EndFunc

    [/autoit]
  • Zitat

    BOAH endgeil ^^ Danke Danke Danke danke !!! Das nenn ich mal Support ^^ Funktioniert einwandfrei !! Danke sehr =)

    the
    MrWong

    So sollte der erste Post aussehen, doch dann ist mir was aufgefallen xD Und zwar kann man noch irgendwie einbinden wann die keys wieder unpressed sind? Oder wäre das jetz zu viel des guten? Also beispielsweise so :

    [Taste irgendwas] down
    [Zeit "Taste irgendwas"]
    [Andere Taste] down
    [Zeit "Zeit Andere Taste"]
    [Andere Taste] up
    [Noch eine Taste] down
    [Zeit "Noch eine Taste"]
    [Taste irgendwas] up
    [Noch eine Taste] up

    Wäre das noch irgendwie machbar oder sprengt das denn Rahmen des Möglichen?

    3 Mal editiert, zuletzt von MrWong (21. März 2009 um 19:01)

  • Hui was willste denn so damit machen? soll einfach nur der fall vom drücken der shifttaste+irgendwas andres beachtet werden oda willste inbegrenzt viele tasten auf einmal drücken? =p hab schon ne idee wie ich das machen kann, setz mich aber erst später dran...

    MFG Chaoskeks

  • Ja also wie du schon sagtest mehrere Tasten gleichzeitig, wobei während Beispielsweise die 1.Taste gedrückte gehalten wird während Taste 2 und danach Taste 3 einmal gedrückt werden...

    the
    MrWong

  • puuh ist zwar nicht unbedingt die schönste Lösung aber sollte gehen.... habs erstmal für 3 Tasten gemacht, du kannst aber beliebig erweitern 8)

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $log = @UserName&"File.html"
    HotKeySet("{ESC}", "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    While 1
    For $i = 1 To 128
    If _isPressed(Hex($i, 2)) Then
    KeyBuffer1($i)
    EndIf
    Next
    Wend
    Wend

    [/autoit] [autoit][/autoit] [autoit]

    Func KeyBuffer1($i)
    $hexKey1 = Hex($i,2)
    $time1 = TimerInit()
    While _isPressed($hexKey1)
    For $j = 1 To 128
    If _isPressed(Hex($j, 2)) and $j <> $i Then
    KeyBuffer2($j)
    Endif
    Next
    Wend
    $diff1 = INT(Timerdiff($time1))
    $hexKey1 = HexEscape($hexKey1)
    ;~ Consolewrite($hexKey1 & " - " & $diff1 & @CRLF)
    FileWrite($log, $hexKey1 & " - " & $diff1 & "<br><BR>")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func KeyBuffer2($j)
    $hexKey2 = Hex($j,2)
    $time2 = TimerInit()
    While _isPressed(Hex($j,2))
    For $k = 1 To 128
    If _isPressed(Hex($k, 2)) and $k <> $j and $k <> $i Then
    KeyBuffer3($k)
    Endif
    Next
    Wend
    $diff2 = INT(Timerdiff($time2))
    $hexKey2 = HexEscape($hexKey2)
    ;~ Consolewrite($hexKey2 & " - " & $diff2 & @CRLF)
    FileWrite($log, $hexKey2 & " - " & $diff2 & "<br><BR>")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func KeyBuffer3($k)
    $hexKey3 = Hex($k,2)
    $time3 = TimerInit()
    While _isPressed(Hex($k,2))
    Wend
    $diff3 = INT(Timerdiff($time3))
    $hexKey3 = HexEscape($hexKey3)
    ;~ Consolewrite($hexKey3 & " - " & $diff3 & @CRLF)
    FileWrite($log, $hexKey3 & " - " & $diff3 & "<br><BR>")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;....Um die Funktion auf mehr Tasten auszuweiten einfach immer mehr Funktionen nach dem Muster erstellen^^

    [/autoit] [autoit][/autoit] [autoit]

    Func HexEscape($hexKey, $Type = 0)
    If $hexKey = '' Then Return -1
    Local $s_String = '01LeftMouse|02RightMouse|04MiddleMouse|05X1Mouse|06X2Mouse|08BACKSPACE|09TAB|0CCLEAR|' & _
    '0DENTER|10SHIFT|11CTRL|12ALT|13PAUSE|14CAPS LOCK|1BESC|20SPACEBAR|21PAGE UP|22PAGE DOWN|' & _
    '23END|24HOME|25LEFT|26UP|27RIGHT|28DOWN|29SELECT|2APRINT|2BEXECUTE|2CPRINT SCREEN|2DINS|2EDEL|' & _
    '300|311|322|333|344|355|366|377|388|399|41A|42B|43C|44D|45E|46F|47G|48H|49I|4AJ|4BK|4CL|4DM|4EN|' & _
    '4FO|50P|51Q|52R|53S|54T|55U|56V|57W|58X|59Y|5AZ|5BLeft Windows|5CRight Windows|60Num 0|61Num 1|' & _
    '62Num 2|63Num 3|64Num 4|65Num 5|66Num 6|67Num 7|68Num 8|69Num 9|6AMultiply|6BAdd|' & _
    '6CSeparator|6DSubtract|6EDecimal|6FDivide|70F1|71F2|72F3|73F4|74F5|75F6|76F7|77F8|78F9|' & _
    '79F10|7AF11|7BF12|7CF13|7DF14|7EF15|7FF16|80HF17|81HF18|82HF19|83HF20|84HF21|85HF22|' & _
    '86HF23|87HF24|90NUM LOCK|91SCROLL LOCK|A0Left SHIFT|A1Right SHIFT|A2Left CTRL|A3Right CTRL|' & _
    'A4Left MENU|A5Right Menu|BA;|BB=|BC,|BD-|BE.|BF/|C0`|DB[|DC\|DD]'

    [/autoit] [autoit][/autoit] [autoit]

    If $Type == 0 Then
    $hexKey = StringTrimLeft($s_String, (StringInStr($s_String, $hexKey) + StringLen($hexKey) - 1))
    $s_String = StringLeft($hexKey, (StringInStr($hexKey, '|') - 1))
    ElseIf $Type == 1 Then
    $hexKey = StringLeft($s_String, StringInStr($s_String, $hexKey) - 1)
    $s_String = StringTrimLeft($hexKey, StringInStr($hexKey, '|', 2, -1))
    EndIf
    If $s_String <> '' Then
    Return $s_String
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    Exit
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von ChaosKeks (22. März 2009 um 03:35)

  • DANKE SEHR =) Genau was ich gebraucht hab =) Respekt, also ich komm da jetzt nicht mehr mit, aber okay xD Also wirklich großes Lob und vielen vielen Dank ^^ Werde mir den Code noch genauer angucken müssen um ihn zu verstehen, aber mein Problem ist dank dir gelöst ! Danke sehr =)

    the
    MrWong