[MacRuby-devel] Understanding Pointer objects

Mark Rada mrada at marketcircle.com
Sat Oct 23 22:04:37 PDT 2010


Hi,

I've been trying to play with using the Accessibility API to do some automated testing.

From what I have researched, I have to use some C functions that often need a reference passed to the them. 

I am at a loss when trying to deal with Pointer objects. I've tried playing with them and googling it, but I just cannot figure out how to turn a pointer into a more useful type or to get what I want out of them.

For example, I can start like this:

	framework 'Cocoa'

	unless AXAPIEnabled() # only works if I include the parenthesis
		puts 'Please enable Access for Assistive Devices first'
		exit 2
	end

	mail              = NSRunningApplication.runningApplicationsWithBundleIdentifier('com.apple.Mail').first
	mail_object = AXUIElementCreateApplication mail.processIdentifier 

	names = Pointer.new :object

	AXUIElementCopyAttributeNames mail_object, names


But then how do I get the values out of the names pointer? For reference, I found the functions in AXUIElement.h.


Thanks,
	Mark


More information about the MacRuby-devel mailing list