Loading ...
Sorry, an error occurred while loading the content.
 

If and while with IsKeyPressed

Expand Messages
  • j00j00633
    use Win32::GuiTest qw/:ALL/; use warnings; # use strict; $a = Loop got a call from test_run. n ; $b = Pause got a call from loop. n ; $c = Loop got a call
    Message 1 of 1 , Aug 22, 2003
      use Win32::GuiTest qw/:ALL/;
      use warnings;
      # use strict;

      $a = "Loop got a call from test_run.\n";
      $b = "Pause got a call from loop.\n";
      $c = "Loop got a call from pause.\n";

      sub test_run
      {
      if (IsKeyPressed("Z")) {
      while (IsKeyPressed("Z")) {
      }
      $timer = 1;
      print "Started and set timer to $timer\!\n";
      }
      if (IsKeyPressed("X") && ($timer == 1)) {
      while (IsKeyPressed("X") && ($timer == 1)) {
      }
      $timer = 2;
      print "Started and set timer to $timer\!\n";
      }
      $call = $a;
      &loop
      }

      sub loop
      {
      print $call;
      while (1) {
      if ($timer == 3) {
      last; }
      print "looping\n";
      sleep 3;

      if (IsKeyPressed("P")) {
      $timer = 3;
      $call = $b;
      &pause
      }
      }
      }




      sub pause
      {
      print $call;
      sleep 5;
      if (IsKeyPressed("P")) {
      while (IsKeyPressed("P")) {
      }
      $timer = 2;
      $call = $c;
      &loop;
      }
      }

      &test_run

      Why does it just fly by the if/while etc.. if I haven't pressed
      anything? it just goes through, prints everything and quits.

      Using ActivePerl Perl5.6 and GuiTest 1.50 on Win2k.
    Your message has been successfully submitted and would be delivered to recipients shortly.