Changing the Global Settings

The OSA module provides some global variables that you can set to change the behavior of RubyOSA:

Name Default Description
OSA.lazy_events true Controls whether OSA proxy objects are resolved on demand, or always. By default objects are only resolved on demand, when necessary. Setting this variable to false will force every object returned by RubyOSA to be resolved. This may affect the performance of your program as one or more extra Apple events will be sent.
OSA.utf8_strings false Controls whether strings will be encoded as Unicode or ASCII. By default strings are encoded in ASCII as some applications cannot handle Unicode strings.
OSA.timeout -1 Controls the timeout duration of Apple events sent by RubyOSA. The value is expressed in ticks. By default it’s set to -1 which means about one minute. -2 means that there is no timeout.
OSA.wait_reply nil Controls whether RubyOSA should expect a result from the Apple events it will send. When set to nil, the default, it will determine this from the scriptable definition. However, it’s pretty rare but you may encounter a malformed application command. You can therefore either set this variable to true or false to force RubyOSA to send back or not a return value.

You set these settings like this:

OSA.timeout = -1

For your convenience, we added an API to change one or more settings only for a given scope:

OSA.set_params(:timeout => -1, :lazy_events => false) do
# Here the settings will get their original values