Innerhalb einer Schleife, Tasten abfragen Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Innerhalb einer Schleife, Tasten abfragen

13 Apr 2019, 11:48

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
}
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Innerhalb einer Schleife, Tasten abfragen  Topic is solved

13 Apr 2019, 12:07

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.
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Innerhalb einer Schleife, Tasten abfragen

13 Apr 2019, 16:47

Danke dir, hat wunderbar funktioniert.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 42 guests