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

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

Replies are listed 'Best First'.
Re^5: Mouse Position in Desktop
by Anonymous Monk on Dec 28, 2010 at 01:12 UTC
    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