Wenn A, dann B

  • HILFE!!!
    Bin jetzt seit 2 Stunden am Verzweifeln, aber ich will nicht aufgeben!

    Das was ich brauche ist eigentl. ganz leicht, glaube ich jedenfalls :)

    Mein Script soll bei einmaligen Druck auf F2 den Text (@mustermann.de) schreiben.

    [autoit]

    global $play=0
    hotkeyset("{F2}","starten")

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

    While 1
    if $play then
    send ("a")
    endif
    Wend

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

    func starten()
    $play=1
    endfunc

    [/autoit]

    Ich hab jetzt schon 5 verschiedene Themengebiete aufgegriffen, aber iwie hilft mir nix!

    Hoffe jemand kann mir schnell die Lösung für das Problem posten, sonst spring ich gleich noch aus dem Fenster :thumbup:

    Lg Alex

    Einmal editiert, zuletzt von packjack (19. Juli 2010 um 14:46)

  • Hey wie wär es wenn dus mal mit

    While _IsPressed(Hexkey) = False
    sleep(100)
    Wend

    send("Text")

    oder ne if abfrage

    If _IsPressed(Hexkey) Then
    Endif/Else

  • [autoit]

    hotkeyset("{F2}","starten")

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

    While 1

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

    Wend

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

    func starten()
    send ("@mustermann.de")
    HotKeySet("{F2}")
    endfunc

    [/autoit]
  • ach und falls du -IsPressed benutzt musst du noch ein #include <Misc.au3> setzen (oben am anfang des Scripts)

    Hier noch die Tabelle mit den Hexkeys

    If calling this function repeatidly, should open 'user32.dll' and pass in
    handle.
    Make sure to close at end of script
    01 Left mouse button
    02
    Right mouse button
    04 Middle mouse button (three-button mouse)
    05 Windows
    2000/XP: X1 mouse button
    06 Windows 2000/XP: X2 mouse button
    08 BACKSPACE
    key
    09 TAB key
    0C CLEAR key
    0D ENTER key
    10 SHIFT key
    11 CTRL
    key
    12 ALT key
    13 PAUSE key
    14 CAPS LOCK key
    1B ESC key
    20
    SPACEBAR
    21 PAGE UP key
    22 PAGE DOWN key
    23 END key
    24 HOME
    key
    25 LEFT ARROW key
    26 UP ARROW key
    27 RIGHT ARROW key
    28 DOWN
    ARROW key
    29 SELECT key
    2A PRINT key
    2B EXECUTE key
    2C PRINT SCREEN
    key
    2D INS key
    2E DEL key
    30 0 key
    31 1 key
    32 2 key
    33 3
    key
    34 4 key
    35 5 key
    36 6 key
    37 7 key
    38 8 key
    39 9
    key
    41 A key
    42 B key
    43 C key
    44 D key
    45 E key
    46 F
    key
    47 G key
    48 H key
    49 I key
    4A J key
    4B K key
    4C L
    key
    4D M key
    4E N key
    4F O key
    50 P key
    51 Q key
    52 R
    key
    53 S key
    54 T key
    55 U key
    56 V key
    57 W key
    58 X
    key
    59 Y key
    5A Z key
    5B Left Windows key
    5C Right Windows key
    60
    Numeric keypad 0 key
    61 Numeric keypad 1 key
    62 Numeric keypad 2 key
    63
    Numeric keypad 3 key
    64 Numeric keypad 4 key
    65 Numeric keypad 5 key
    66
    Numeric keypad 6 key
    67 Numeric keypad 7 key
    68 Numeric keypad 8 key
    69
    Numeric keypad 9 key
    6A Multiply key
    6B Add key
    6C Separator key
    6D
    Subtract key
    6E Decimal key
    6F Divide key
    70 F1 key
    71 F2 key
    72
    F3 key
    73 F4 key
    74 F5 key
    75 F6 key
    76 F7 key
    77 F8 key
    78 F9
    key
    79 F10 key
    7A F11 key
    7B F12 key
    7C-7F F13 key - F16
    key
    80H-87H F17 key - F24 key
    90 NUM LOCK key
    91 SCROLL LOCK key
    A0
    Left SHIFT key
    A1 Right SHIFT key
    A2 Left CONTROL key
    A3 Right CONTROL
    key
    A4 Left MENU key
    A5 Right MENU key
    BA ;
    BB =
    BC ,
    BD
    -
    BE .
    BF /
    C0 `
    DB [
    DC \
    DD ]

  • Ohne Sleep wird das (vermeindlich) gewünschte Ergebnis sicherlich nicht erreicht:

    Spoiler anzeigen
    [autoit]

    $play = False
    $name = "@mustermann.de"
    $Zeilenumbruch = @CRLF
    HotKeySet("{Esc}","beenden")
    HotKeySet("{F2}","starten")

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

    While 1
    If $play Then
    Send($name)
    Send($Zeilenumbruch)
    EndIf
    Sleep(1000); pausiert um ggf. unangenehmen effekt zu vermeiden
    WEnd

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

    Func beenden()
    Exit;beendet das script
    EndFunc

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

    Func starten()
    $play = Not $play; aktiviert bzw. deaktiviert das senden
    ;true wird false und false wird true
    EndFunc

    [/autoit]

    Wer immer nur das tut, was er bereits kann - wird auch immer nur das bleiben, was er bereits ist!

  • Warum so kompliziert???

    Ganz einfach

    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>

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

    $Text = @mustermann.de
    While 1
    If _IsPressed(71) ;71 für F2
    Send($Text)
    Else
    ...
    EndIf
    Sleep(500)
    Wend

    [/autoit]
  • [autoit]


    ;Die Lösung ist, mach nicht If $Play Then, sondern If $Play = 1 Then

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

    If $Play = 1 Then
    Send ("@maxmustermann")
    EndIf

    [/autoit]

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal

  • Danke an all die schnellen Antworten!

    Ich habe aber immernoch das gleiche Problem, wie bei meinen Scripten.

    Wenn ich F2 drücke, dann bekomme ich @mustermann.de@mustermann.de@mustermann.de@mustermann.de@mustermann.de@mustermann.de@mustermann.de@mustermann.de. Okay bei manchen Scripten auch mit Verzögerung, aber das hilft mir nicht!

    Wie kann ich denn einstellen, dass wenn ich "einmal" F2 drücke, der Computer auch nur "einmal" @mustermann.de schreibt. Aber das Script soll sich nicht nach einmaligen Drücken beenden, sondern bei jedem Drücken von F2, @mustermann.de ausspucken.

    Danke

  • wie gesagt

    [autoit]

    hotkeyset("{F2}","starten")

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

    func starten()
    send("@mustermann.de")
    endfunc

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

    while 1
    sleep(199)
    Wend

    [/autoit]
  • setze einfach bei meinem Script das sleep(500) in sleep 1000 oder höher (1000= 1sec)

    #include <Misc.au3>

    $Text = "@mustermann.de"
    While 1
    If _IsPressed(71) Then;71 für F2
    Send($Text)
    EndIf
    Sleep(500)
    Wend

    Funktioniert habs getestet

  • Vielen Dank an Kev!

    Funktioniert einwandfrei! Hatte dein Script auch schon beim ersten Mal probiert, allerdings hatte ich wohl nicht alle Zeilen eines anderen Scriptes gelöscht.

  • Kann es sein dass du in der if schleife im startpost auch keine bedingung gesetzt hast, denn da steht nur

    Spoiler anzeigen
    [autoit]


    if $play then
    send("a")
    endif

    [/autoit]

    eigentlich muss es doch heißen

    Spoiler anzeigen
    [autoit]


    if $play = 1 then
    send("a")
    endif

    [/autoit]
  • @mazZ:
    Nein, das ist schon okey.
    Alle Werte außer "" und 0 werden als TRUE interpretiert. Diese Schreibweise ist deswegen vollkommen okey.

    Guckstu hier
    [autoit]

    $iVar = ""
    If $iVar Then MsgBox(0, "", '$iVar = ""')

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

    $iVar = 1
    If $iVar Then MsgBox(0, "", "$iVar = 1")

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

    $iVar = -1
    If $iVar Then MsgBox(0, "", "$iVar = -1")

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

    $iVar = 0
    If $iVar Then MsgBox(0, "", "$iVar = 0")

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

    $iVar = "Hallo!"
    If $iVar Then MsgBox(0, "", '$iVar = "Hallo!"')

    [/autoit]

    LG ;)