Re: JavaScript for automation
Re: JavaScript for automation
- Subject: Re: JavaScript for automation
- From: Alex Zavatone <email@hidden>
- Date: Thu, 04 Dec 2014 09:42:04 -0500
Supply it. Don't make the people who you are asking to help you to go and find the script.
Sent from my iPod Touch. Please pardon typos.
On Dec 4, 2014, at 9:14 AM, Deivy Petrescu <email@hidden> wrote:
>
>> On Dec 4, 2014, at 08:52 , Shane Stanley <email@hidden> wrote:
>>
>> On 5 Dec 2014, at 12:39 am, Deivy Petrescu <email@hidden> wrote:
>>>
>>> In every single instance of running this app I have the “sandbox” word showing up in console.
>>
>> It might be more helpful if you gave us some idea of what the script is trying to do, or at least what apps it is addressing.
>
> It is the script that was used in the video of JS for automation in its video presentation in WWDC 2014 (code at the end)
> It creates a cocoa app form scratch (which is very neat)
>
>
>>
>>> Is an app that I created myself prevented to run in my own computer?
>>> Isn’t that taking a very stringent approach to security?
>>
>> And how exactly does the computer know you created it yourself, and that no-one else has modified it since?
>
> C’mon Shane. It is an AS app. It has no problems when I create an app which is AS based (versus JS cocoa).
> This would be hell. If I create an app and I myself can not run it.
>
>
>
>> --
>> Shane Stanley <email@hidden>
>> <www.macosxautomation.com/applescript/apps/>
>
> Here is the code I have. Check to see that there are no errors:
>
>
> <AppleScript JavaScript code!>
>
> ObjC.import("Cocoa");
>
> var mask = $.NSTitledWindowMask
> | $.NSClosableWindowMask
> | $.NSMiniaturizableWindowMask ;
>
> var window = $.NSWindow.alloc.initWithContentRectStyleMaskBackingDefer(
> $.NSMakeRect(0,0,270,130),
> mask,
> $.NSBackingStoreBuffered,
> false
> );
>
> window.center;
>
> window.title= "Temperature Converter";
>
> var currentY =75;
>
> function makeLabelAndInputFor(unit) {
>
> var label = $.NSTextField.alloc.initWithFrame($.NSMakeRect(20, currentY, 80, 25));
>
> label.stringValue = unit;
> label.bezeled = false;
> label.drawsBackground = false;
> label.editable = false;
> label.selectable = false;
> label.alignment = $.NSRightTextAlignment;
>
> var input=$.NSTextField.alloc.initWithFrame($.NSMakeRect(110, currentY+4, 110, 25));
>
> window.contentView.addSubview(label);
> window.contentView.addSubview(input);
>
> currentY -=35;
>
> return input;
>
> }
>
> var fInput = makeLabelAndInputFor("Fahrenheit");
> var CInput = makeLabelAndInputFor("Celsius");
>
> var formatter = $.NSNumberFormatter.alloc.init;
> formatter.numberStyle = $.NSNumberFormatterDecimalStyle;
> formatter.setPaddingPosition = $.NSNumberFormatterPadAfterSuffix;
> formatter.setFormatWidth = 2;
>
>
> ObjC.registerSubclass({
> name:"TpC",
> methods: {
> "toFahrenheit:": {
> types:["void", ["id"]],
> implementation: function(sender) {
> var value = (sender.doubleValue * 9 / 5) + 32;
> fInput.stringValue=formatter.stringFromNumber($(value));
> }
> },
> "toCelsius:": {
> types:["void", ["id"]],
> implementation: function(sender) {
> var value = (sender.doubleValue - 32) * 5 / 9;
> CInput.stringValue=formatter.stringFromNumber($(value));
> }
> }
> }
> });
>
>
> var converter = $.TpC.alloc.init;
> console.log(converter)
>
> fInput.target=converter;
> fInput.action="toCelsius:";
>
> CInput.target=converter;
> CInput.action="toFahrenheit:";
>
> window.makeKeyAndOrderFront(window);
>
> </AppleScript JavaScript code!>
>
>
> Deivy Petrescu
> email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden