Page 1 of 1

Innerhalb einer Schleife, Tasten abfragen

Posted: 13 Apr 2019, 11:48
by KHA
Hallo,
wie kann ich innerhalb einer schleife tasten abfragen?
in meinem Beispiel, habe eine Liste bestehend aus Obst und Farben.
Wenn ich die Linke Taste drücke, soll es in datei obst.txt gespeichert werden und wenn ich die rechte taste drücke dann in Datei Farbe.txt
LG

Code: Select all

mydat=
(join`r`n
Gelb
Banane
Grün
Apfel
Kiwi
Grün
)

Loop, parse, mydat, `n
{
msgbox, % A_LoopField
Left::
;If GetKeyState("Left", "P")
FileAppend, %A_LoopField%, Obst.txt
return

right::
;If GetKeyState("Right", "P")
FileAppend, %A_LoopField%, Farbe.txt
return
}

Re: Innerhalb einer Schleife, Tasten abfragen  Topic is solved

Posted: 13 Apr 2019, 12:07
by wolf_II
Versuch mal:

Code: Select all

mydat=
(join`r`n
Gelb
Banane
Grün
Apfel
Kiwi
Grün
)

Loop, parse, mydat, `n
{
    msgbox, 36,, % A_LoopField

    IfMsgBox, Yes
        FileAppend, %A_LoopField%, Obst.txt

    else
        FileAppend, %A_LoopField%, Farbe.txt
}


Left:: ControlSend, , Y, ahk_class #32770
right:: ControlSend, , N, ahk_class #32770
Ich hoffe das hilft.

Re: Innerhalb einer Schleife, Tasten abfragen

Posted: 13 Apr 2019, 16:47
by KHA
Danke dir, hat wunderbar funktioniert.