Re: [MacRuby-devel] Multiple enumerations
Hmm…in general I would steer clear of scripting bridge when equivalent functionality is available elsewhere. In this case, you can make use of the Quartz Event Services. There's a Stack Overflow answer here that should be able to get you started: http://stackoverflow.com/questions/1938509/how-to-simulate-a-low-level-keypress-on-os-x As for the exact problem you're facing, I'm not sure what the answer is. Looking at the AppleScript dictionary, it seems like "command down" and "option down" are special properties in the dictionary, but I don't recall at the moment how to extract dictionary properties from the library. Depending on where you extracted those numeric values from, there's a chance that they could be different on your system (i.e. enums might change between OS versions, since you're supposed to use them as enums and not numeric values). But the short answer is: your code looks fine, and using enums/numeric constants like that should work as expected in MacRuby. Have you tried the equivalent code in Obj-C to see if this is specific to MacRuby? Cheers, Josh On Tuesday, May 1, 2012 at 11:57 PM, Josh Voigts wrote: > Is there a way to get multiple enumerations to work, like in the > following example. I know I could be doing this with cocoa, but it's a > small scripting project. (Also I didn't feel like loading a bridge > support file, would that help in this case?) > > > framework 'ScriptingBridge' > > sys = SBApplication.applicationWithBundleIdentifier("com.apple.systemevents") > > COMMAND_KEY = 1264807268 > OPTION_KEY = 1265594484 > > sys.keystroke("u", using: COMMAND_KEY|OPTION_KEY) > > > > It seems to only recognize the first enum... I'm probably missing > something logically here... > ___ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org (mailto:MacRuby-devel@lists.macosforge.org) > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > > ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Multiple enumerations
If you do want to go the way of Quartz, I've already created a layer above it that you may want to use. The gem: https://rubygems.org/gems/AXTyper Example Usage: irb(main):001:0> require 'rubygems' irb(main):002:0> require 'accessibility/string' irb(main):003:0> include Accessibility::String irb(main):004:0> events = keyboard_events_for "Hello, #{ENV['USER']}." irb(main):005:0> events.each do |event| KeyCoder.post_event event end In your case, you can try a hotkey combination like this: irb(main):004:0> events = keyboard_events_for "\\COMMAND+\\OPTION+u" irb(main):005:0> events.each do |event| KeyCoder.post_event event end And there are more details in the blog post I wrote about it: http://ferrous26.com/blog/2012/04/03/axelements-part1/ On 2012-05-02, at 9:05 AM, Joshua Ballanco wrote: > Hmm…in general I would steer clear of scripting bridge when equivalent > functionality is available elsewhere. In this case, you can make use of the > Quartz Event Services. There's a Stack Overflow answer here that should be > able to get you started: > http://stackoverflow.com/questions/1938509/how-to-simulate-a-low-level-keypress-on-os-x > > As for the exact problem you're facing, I'm not sure what the answer is. > Looking at the AppleScript dictionary, it seems like "command down" and > "option down" are special properties in the dictionary, but I don't recall at > the moment how to extract dictionary properties from the library. Depending > on where you extracted those numeric values from, there's a chance that they > could be different on your system (i.e. enums might change between OS > versions, since you're supposed to use them as enums and not numeric values). > > But the short answer is: your code looks fine, and using enums/numeric > constants like that should work as expected in MacRuby. Have you tried the > equivalent code in Obj-C to see if this is specific to MacRuby? > > Cheers, > > Josh > > > On Tuesday, May 1, 2012 at 11:57 PM, Josh Voigts wrote: > >> Is there a way to get multiple enumerations to work, like in the >> following example. I know I could be doing this with cocoa, but it's a >> small scripting project. (Also I didn't feel like loading a bridge >> support file, would that help in this case?) >> >> >> framework 'ScriptingBridge' >> >> sys = SBApplication.applicationWithBundleIdentifier("com.apple.systemevents") >> >> COMMAND_KEY = 1264807268 >> OPTION_KEY = 1265594484 >> >> sys.keystroke("u", using: COMMAND_KEY|OPTION_KEY) >> >> >> >> It seems to only recognize the first enum... I'm probably missing >> something logically here... >> ___ >> MacRuby-devel mailing list >> MacRuby-devel@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > > ___ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Failing installers
It's been a while since I installed a nightly build because I get a error in the installer ("Installation failed", and "An error occurred while running scripts from the package “macruby_nightly-2012-05-02.pkg”"), and I haven't had the time to look into it. I've just given it another go, and, to my eyes, it seems to have installed everything it should have: /Library/Frameworks/MacRuby.framework /usr/local/bin/macgem /usr/local/bin/macirb /usr/local/bin/macrake /usr/local/bin/macrdoc /usr/local/bin/macri /usr/local/bin/macruby /usr/local/bin/macruby_deploy /usr/local/bin/macruby_select /usr/local/bin/macrubyc /usr/local/bin/macrubyd Does anyone know if that is everything? Can I just ignore the installer error if the above is in place? Cheers -- Fb ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Failing installers
The script might fail if you do not have Xcode installed or something is unusual about your Xcode setup. To answer your other question, everything except Xcode integration should be installed by the time that the failing script is run. Also, if it turns out to be something with your setup of Xcode, could you please log a bug with details? This seems like it should be a blocker for release. Sent from my iDevice On 2012-05-02, at 12:42, stephen horne wrote: > It's been a while since I installed a nightly build because I get a error in > the installer ("Installation failed", and "An error occurred while running > scripts from the package “macruby_nightly-2012-05-02.pkg”"), and I haven't > had the time to look into it. > > I've just given it another go, and, to my eyes, it seems to have installed > everything it should have: > > > /Library/Frameworks/MacRuby.framework > > /usr/local/bin/macgem > /usr/local/bin/macirb > /usr/local/bin/macrake > /usr/local/bin/macrdoc > /usr/local/bin/macri > /usr/local/bin/macruby > /usr/local/bin/macruby_deploy > /usr/local/bin/macruby_select > /usr/local/bin/macrubyc > /usr/local/bin/macrubyd > > > Does anyone know if that is everything? Can I just ignore the installer error > if the above is in place? > > Cheers > -- > Fb > > ___ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Failing installers
Ok, thanks. Xcode is installed, and I don't remember doing anything funny to it, but it's entirely possible I broke it somehow as much of it is beyond my understanding - I will see if I can figure it out and log a bug if I do. fb On 02/05/2012, at 18:45, Mark Rada wrote: > The script might fail if you do not have Xcode installed or something is > unusual about your Xcode setup. > > To answer your other question, everything except Xcode integration should be > installed by the time that the failing script is run. > > Also, if it turns out to be something with your setup of Xcode, could you > please log a bug with details? This seems like it should be a blocker for > release. > > Sent from my iDevice > > On 2012-05-02, at 12:42, stephen horne wrote: > >> It's been a while since I installed a nightly build because I get a error in >> the installer ("Installation failed", and "An error occurred while running >> scripts from the package “macruby_nightly-2012-05-02.pkg”"), and I haven't >> had the time to look into it. >> >> I've just given it another go, and, to my eyes, it seems to have installed >> everything it should have: >> >> >> /Library/Frameworks/MacRuby.framework >> >> /usr/local/bin/macgem >> /usr/local/bin/macirb >> /usr/local/bin/macrake >> /usr/local/bin/macrdoc >> /usr/local/bin/macri >> /usr/local/bin/macruby >> /usr/local/bin/macruby_deploy >> /usr/local/bin/macruby_select >> /usr/local/bin/macrubyc >> /usr/local/bin/macrubyd >> >> >> Does anyone know if that is everything? Can I just ignore the installer >> error if the above is in place? >> >> Cheers >> -- >> Fb >> >> ___ >> MacRuby-devel mailing list >> MacRuby-devel@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > ___ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel -- Stephen Horne ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Failing installers
Hmm, that does sound strange. The script that the installer runs is found here: https://github.com/MacRuby/MacRuby/blob/master/misc/release/package_script/postinstall I would guess that it is not able to get the Xcode dir properly and failing to set it up. On 2012-05-02, at 2:03 PM, stephen horne wrote: > Ok, thanks. Xcode is installed, and I don't remember doing anything funny to > it, but it's entirely possible I broke it somehow as much of it is beyond my > understanding - I will see if I can figure it out and log a bug if I do. > > fb > > On 02/05/2012, at 18:45, Mark Rada wrote: > >> The script might fail if you do not have Xcode installed or something is >> unusual about your Xcode setup. >> >> To answer your other question, everything except Xcode integration should be >> installed by the time that the failing script is run. >> >> Also, if it turns out to be something with your setup of Xcode, could you >> please log a bug with details? This seems like it should be a blocker for >> release. >> >> Sent from my iDevice >> >> On 2012-05-02, at 12:42, stephen horne wrote: >> >>> It's been a while since I installed a nightly build because I get a error >>> in the installer ("Installation failed", and "An error occurred while >>> running scripts from the package “macruby_nightly-2012-05-02.pkg”"), and I >>> haven't had the time to look into it. >>> >>> I've just given it another go, and, to my eyes, it seems to have installed >>> everything it should have: >>> >>> >>> /Library/Frameworks/MacRuby.framework >>> >>> /usr/local/bin/macgem >>> /usr/local/bin/macirb >>> /usr/local/bin/macrake >>> /usr/local/bin/macrdoc >>> /usr/local/bin/macri >>> /usr/local/bin/macruby >>> /usr/local/bin/macruby_deploy >>> /usr/local/bin/macruby_select >>> /usr/local/bin/macrubyc >>> /usr/local/bin/macrubyd >>> >>> >>> Does anyone know if that is everything? Can I just ignore the installer >>> error if the above is in place? >>> >>> Cheers >>> -- >>> Fb >>> >>> ___ >>> MacRuby-devel mailing list >>> MacRuby-devel@lists.macosforge.org >>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel >> ___ >> MacRuby-devel mailing list >> MacRuby-devel@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > > -- > Stephen Horne > > ___ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel