Sha256: 5e069f2dc92fc39259f4c5cfc963280b47c18e3de5488a81cb2e83ae32a86414

Contents?: true

Size: 1.35 KB

Versions: 18

Compression:

Stored size: 1.35 KB

Contents

require 'rubygems'
require 'ffi'

module Mouse
  extend FFI::Library

  ffi_lib 'user32'
  ffi_convention :stdcall
  
  MOUSEEVENTF_MOVE = 1
  INPUT_MOUSE = 0
  MOUSEEVENTF_ABSOLUTE = 0x8000
  
  class MouseInput < FFI::Struct
    layout :dx, :long,
           :dy, :long,
           :mouse_data, :ulong,
           :flags, :ulong,
           :time, :ulong,
           :extra, :ulong
  end
  class InputEvent < FFI::Union
    layout :mi, MouseInput
  end 
  class Input < FFI::Struct
    layout :type, :ulong,
           :evt, InputEvent
  end
  
  # UINT SendInput(UINT nInputs, LPINPUT pInputs, int cbSize);
  attach_function :SendInput, [ :uint, :pointer, :int ], :uint
  
  def self.jitter_forever_in_own_thread
    
    myinput = Mouse::Input.new
    myinput[:type] = Mouse::INPUT_MOUSE

    in_evt = myinput[:evt][:mi]

    in_evt[:mouse_data] = 0
    in_evt[:flags] = Mouse::MOUSEEVENTF_MOVE # | Mouse::MOUSEEVENTF_ABSOLUTE
    in_evt[:time] = 0
    in_evt[:extra] = 0
    in_evt[:dx] = 0
    in_evt[:dy] = 8 # just enough for VLC full screen...

    Thread.new {
      loop {
        in_evt[:dy] *= -1
        Mouse.SendInput(1, myinput, Mouse::Input.size)
        in_evt[:dy] *= -1
        sleep 0.05
        Mouse.SendInput(1, myinput, Mouse::Input.size)
        sleep 0.75
      }
    }
    
  end
    
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sensible-cinema-0.13.1 lib/mouse.rb
sensible-cinema-0.13.0 lib/mouse.rb
sensible-cinema-0.12.0 lib/mouse.rb
sensible-cinema-0.11.0 lib/mouse.rb
sensible-cinema-0.10.2 lib/mouse.rb
sensible-cinema-0.10.1 lib/mouse.rb
sensible-cinema-0.9.7 lib/mouse.rb
sensible-cinema-0.9.4 lib/mouse.rb
sensible-cinema-0.9.3 lib/mouse.rb
sensible-cinema-0.7.7 lib/mouse.rb
sensible-cinema-0.7.5 lib/mouse.rb
sensible-cinema-0.7.4 lib/mouse.rb
sensible-cinema-0.7.3 lib/mouse.rb
sensible-cinema-0.7.2 lib/mouse.rb
sensible-cinema-0.7.1 lib/mouse.rb
sensible-cinema-0.7.0 lib/mouse.rb
sensible-cinema-0.6.1 lib/mouse.rb
sensible-cinema-0.6.0 lib/mouse.rb