Sha256: c4a5d5b767a746a65eeb7d9d0609cdc42ec4dabaf7fda4d875c581ccc8f32945

Contents?: true

Size: 894 Bytes

Versions: 21

Compression:

Stored size: 894 Bytes

Contents

module RAutomation
  module Adapter
    module Autoit
      class Mouse
        def initialize(window)
          @window = window
          @autoit = window.class.autoit
        end

        def move(coords={})
          @last_position = coords = (@last_position || position).merge(coords)

          until position[:x] == coords[:x] && position[:y] == coords[:y]
            @window.activate
            @autoit.MouseMove(coords[:x], coords[:y])
          end
        end

        def position
          {:x => @autoit.MouseGetPosX, :y => @autoit.MouseGetPosY}
        end

        def click(button = "left")
          @autoit.MouseClick(button)
        end

        def press(button = "left")
          @autoit.MouseDown(button)
        end

        def release(button = "left")
          @autoit.MouseUp(button)
        end

      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rautomation-0.7.2 lib/rautomation/adapter/autoit/mouse.rb