metalx1000

Watch for mouse movement

Jul 7th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. to start powershell script:
  3. PowerShell -ExecutionPolicy Bypass .\mouse_pos.ps1
  4. #>
  5.  
  6. function watch_mouse(){
  7.     [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  8.     cls
  9.     $oX = 0
  10.  
  11.     while(1)
  12.     {
  13.     Start-Sleep -m 500    
  14.     $mY = ([System.Windows.Forms.Cursor]::Position.Y )#Mouse Y
  15.     $mX = ([System.Windows.Forms.Cursor]::Position.X )#Mouse X
  16.     Write-Host $mX,$mY    
  17.    
  18.         if(($oX -ne $mX) -and ($oX -ne 0))
  19.         {
  20.             Write-Host "Mouse Moved on X!"
  21.             break
  22.         }
  23.        
  24.         $oX = $mX
  25.        
  26.     }
  27. }
  28.  
  29. watch_mouse
Add Comment
Please, Sign In to add comment