你如何在 applescript 中创建一个受保护的 window?
how do you make a protected window in applescript?
我正在尝试使用无法关闭的 applescript 制作一个应用程序。不幸的是,谷歌搜索 'protected window with applescript' 会出现 'Make a fake virus' 和 'make a password protected app' 这样的结果。请帮忙!
您还没有真正展示对 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:
我正在尝试使用无法关闭的 applescript 制作一个应用程序。不幸的是,谷歌搜索 'protected window with applescript' 会出现 'Make a fake virus' 和 'make a password protected app' 这样的结果。请帮忙!
您还没有真正展示对 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: