ich kapier das einfach nicht

  • hallo, ich komme einfach nicht auf diesen fehler!
    es könnte natürlich auch ein bug von Autoit sein.

    beim drücken von der taste "f" soll nur eine variable geändert werden.
    so das script mit Hotkey geht so wie es soll.

    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>

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

    $fixieren = 4

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

    HotKeySet("f", "_fixieren")

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

    $dll = DllOpen("user32.dll")

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

    While 1
    Sleep(1)
    ;If _IsPressed("46", $dll) Then
    ; _fixieren()
    ;EndIf
    WEnd

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

    DllClose($dll)

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

    Func _fixieren()

    BlockInput(1)

    If $fixieren = 4 Then

    $fixieren = 2

    TrayTip("Info", "4 to " & $fixieren, 5)
    Sleep(500)

    Else
    $fixieren = 4

    TrayTip("Info", "2 to " & $fixieren, 5)
    Sleep(500)

    EndIf

    BlockInput(0)

    EndFunc ;==>_fixieren

    [/autoit]

    das script jetzt, mit _IsPressed, geht nach drücken von "f" in eine endlos schleife, nur warum???
    auch wenn man es mal schliessen kann und es dann neustartet, geht es sofort wieder in die endlos schleife!

    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>

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

    $fixieren = 4

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

    ;HotKeySet("f", "_fixieren")

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

    $dll = DllOpen("user32.dll")

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

    While 1
    Sleep(1)
    If _IsPressed("46", $dll) Then
    _fixieren()
    EndIf
    WEnd

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

    DllClose($dll)

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

    Func _fixieren()

    BlockInput(1)

    If $fixieren = 4 Then

    $fixieren = 2

    TrayTip("Info", "4 to " & $fixieren, 5)
    Sleep(500)

    Else
    $fixieren = 4

    TrayTip("Info", "2 to " & $fixieren, 5)
    Sleep(500)

    EndIf

    BlockInput(0)

    EndFunc ;==>_fixieren

    [/autoit]

    wenn ich aber dann den "BlockInput" deaktiviere geht das script mit _IsPressed auch :(
    aber warum nicht mit "BlockInput" ???


    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>

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

    $fixieren = 4

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

    ;HotKeySet("f", "_fixieren")

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

    $dll = DllOpen("user32.dll")

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

    While 1
    Sleep(1)
    If _IsPressed("46", $dll) Then
    _fixieren()
    EndIf
    WEnd

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

    DllClose($dll)

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

    Func _fixieren()

    ;BlockInput(1)

    If $fixieren = 4 Then

    $fixieren = 2

    TrayTip("Info", "4 to " & $fixieren, 5)
    Sleep(500)

    Else
    $fixieren = 4

    TrayTip("Info", "2 to " & $fixieren, 5)
    Sleep(500)

    EndIf

    ;BlockInput(0)

    EndFunc ;==>_fixieren

    [/autoit]

    Doktore

  • Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

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

    $fixieren = 4

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

    ;HotKeySet("f", "_fixieren")

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

    $dll = DllOpen("user32.dll")

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

    While 1
    Sleep(1)
    If _IsPressed("46", $dll) Then
    _fixieren()
    While _IsPressed("46", $dll)
    Sleep(10)
    Wend
    EndIf
    WEnd

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

    DllClose($dll)

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

    Func _fixieren()

    ;BlockInput(1)

    If $fixieren = 4 Then

    $fixieren = 2

    TrayTip("Info", "4 to " & $fixieren, 5)
    Sleep(500)

    Else
    $fixieren = 4

    TrayTip("Info", "2 to " & $fixieren, 5)
    Sleep(500)

    EndIf

    ;BlockInput(0)

    EndFunc ;==>_fixieren

    [/autoit]

    Eventuell hilft das weil er sonst solange du die Taste gedrückt hälst die funktion immer wieder aufruft.

    • Offizieller Beitrag

    Ich weiß, es wird dir kein Trost sein - aber auf meinem Rechner funktioniert keine deiner Varianten. ?(
    Dann hab ich's mal am Laptop probiert. Hier funktionierte die Version _IsPressed mit BlockInput() teilweise. Also Endlosschleife mit ständigem Wechsel zwischen den TrayTip's ( 4 to 2 ; 2 to 4 ; 4 to 2 ...).
    Im Moment kA warum.

    EDIT:
    Versuchs mal so:

    [autoit]

    While 1
    While _IsPressed("46") = 0 ; Warten auf "F" gedrückt
    Sleep(150)
    WEnd
    _fixieren()
    WEnd

    [/autoit]

    Kann es bei mir nicht testen - mein PC läßt kein TrayTip zu (wieso auch immer).

    EDIT 2:
    Hab jetzt noch mal am Laptop getestet und komme auch zu dem Schluß: Es ist ein Bug.
    MIt BlockInput wirds eine Endlosschleife. Das ist echt nicht erklärbar.
    Meine letzte getestete Variante war diese:

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

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

    $fixieren = 4
    ;HotKeySet("f", "_fixieren")

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

    While 1
    While _IsPressed("46") = 0 ; Warten auf "F" gedrückt
    Sleep(150)
    WEnd
    _fixieren()
    WEnd

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

    Func _fixieren()
    ;~ BlockInput(1)
    Switch $fixieren
    Case 4
    $fixieren = 2
    TrayTip("Info", "4 to " & $fixieren, 5, 1)
    Sleep(1500)
    TrayTip("","",1)
    Case 2
    $fixieren = 4
    TrayTip("Info", "2 to " & $fixieren, 5, 1)
    Sleep(1500)
    TrayTip("","",1)
    EndSwitch
    ;~ BlockInput(0)
    EndFunc ;==>_fixieren

    [/autoit]


    Wobei ich nicht verstehe, wozu das BlockInput dienen soll. So, wie ich es jetzt gemacht habe, kann eine Eingabe von "F" erst wieder geprüft werden, wenn die Funktion _fixieren beendet ist. Ein Doppelaufruf ist also ausgeschlossen (ich glaube, das war dein Hintergedanke dabei).

    • Offizieller Beitrag

    Hallo,

    die Funktion von Daniel funktioniert beim mir am besten, allerdings muss ich die Sleep's in _fixieren() deaktivieren wenn ich Blockinput aktiviere sonst wird nur jeder 2. Tastendruck ausgeführt!