use Win32::GuiTest qw/SendKeys IsKeyPressed/; my @keys = qw/1 2 3 x y z ESC/; my $logfile = "logfile_eingaben.txt"; open LOGFILE, ">> $logfile"; #until (IsKeyPressed("1")&&("2")) { until (IsKeyPressed("ESC")) {    for (@keys) {        if (IsKeyPressed($_)) {            print LOG "$_ wurde gedrückt\n";            SendKeys "{PAUSE 1}";        }        elsif (IsKeyPressed("Strg")) { print LOG " $_ gedrückt\n"; SendKeys "{PAUSE 1}"; } else {           SendKeys "{PAUSE 1}";        }    } } close LOGFILE;