2015-06-17 24 views

回答

1

您還沒有真正瞭解AppleScript,Objective-c或applescriptObjc的知識。

但我會離開你這個:

use scripting additions 
use framework "Foundation" 
use framework "cocoa" 



property aWindow : class "NSWindow" 
property aWindow2 : class "NSWindow" 
set height to 350 
set width to 250 
set winRect to current application's NSMakeRect(500, 500, width, height) 
set aWindow to current application's NSWindow's alloc()'s initWithContentRect:winRect styleMask:1 backing:2 defer:false 




set winRect to current application's NSMakeRect(751, 500, width, height) 

--resizable window 
set aWindow2 to current application's NSWindow's alloc()'s initWithContentRect:winRect styleMask:9 backing:2 defer:false 


(* Thiese button is for when you test in SE, otherwise you will need to quit SE*) 

set closeButtonFrame to current application's NSMakeRect(25, (height - 40), 200, 25) 

set closeBtn1 to current application's NSButton's alloc's initWithFrame:closeButtonFrame 
closeBtn1's setTitle:"close (for testing)" 
set closeBtn1's bezelStyle to 12 --NSRoundedBezelStyle 
closeBtn1's setButtonType:0 --NSMomentaryLightButton 
closeBtn1's setTarget:me 
closeBtn1's setAction:"closeWindow1:" 
aWindow's contentView's addSubview:closeBtn1 


set closeBtn to current application's NSButton's alloc's initWithFrame:closeButtonFrame 
closeBtn's setTitle:"close (for testing)" 
set closeBtn's bezelStyle to 12 --NSRoundedBezelStyle 
closeBtn's setButtonType:0 --NSMomentaryLightButton 
closeBtn's setTarget:me 
closeBtn's setAction:"closeWindow:" 
aWindow2's contentView's addSubview:closeBtn 


aWindow2's makeKeyAndOrderFront:aWindow2 
aWindow's makeKeyAndOrderFront:aWindow 

on closeWindow1:sender 

    aWindow's orderOut:aWindow 
end closeWindow1: 
on closeWindow:sender 

    aWindow2's orderOut:aWindow2 
end closeWindow: