Sha256: c450aad982e6221e6d3ca9a8e9ea2b74890c12ac2b0486bc0560c8182aa57d96

Contents?: true

Size: 1.8 KB

Versions: 7

Compression:

Stored size: 1.8 KB

Contents

require 'ffi'

require 'uia/library/struct_attributes'

module Uia
  module Library
    module ElementLayout
      def self.included(base)
        base.class_eval do
          extend StructAttributes

          layout :handle, :int,
                 :runtime_id, :pointer,
                 :number_of_ids, :int,
                 :name, :string,
                 :class_name, :string,
                 :control_type_id, :int,
                 :patterns, :pointer,
                 :patterns_length, :int,
                 :id, :string,
                 :is_enabled, :bool,
                 :is_visible, :bool,
                 :has_focus, :bool,
                 :bounding_rectangle, [:long, 4]

          struct_attr :id, :name, :handle, :control_type_id, :class_name,
                      [:enabled?, :is_enabled], [:visible?, :is_visible], [:focused?, :has_focus]

          def runtime_id
            self[:runtime_id].read_array_of_int(number_of_ids)
          end

          def bounding_rectangle
            self[:bounding_rectangle].to_a
          end

          def pattern_ids
            self[:patterns].read_array_of_int(self[:patterns_length])
          end

          def children
            Library.children(self)
          end

          def descendants
            Library.descendants(self)
          end

          def empty?
            to_ptr.address == 0
          end

          private
          def number_of_ids
            self[:number_of_ids]
          end
        end
      end
    end

    class ManagedElementStruct < FFI::ManagedStruct
      include ElementLayout

      def self.release(pointer)
        Library.release_element(pointer)
      end
    end

    class ElementStruct < FFI::Struct
      include ElementLayout
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
uia-0.1.2.3 lib/uia/library/element_structs.rb
uia-0.1.2.2 lib/uia/library/element_structs.rb
uia-0.1.2.1 lib/uia/library/element_structs.rb
uia-0.1.2 lib/uia/library/element_structs.rb
uia-0.1.1 lib/uia/library/element_structs.rb
uia-0.1 lib/uia/library/element_structs.rb
uia-0.0.9 lib/uia/library/element_structs.rb