I'm trying to get a list of running processes on OS X through Ruby's ScriptingBridge.
Everything works fine, except getting the process id. The problem seems to be that Ruby's internal Object#id property is called instead of the SystemEvents.process.id selector.
This is my current sample code:
#!/usr/bin/env ruby
# Lists all active processes
require 'osx/cocoa'
include OSX
OSX.require_framework 'ScriptingBridge'
app = SBApplication.applicationWithBundleIdentifier_("com.apple.SystemEvents")
procs = app.processes
procs.each do |x|
puts "Process No. #{x.id}: #{x.name}"
end
This is (part of) it's output:
merlin:mw ~/> /Users/mw/Projekte/Ruby/winlist.rb
/Users/mw/Projekte/Python/winlist.rb:13: warning: Object#id will be deprecated; use Object#object_id
Process No. 2275604960: loginwindow
/Users/mw/Projekte/Python/winlist.rb:13: warning: Object#id will be deprecated; use Object#object_id
Process No. 2275603460: talagent
/Users/mw/Projekte/Python/winlist.rb:13: warning: Object#id will be deprecated; use Object#object_id
Process No. 2275600720: Dock
[... snipped list of all my processes ...]
How can I make sure the ScriptingBridge is called, not Object#id?