Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Keep the playback rolling (Win32)

by Anonymous Monk
on Mar 10, 2009 at 16:42 UTC ( #749646=note: print w/replies, xml ) Need Help??


in reply to Keep the playback rolling (Win32)

The code sometimes does not work it exits becuase "y" some times will not be equal to "y1". I dont understand why this is happening. To verify I just printed out the x, x1, y and y1 before the "exit". After couple of iterations it exits and it prints as follows. x=190, y=72, x1=190, y1=72 x=200, y=82, x1=200, y1=81 I observed that Always y1 is less than 1.

Replies are listed 'Best First'.
Re^2: Keep the playback rolling (Win32) (jiggle)
by tye (Sage) on Mar 10, 2009 at 16:56 UTC

    It might be because your optical mouse decided to jiggle the pointer one pixel? You could certainly add a tolerance for how much the mouse pointer needs to move to terminate it or remove that check entirely and just Ctrl-C the script when you want it to stop. This sensitive test is fine for my particular use case. Note that it also fails if the mouse pointer is too close to the wrong screen edge.

    This pl2bat-wrapped version avoids both such problems:

    @rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S %0 %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!perl -w #line 15 use strict; use Win32::GuiTest qw< GetCursorPos MouseMoveAbsPix >; sleep 5; my( $x, $y )= GetCursorPos(); my @dx= ( 10, -10, -10, 10 ); my @dy= ( 10, 10, -10, -10 ); while( 1 ) { sleep 1; my( $x1, $y1 )= GetCursorPos(); exit if( 10 < abs( $x - $x1 ) || 10 < abs( $y - $y1 ) ); $x += $dx[0]; push @dx, shift @dx; $y += $dy[0]; push @dy, shift @dy; MouseMoveAbsPix( $x, $y ); } __END__ :endofperl

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://749646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2019-12-10 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?