how do you make a protected window in applescript?

180 views Asked by At

I am trying to make an app with applescript that you can't close. unfortunately, googling 'protected window with applescript' brings up results such as 'Make a fake virus' and 'make a password protected app'. Please help!

1

There are 1 answers

0
markhunte On BEST ANSWER

You have not really shown what know about Applescript, Objective - c or applescriptObjc.

But I will leave you with this:

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: