in reply to Re^2: Mouse Position in Desktop
in thread Mouse Position in Desktop

You need to yield to other processes by sleeping some amount of time each loop. Time::HiRes's version of sleep will help here.

Replies are listed 'Best First'.
Re^4: Mouse Position in Desktop
by GrandFather (Saint) on Dec 28, 2010 at 00:13 UTC

    Why? Windows is a pre-emptive multi-tasking operating system and mouse handling is essentially independent of applications. Inserting sleeps will not speed anything up and there is no need for a yield as the OS already asynchronously handles mouse position.

    True laziness is hard work
      That's fine if you don't expect the process to be able to print anything to a window.

        You still don't make sense. Have you tried the OP's code? It works fine for me and (with a small tweak for counting) gives about 15,500 updates per second (not sure why the OP found that too slow actually).

        use strict; use warnings; use Win32::GuiTest; my $start = time; my $times; 1 while time - 1 < $start; while (time - 6 < $start) { my ($x, $y) = Win32::GuiTest::GetCursorPos(); print "X is at $x, Y is at $y\n"; ++$times; } print +($times / 5), "\n";
        True laziness is hard work