text
stringlengths
0
15.7k
source
stringlengths
6
112
set theMenuItem to ((current application's NSApp's mainMenu()'s itemAtIndex:1)'s submenu())'s itemAtIndex:1
lns3.scpt
set theMenuItem to ((current application's NSApp's mainMenu()'s itemAtIndex:1)'s submenu())'s itemAtIndex:2
lns3.scpt
set theMenuItem to ((current application's NSApp's mainMenu()'s itemAtIndex:1)'s submenu())'s itemAtIndex:3
lns3.scpt
set theMenuItem to ((current application's NSApp's mainMenu()'s itemAtIndex:1)'s submenu())'s itemAtIndex:4
lns3.scpt
set theDemoMenu to current application's NSApp's mainMenu()'s itemWithTitle:"Demo"
lns3.scpt
set theDemoMenuItems to theDemoMenu's submenu()
lns3.scpt
repeat with i from 0 to 2
lns3.scpt
set theDemoMenuItem to (theDemoMenuItems's itemAtIndex:i)
lns3.scpt
(theDemoMenuItem's setTarget:me)
lns3.scpt
end ModifyTargetsOfItems
lns3.scpt
set RootMenu to current application's NSApp's mainMenu
lns3.scpt
set DemoMenuItem to RootMenu's addItemWithTitle:"Demo" action:"" keyEquivalent:""
lns3.scpt
set DemoMenu to current application's NSMenu's alloc()'s initWithTitle:"Demo"
lns3.scpt
set DemoMenuItem's submenu to DemoMenu
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 1" action:"DoDemo1:" keyEquivalent:""
lns3.scpt
ReturnValue's setTarget:me
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 2" action:"DoDemo2" keyEquivalent:""
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 3" action:"DoDemo3:"
lns3.scpt
on doDemo1:sender
lns3.scpt
display dialog "message" buttons {"Cancel", "OK"} default button "OK" with title "Demo 1"
lns3.scpt
end doDemo1:
lns3.scpt
on doDemo2()
lns3.scpt
display dialog "message" buttons {"Cancel", "OK"} default button "OK" with title "Demo 2"
lns3.scpt
end doDemo2
lns3.scpt
on doDemo3:sender
lns3.scpt
display dialog "message" buttons {"Cancel", "OK"} default button "OK" with title "Demo 3"
lns3.scpt
end doDemo3:
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 1" action:"doDemo1:" keyEquivalent:""
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 2" action:"doDemo2:" keyEquivalent:""
lns3.scpt
set ReturnValue to DemoMenu's addItemWithTitle:"Demo 3" action:"doDemo3:" keyEquivalent:""
lns3.scpt
set DemoMenuItem to current application's NSMenuItem's alloc()'s initWithTitle:"Demo" action:"" keyEquivalent:""
lns3.scpt
DemoMenuItem's setSubmenu:DemoMenu
lns3.scpt
set RootMenu to current application's NSApp's mainMenu()
lns3.scpt
RootMenu's addItem:DemoMenuItem
lns3.scpt
on doDemo2:sender
lns3.scpt
end doDemo2:
lns3.scpt
on validateMenuItem:anItem
lns3.scpt
set theSel to anItem's action() as text
lns3.scpt
display dialog theSel
lns3.scpt
end validateMenuItem:
lns3.scpt
RootMenu's setAutoenablesItems:false -- enabling/disabling must be done manually
lns3.scpt
set theFolder to "/Users/shane/Desktop/"
lns3.scpt
set totalSize to its sizeOfFolder:theFolder
lns3.scpt
display dialog (its formatAsBytes:totalSize)
lns3.scpt
on sizeOfFolder:folderPosixPath
lns3.scpt
set theURL to current application's |NSURL|'s fileURLWithPath:folderPosixPath
lns3.scpt
set totalSize to 0
lns3.scpt
set theEnumerator to current application's NSFileManager's defaultManager()'s enumeratorAtURL:theURL includingPropertiesForKeys:{current application's NSURLTotalFileSizeKey} options:0 errorHandler:(missing value)
lns3.scpt
repeat with nextURL in theEnumerator's allObjects()
lns3.scpt
set {hasResult, theResult} to (nextURL's getResourceValue:(reference) forKey:(current application's NSURLTotalFileSizeKey) |error|:(missing value))
lns3.scpt
set totalSize to totalSize + (theResult as real)
lns3.scpt
return totalSize
lns3.scpt
end sizeOfFolder:
lns3.scpt
on formatAsBytes:theValue
lns3.scpt
set theNSByteCountFormatter to current application's NSByteCountFormatter's alloc()'s init()
lns3.scpt
theNSByteCountFormatter's setIncludesActualByteCount:true
lns3.scpt
theNSByteCountFormatter's setCountStyle:(current application's NSByteCountFormatterCountStyleFile)
lns3.scpt
return (theNSByteCountFormatter's stringFromByteCount:theValue) as text
lns3.scpt
end formatAsBytes:
lns3.scpt
set currentUsers to "Login User List:" & return
lns3.scpt
set currentUsers to currentUsers & (do shell script "dscl . list /Users UniqueID | egrep -v ^'_|daemon|nobody|root'")
lns3.scpt
set theData to current application's NSData's dataWithContentsOfFile:"/Library/Preferences/com.apple.preferences.accounts.plist"
lns3.scpt
if theData is not missing value then
lns3.scpt
set currentUsers to currentUsers & return & return & "Deleted User List:" & return
lns3.scpt
set {theThing, theError} to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 |format|:(missing value) |error|:(reference)
lns3.scpt
set theNames to theThing's valueForKeyPath:"deletedUsers.dsAttrTypeStandard:RealName"
lns3.scpt
set theIDs to theThing's valueForKeyPath:"deletedUsers.dsAttrTypeStandard:UniqueID"
lns3.scpt
repeat with i from 1 to count of theNames
lns3.scpt
set currentUsers to currentUsers & item i of theNames & tab & tab & tab & item i of theIDs & return
lns3.scpt
try -- will fail because it's js
lns3.scpt
script "JSTest.scpt"
lns3.scpt
on error from jsLib -- jsLib will refer to lib
lns3.scpt
set jsLibPath to POSIX path of (jsLib as alias)
lns3.scpt
set {myJSLib, theError} to current application's OSAScript's alloc()'s initWithContentsOfURL:(current application's |NSURL|'s fileURLWithPath:jsLibPath) |error|:(reference)
lns3.scpt
if myJSLib is missing value then error (theError's localizedDescription()) as text
lns3.scpt
my callFunction:"doIt" withArgs:{2, 2} inJSLib:myJSLib
lns3.scpt
on callFunction:funcName withArgs:argsList inJSLib:myJSLib
lns3.scpt
set {theResult, theError} to myJSLib's executeHandlerWithName:funcName arguments:argsList |error|:(reference)
lns3.scpt
if theResult is missing value then error (theError's localizedDescription()) as text
lns3.scpt
end callFunction:withArgs:inJSLib:
lns3.scpt
display dialog "This is just a test." buttons {"Great", "OK"}
lns3.scpt
default button "OK" giving up after 3
lns3.scpt
set myName to "John"
lns3.scpt
copy 33 to myAge
lns3.scpt
set averageTemp to 63 as degrees Fahrenheit
lns3.scpt
set savedName to name of front window
lns3.scpt
close window savedName
lns3.scpt
get name of front window of application "Finder"
lns3.scpt
property defaultClientName : "Mary Smith"
lns3.scpt
on greetClient(nameOfClient)
lns3.scpt
display dialog ("Hello " & nameOfClient & "!")
lns3.scpt
end greetClient
lns3.scpt
script testGreet
lns3.scpt
greetClient(defaultClientName)
lns3.scpt
run testGreet --result: "Hello Mary Smith!"
lns3.scpt
greetClient("Joe Jones") --result: "Hello Joe Jones!"
lns3.scpt
set myList to {1, "what", 3} --result: {1, "what", 3}
lns3.scpt
set beginning of myList to 0
lns3.scpt
set end of myList to "four"
lns3.scpt
myList --result: {0, 1, "what", 3, "four"}
lns3.scpt