Skip to content

Instantly share code, notes, and snippets.

@pbosetti
Created September 29, 2011 10:12
Show Gist options
  • Save pbosetti/1250443 to your computer and use it in GitHub Desktop.
Save pbosetti/1250443 to your computer and use it in GitHub Desktop.
Mouse clicks automation
#!/usr/bin/env ruby
require 'ffi'
module Mouse
extend FFI::Library
ffi_lib '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics'
class CGPoint < FFI::Struct
layout :x, :double, :y, :double
end
attach_function :CGPostMouseEvent, [ CGPoint, :bool, :int, :bool ], :void
end
point = Mouse::CGPoint.new
point[:x] = 100
point[:y] = 100
Mouse::CGPostMouseEvent(point, true, 1, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment