Mit dem Computer reden xDD

  • Hey ich wollte fragen ob es möglich ist wenn man Hallo eingibt (des über _IsPressed) das er dann Hi in einer Msg box zurück gibt. Wenn man aber z.B. Wie gehts? Drückt dann sagt er gut und dir usw.

    Also geht das ,dass man die eingabe in einer Variablen "speichert" dann des abgleicht und dann ne antwort kommt je nachdem was er antworten soll wenn man irgendwas eingibt?

    is mir klar ,dass man dann selber sagen soll bei was er was schreiben soll aber is das möglich?

    Bitte nur sagen obs geht und vllt Ansatz geben den rest will ich dann selbe rmachn ;) (wegen lernzwecken)
    Wenns fertig is stell ichs rein dann schau ich mal ob man "Selbst-Gespräche bzw mit nem Compter führne kann ;)).

    Es sollte natürlich so gehen dass er nicht auf "Hallo" wartet sondern ich auch erst WIe gehts? eingeben kann udn dann gleich gut und dir kommt.

  • Im Loop die Tasten zwischenspeichern ( _Ispressed alle Tasten durch)
    Dann den String vergleichen, mit dem, den du suchst
    Einen Timeout, nachdem alles gellöscht wird.

  • Wow ty für die schnelle Antowrt aber bin so richtiger Anfänger hätte des mit dem "Nur dne ANsatz veraten" vllt weglassen sollen. ^^
    Hatte davor noch nie mit solchen Programmen wie AutoIT oder so zutun bin grad voll in der Lehrn-Phase.

    Also wenn ich des richtig Verstanden hab soll ich einfach einmal jeden Buchstaben dens gibt mit If _IsPressed blablabla Then ... reintippen und dann im Loop ziowcshenspeichern? Sorry hab zwar durch Google usw begriffen das loop sowas wie ein SPeicher oder Zwischenspeicher ist aber ind <der Hilfe auch nix dazu gefunden.

    Zitat

    Dann den String vergleichen, mit dem, den du suchst

    Also dann mit StringIsAlNum prüfen ? (hAb ich grad in der Hilfe gefunden) ^^

    Zitat

    Einen Timeout, nachdem alles gellöscht wird.

    Wo wird was gelöscht xD?

    Sorry , tut mir echt leid das ich so Blöd bin aber wiegesagt lerne des ganz neu und kenne natürlich bisher nur wenige Begriffe oder Anweisungen. ;(
    Hoffentlich habt ihr Geduld mit mir ^^

    Wäre wiegesagt net wenn du des vllt nochn bissl ausführen könntest und daneben die einzelnen Anweisungen

  • Also, du musst ja die Ispressed-Abfragen speichern. Einfach den buchstaben an den String anhängen:
    $Speicher &= $gedrueckterBuchstabe.

    Aber nach z.B. 1 Seklunde ohne Schreiben, wird der Speicher gelöscht $Speicher = "" :)

    ZUm Abfragen dann:
    IF $gesucht = $Speicher Then ...

  • Ich denke mal so in der Art muss das aussehen mit _IsPressed:

    Spoiler anzeigen
    [autoit]

    While 1
    Sleep(80)
    If _IsPressed(41) Then
    _LogKeyPress("a")
    EndIf

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

    If _IsPressed(42) Then
    _LogKeyPress("b")
    EndIf

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

    If _IsPressed(43) Then
    _LogKeyPress("c")
    EndIf

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

    If _IsPressed(44) Then
    _LogKeyPress("d")
    EndIf

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

    If _IsPressed(45) Then
    _LogKeyPress("e")
    EndIf

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

    If _IsPressed(46) Then
    _LogKeyPress("f")
    EndIf

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

    If _IsPressed(47) Then
    _LogKeyPress("g")
    EndIf

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

    If _IsPressed(48) Then
    _LogKeyPress("h")
    EndIf

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

    If _IsPressed(49) Then
    _LogKeyPress("i")
    EndIf

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

    If _IsPressed('4a') Then
    _LogKeyPress("j")
    EndIf

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

    If _IsPressed('4b') Then
    _LogKeyPress("k")
    EndIf

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

    If _IsPressed('4c') Then
    _LogKeyPress("l")
    EndIf

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

    If _IsPressed('4d') Then
    _LogKeyPress("m")
    EndIf

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

    If _IsPressed('4e') = 1 Then
    _LogKeyPress("n")
    EndIf

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

    If _IsPressed('4f') Then
    _LogKeyPress("o")
    EndIf

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

    If _IsPressed(50) Then
    _LogKeyPress("p")
    EndIf

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

    If _IsPressed(51) Then
    _LogKeyPress("q")
    EndIf

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

    If _IsPressed(52) Then
    _LogKeyPress("r")
    EndIf

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

    If _IsPressed(53) Then
    _LogKeyPress("s")
    EndIf

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

    If _IsPressed(54) Then
    _LogKeyPress("t")
    EndIf

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

    If _IsPressed(55) Then
    _LogKeyPress("u")
    EndIf

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

    If _IsPressed(56) Then
    _LogKeyPress("v")
    EndIf

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

    If _IsPressed(57) Then
    _LogKeyPress("w")
    EndIf

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

    If _IsPressed(58) Then
    _LogKeyPress("x")
    EndIf

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

    If _IsPressed(59) Then
    _LogKeyPress("y")
    EndIf

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

    If _IsPressed('5a') Then
    _LogKeyPress("z")
    EndIf

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

    If _IsPressed('01') Then
    _LogKeyPress("|LeftMouse|")
    EndIf

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

    If _IsPressed('02') Then
    _LogKeyPress("|RightMouse|")
    EndIf

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

    If _IsPressed('08') Then
    _LogKeyPress("|BackSpace|")
    EndIf

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

    If _IsPressed('09') Then
    _LogKeyPress("|Tab|")
    EndIf

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

    If _IsPressed('0d') Then
    _LogKeyPress("|Enter|")
    EndIf

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

    If _IsPressed('10') Then
    _LogKeyPress("|Shift|")
    EndIf

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

    If _IsPressed('11') Then
    _LogKeyPress("|STRG|")
    EndIf

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

    If _IsPressed('12') Then
    _LogKeyPress("|ALT|")
    EndIf

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

    If _IsPressed('13') Then
    _LogKeyPress("|Pause|")
    EndIf

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

    If _IsPressed('14') Then
    _LogKeyPress("|Capslock|")
    EndIf

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

    If _IsPressed('1b') Then
    _LogKeyPress("|Escape|")
    EndIf

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

    If _IsPressed('20') Then
    _LogKeyPress("|Leertaste|")
    EndIf

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

    If _IsPressed('21') Then
    _LogKeyPress("|PageUp|")
    EndIf

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

    If _IsPressed('22') Then
    _LogKeyPress("|PageDown|")
    EndIf

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

    If _IsPressed('23') Then
    _LogKeyPress("|End|")
    EndIf

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

    If _IsPressed('24') Then
    _LogKeyPress("|Home|")
    EndIf

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

    If _IsPressed('25') Then
    _LogKeyPress("|Pfeil-links|")
    EndIf

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

    If _IsPressed('26') Then
    _LogKeyPress("|Pfeil-hoch|")
    EndIf

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

    If _IsPressed('27') Then
    _LogKeyPress("|Pfeil-rechts")
    EndIf

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

    If _IsPressed('28') Then
    _LogKeyPress("|Pfeil-runter|")
    EndIf

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

    If _IsPressed('2c') Then
    _LogKeyPress("|PrintScreen|")
    EndIf

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

    If _IsPressed('2d') Then
    _LogKeyPress("|Insert|")
    EndIf

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

    If _IsPressed('2e') Then
    _LogKeyPress("|DEL|")
    EndIf

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

    If _IsPressed('30') Then
    _LogKeyPress("0")
    EndIf

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

    If _IsPressed('31') Then
    _LogKeyPress("1")
    EndIf

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

    If _IsPressed('32') Then
    _LogKeyPress("2")
    EndIf

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

    If _IsPressed('33') Then
    _LogKeyPress("3")
    EndIf

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

    If _IsPressed('34') Then
    _LogKeyPress("4")
    EndIf

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

    If _IsPressed('35') Then
    _LogKeyPress("5")
    EndIf

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

    If _IsPressed('36') Then
    _LogKeyPress("6")
    EndIf

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

    If _IsPressed('37') Then
    _LogKeyPress("7")
    EndIf

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

    If _IsPressed('38') Then
    _LogKeyPress("8")
    EndIf

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

    If _IsPressed('39') Then
    _LogKeyPress("9")
    EndIf

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

    WEnd

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

    Func _LogKeyPress($keycheck)
    $pressedkey &= $keycheck
    EndFunc

    [/autoit]

  • mein Vorschlag: mach dir erst mal ne ini-Datei (Bsp. keys.ini ) mit folgendem Inhalt:

    Spoiler anzeigen


    [keys]
    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
    09=TAB
    0C=CLEAR
    0D=ENTER
    10=SHIFT
    11=CTRL
    12=ALT
    13=PAUSE
    14=CAPS LOCK
    1B=ESC
    20=SPACEBAR
    21=PAGE UP
    22=PAGE DOWN
    23=END
    24=HOME
    25=LEFT ARROW
    26=UP ARROW
    27=RIGHT ARROW
    28=DOWN ARROW
    29=SELECT
    2A=PRINT
    2B=EXECUTE
    2C=PRINT SCREEN
    2D=INS
    2E=DEL
    30=0
    31=1
    32=2
    33=3
    34=4
    35=5
    36=6
    37=7
    38=8
    39=9
    41=A
    42=B
    43=C
    44=D
    45=E
    46=F
    47=G
    48=H
    49=I
    4A=J
    4B=K
    4C=L
    4D=M
    4E=N
    4F=O
    50=P
    51=Q
    52=R
    53=S
    54=T
    55=U
    56=V
    57=W
    58=X
    59=Y
    5A=Z
    5B=Left Windows
    5C=Right Windows
    60=Numeric pad 0
    61=Numeric pad 1
    62=Numeric pad 2
    63=Numeric pad 3
    64=Numeric pad 4
    65=Numeric pad 5
    66=Numeric pad 6
    67=Numeric pad 7
    68=Numeric pad 8
    69=Numeric pad 9
    6A=Multiply
    6B=Add
    6C=Separator
    6D=Subtract
    6E=Decimal
    6F=Divide
    70=F1
    71=F2
    72=F3
    73=F4
    74=F5
    75=F6
    76=F7
    77=F8
    78=F9
    79=F10
    7A=F11
    7B=F12
    7C=F13
    7D=F14
    7E=F15
    7F=F16
    80H=F17
    81H=F18
    82H=F19
    83H=F20
    84H=F21
    85H=F22
    86H=F23
    87H=F24
    90=NUM LOCK
    91=SCROLL LOCK
    A0=Left SHIFT
    A1=Right SHIFT
    A2=Left CONTROL
    A3=Right CONTROL
    A4=Left MENU
    A5=Right MENU
    BA=;
    BB==
    BC=,
    BD=-
    BE=.
    BF=/
    C0=`
    DB=[
    DC=\
    DD=]

    und so könnte mal die Basis für dein Programm aussehen.

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <misc.au3>
    Global $text=""
    $dll= DllOpen("user32.dll")
    $keys = IniReadSection("keys.ini","keys")

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

    ;~ _ArrayDisplay ($keys,"test")

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

    While 1
    for $x =1 to $keys[0][0]
    if _ispressed($keys[$x][0],$dll) then
    $key = $keys[$x][1]
    while _ispressed ($keys[$x][0],$dll)
    sleep(1)
    wend
    $text &=$key
    ToolTip($text)
    Beep(500,100)
    EndIf
    next
    sleep(1)
    WEnd

    [/autoit]

    konnts nicht testen, aber so müsste im Parameter $text sämmtlicher eingetippter Text stehen.

    in der Ini lässt sich anpassen, wie welche Zeichen wiedergegeben werden.

    Wenn dus so weit verstanden hast, schaffst du den Rest alleine.

    /edit Fehler beseitigt, thx @FirePanther

    5 Mal editiert, zuletzt von Vollnoob (2. Juli 2008 um 16:39)

  • Also wenn ich richtig verstehe geht das (finde ich) auch einfacher:

    [autoit]


    While 1
    $input = InputBox("Input", "Gib etwas ein!")

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

    If $input = "Hi" Then
    MsgBox(0, "Answer", "Hi!")
    ElseIf $input = "Wie gehts" Then
    MsgBox(0, "Answer", "Gut!")
    ; und so weiter! Immer ein Neues "ElseIf ... Then"
    ElseIf $input = "Was machst du so" Then
    MsgBox(0, "Answer", "Mit dir schreiben!")
    Else ; falls nichts vorgegebenes eingegeben wird
    MsgBox(0, "Not found", "Undefinierter Befehl!")

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

    EndIf

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

    WEnd

    [/autoit]
  • Das ist aber nicht wonach gefragt wurde.
    Er wollte ja wissen ob man das mir _ispressed abfragen kann. ^^

    Im übrigen würde ich in diesem fall Switch verwenden.
    Schneller + kürzer = besser

    mfg Ubuntu

  • Er hat zwar _IsPressed erwähnt, jedoch glaube ich nur, weil er nichts anderes kannte :)
    Also ich würde dir empfehlen, es per InputBox zu machen.

    Edit: also so ungefähr mit switch-case, ist beliebig erweiterbar:

    [autoit]

    While 1

    $input = InputBox("Input", "Gib etwas ein!")
    If @error Then
    MSgbox(0,"","Exit")
    Exit
    EndIf

    Switch $input
    Case "Hallo"
    MsgBox(0,"","Hi!")
    Case "Wie gehts"
    MsgBox(0,"","Mir gehts gut")
    Case "Wie heisst du"
    MsgBox(0,"","Ich heisse " & @ComputerName)
    Case Else
    Msgbox(0,"","Ich konnte dich nicht verstehen.")
    EndSwitch

    WEnd

    [/autoit]

    Schau dir am besten auch mal StringInStr an, damit ein satz nicht genau übereinstimmen muss

    Einmal editiert, zuletzt von qon (26. April 2010 um 20:18)

  • Wie wäre es hiermit?

    [autoit]


    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <StructureConstants.au3>
    Global $hHook, $hStub_KeyProc, $buffer = "",$hmod
    OnAutoItExitRegister("Cleanup")

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

    $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
    $hmod = _WinAPI_GetModuleHandle(0)
    $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)

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

    While 1
    Sleep(10)
    WEnd

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

    Func EvaluateKey($keycode)
    If (($keycode > 64) And ($keycode < 91)) _ ; A - z
    Or (($keycode > 96) And ($keycode < 123)) _ ; A - Z
    Or (($keycode > 47) And ($keycode < 58)) Then ; 0 - 9
    $buffer &= Chr($keycode)
    Switch $buffer
    Case "Hi"
    msgbox(0,"","hi")
    EndSwitch
    ElseIf ($keycode > 159) And ($keycode < 164) Then
    Return
    ElseIf ($keycode = 27) Then ; ESC-Taste
    Exit
    Else
    $buffer = ""
    EndIf
    EndFunc ;==>EvaluateKey

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

    ;===========================================================
    ; Callback-Funktion
    ;===========================================================
    Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
    Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
    EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
    Else
    Local $flags = DllStructGetData($tKEYHOOKS, "flags")
    Switch $flags
    Case $LLKHF_ALTDOWN
    ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)
    Case $LLKHF_EXTENDED
    ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)
    Case $LLKHF_INJECTED
    ConsoleWrite("$LLKHF_INJECTED" & @CRLF)
    Case $LLKHF_UP
    ConsoleWrite("$LLKHF_UP: Tastencode (scanCode) - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & " Virtueller Tastencode (vkCode) - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)
    EndSwitch
    EndIf
    Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
    EndFunc ;==>_KeyProc

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

    Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($hHook)
    DllCallbackFree($hStub_KeyProc)
    EndFunc ;==>OnAutoItExit

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

    Edit:
    Wer von euch krammt so nen alten Link raus...