diff --git "a/data/applescript/data.json" "b/data/applescript/data.json" new file mode 100644--- /dev/null +++ "b/data/applescript/data.json" @@ -0,0 +1,100 @@ +{"size":4533,"ext":"applescript","lang":"AppleScript","max_stars_count":7.0,"content":"(*\n\tLooks up the network address and the port for the service of the specified type on the host with the specified name.\n*)\n\nlog bonjourLookup(\"afpovertcp\", \"Mac001\", 1.0)\n\nlog bonjourLookup(\"ssh\", \"Mac002\", 1.0)\n\non bonjourLookup(aServiceType, aName, aScanTime)\n\t\n\t-- Service types can be looked up at: http:\/\/www.dns-sd.org\/ServiceTypes.html\n\t\n\tscript bonjourLookup\n\t\t\n\t\tproperty serviceType : aServiceType\n\t\tproperty computerName : aName\n\t\tproperty scanTime : aScanTime\n\t\t\n\t\tproperty lookupResult : \"\"\n\t\t\n\t\ton lookup()\n\t\t\t\n\t\t\tset lookupResult to runLookupScript()\n\t\t\treturn addressAndPortFromLookupResult()\n\t\t\t\n\t\tend lookup\n\t\t\n\t\ton addressAndPortFromLookupResult()\n\t\t\t\n\t\t\tif lookupResult does not contain \"can be reached at\" then return {false, false}\n\t\t\t\n\t\t\tset prvDlmt to text item delimiters\n\t\t\tset text item delimiters to \"can be reached at\"\n\t\t\t\n\t\t\tset theAddress to text item 2 of lookupResult\n\t\t\t\n\t\t\tset text item delimiters to \":\"\n\t\t\tset thePort to text item 2 of theAddress\n\t\t\tset theAddress to text item 1 of theAddress\n\t\t\t\n\t\t\tset text item delimiters to \" \"\n\t\t\tset thePort to text item 1 of thePort\n\t\t\t\n\t\t\tset text item delimiters to prvDlmt\n\t\t\t\n\t\t\tset theAddress to trim(theAddress)\n\t\t\tset thePort to trim(thePort)\n\t\t\t\n\t\t\tif character -1 of theAddress is \".\" then set theAddress to text 1 thru -2 of theAddress\n\t\t\t\n\t\t\treturn {theAddress, thePort}\n\t\t\t\n\t\tend addressAndPortFromLookupResult\n\t\t\n\t\ton runLookupScript()\n\t\t\t\n\t\t\ttry\n\t\t\t\t-- Start the script\n\t\t\t\tset shellScript to {\"#!\/bin\/bash\"}\n\t\t\t\t\n\t\t\t\t-- Use the dns-sd tool to discover services\n\t\t\t\tset end of shellScript to \"\/usr\/bin\/dns-sd -L \" & quoted form of computerName & \" _\" & serviceType & \"._tcp local &\"\n\t\t\t\t\n\t\t\t\t-- Keep track of the process id for the mDNS tool\n\t\t\t\tset end of shellScript to \"mDNSpid=$!\"\n\t\t\t\t\n\t\t\t\t-- Wait a little for mDNS to discover services\n\t\t\t\tset end of shellScript to \"sleep \" & (scanTime as text)\n\t\t\t\t\n\t\t\t\t-- Quit the mDNS tool\n\t\t\t\tset end of shellScript to \"kill -HUP $mDNSpid\"\n\t\t\t\t\n\t\t\t\t-- Compose the script\n\t\t\t\tset shellScript to joinList(shellScript, ASCII character 10)\n\t\t\t\t\n\t\t\t\t-- Run the script\n\t\t\t\tset lookupResult to do shell script shellScript\n\t\t\t\t\n\t\t\t\treturn lookupResult\n\t\t\t\t\n\t\t\ton error _eMsg number _eNum\n\t\t\t\t\n\t\t\t\treturn \"\"\n\t\t\t\t\n\t\t\tend try\n\t\tend runLookupScript\n\t\t\n\t\ton trim(aText)\n\t\t\t\n\t\t\t(* Strips a text of its surrounding white space. *)\n\t\t\t\n\t\t\ttry\n\t\t\t\t\n\t\t\t\tif class of aText is not text then error \"Wrong type.\"\n\t\t\t\t\n\t\t\t\tif length of aText is 0 then return \"\"\n\t\t\t\t\n\t\t\t\t----------------------------------------------------\n\t\t\t\t\n\t\t\t\tset start_WhiteSpaceEnd to false\n\t\t\t\t\n\t\t\t\trepeat with i from 1 to count of characters in aText\n\t\t\t\t\t\n\t\t\t\t\tif (ASCII number (character i of aText)) > 32 and (ASCII number (character i of aText)) is not 202 then\n\t\t\t\t\t\texit repeat\n\t\t\t\t\telse\n\t\t\t\t\t\tset start_WhiteSpaceEnd to i\n\t\t\t\t\tend if\n\t\t\t\t\t\n\t\t\t\tend repeat\n\t\t\t\t\n\t\t\t\t----------------------------------------------------\n\t\t\t\t\n\t\t\t\tset end_WhiteSpaceStart to false\n\t\t\t\t\n\t\t\t\tset i to count of characters in aText\n\t\t\t\t\n\t\t\t\trepeat\n\t\t\t\t\t\n\t\t\t\t\tif start_WhiteSpaceEnd is not false and i \u2264 (start_WhiteSpaceEnd + 1) then exit repeat\n\t\t\t\t\t\n\t\t\t\t\tif (ASCII number (character i of aText)) > 32 and (ASCII number (character i of aText)) is not 202 then\n\t\t\t\t\t\texit repeat\n\t\t\t\t\telse\n\t\t\t\t\t\tset end_WhiteSpaceStart to i\n\t\t\t\t\tend if\n\t\t\t\t\t\n\t\t\t\t\tset i to i - 1\n\t\t\t\t\t\n\t\t\t\tend repeat\n\t\t\t\t\n\t\t\t\t----------------------------------------------------\n\t\t\t\t\n\t\t\t\tif start_WhiteSpaceEnd is false and end_WhiteSpaceStart is false then\n\t\t\t\t\treturn aText\n\t\t\t\t\t\n\t\t\t\telse if start_WhiteSpaceEnd is not false and end_WhiteSpaceStart is false then\n\t\t\t\t\treturn text (start_WhiteSpaceEnd + 1) thru -1 of aText\n\t\t\t\t\t\n\t\t\t\telse if start_WhiteSpaceEnd is false and end_WhiteSpaceStart is not false then\n\t\t\t\t\treturn text 1 thru (end_WhiteSpaceStart - 1) of aText\n\t\t\t\t\t\n\t\t\t\telse if start_WhiteSpaceEnd is not false and end_WhiteSpaceStart is not false then\n\t\t\t\t\treturn text (start_WhiteSpaceEnd + 1) thru (end_WhiteSpaceStart - 1) of aText\n\t\t\t\t\t\n\t\t\t\tend if\n\t\t\t\t\n\t\t\ton error eMsg number eNum\n\t\t\t\t\n\t\t\t\tlog \"trim: \" & eMsg & \" (\" & (eNum as text) & \")\"\n\t\t\t\terror \"trim: \" & eMsg number eNum\n\t\t\t\t\n\t\t\tend try\n\t\t\t\n\t\tend trim\n\t\t\n\t\ton joinList(aList, aDelimiter)\n\t\t\t\n\t\t\tif aDelimiter is false then set aDelimiter to \"\"\n\t\t\t\n\t\t\tset prvDlmt to text item delimiters\n\t\t\tset text item delimiters to aDelimiter\n\t\t\t\n\t\t\tset aList to aList as text\n\t\t\t\n\t\t\tset text item delimiters to prvDlmt\n\t\t\t\n\t\t\treturn aList\n\t\t\t\n\t\tend joinList\n\t\t\n\tend script\n\t\n\ttell bonjourLookup to return lookup()\n\t\nend bonjourLookup","avg_line_length":25.7556818182,"max_line_length":120,"alphanum_fraction":0.6417383631} +{"size":692,"ext":"applescript","lang":"AppleScript","max_stars_count":2.0,"content":"on open (thePaths)\n\tset myFile to (item 1 of thePaths)\n\tset appPath to POSIX path of myFile\n\t\n\ttry\n\t\ttell application \"System Events\"\n\t\t\ttell property list file (appPath & \"Contents\/Info.plist\")\n\t\t\t\tset iconName to the value of property list item \"CFBundleIconFile\"\n\t\t\tend tell\n\t\tend tell\n\t\tif iconName does not end with \".icns\" then set iconName to iconName & \".icns\"\n\ton error errorText\n\t\tbeep\n\t\tdisplay alert \"Could not find an application icon.\" message errorText\n\t\treturn\n\tend try\n\t\n\tset iconFile to POSIX file (appPath & \"Contents\/Resources\/\" & iconName)\n\tset the clipboard to iconFile\n\treturn [{title:iconName, |path|:iconFile, icon:iconFile, subtitle:\"Copied to clipboard!\"}]\nend open","avg_line_length":32.9523809524,"max_line_length":91,"alphanum_fraction":0.7398843931} +{"size":53,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"#!\/usr\/bin\/osascript\n\nset cmd to quoted form of \"pwd\"","avg_line_length":17.6666666667,"max_line_length":31,"alphanum_fraction":0.7169811321} +{"size":2937,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"# Scripts Pack - Tweak various preference variables in macOS\n# \n\n-- When enabled, files will bes style list view on the stack\n-- Highlight Grid Stack Files on mouseover\n\n-- Versions compatible: Mac OS X Leopard (10.5)+\n-- Preference Identifier: com.apple.dock\n-- Preference Key: mouse-over-hilte-stack\n-- Preference location: ~\/Library\/Preferences\/com.apple.dock.plist\n-- Default value (boolean): false\n\n#set MacVer to do shell script \"sw_vers -productVersion\"\n(*set MacVer to \"10.5.0\"\nset Min to \"10.5.0\"\nif MacVer < Min then\n\tdisplay alert \"Outdated Mac OS Version!\" message \"You're using Mac OS \" & MacVer & \". This feature only works with the minimum of Mac OS 10.5 and later. This script will have no effect unless you update your system!\" buttons [\"OK\"] as warning cancel button 1\n*)\n(*\nend if\n\nif MacVer > Min then\n\tset sZ to \"hilite\"\nend if\nif MacVer < \"10.4.9\" then\n\tset sZ to \"hlite\"\nend if\n*)\n\ntry\n\tset prValue to do shell script \"defaults read com.apple.dock mouse-over-\" & sZ & \"-stack\"\n\t\n\tset toggleBut to \"Enable\"\n\tset tZ to \"enable\"\n\tset sTz to \"yes\"\n\tset bT to \"You've decided to enable highlighting of grid stack files.\"\n\t\n\tif prValue = \"1\" then\n\t\t\n\t\tset toggleBut to \"Disable\"\n\t\tset tZ to \"disable\"\n\t\tset sTz to \"no\"\n\t\tset bT to \"You've decided to disable highlighting of grid stack files.\"\n\t\t\n\t\tset prValue to \"The highlight grid stack files on mouseover feature is enabled. You will see a gradient on whichever file you mouseover in the stacks.\"\n\telse\n\t\tset prValue to \"The highlight grid stack files on mouseover feature is disabled. You will not a gradient on whichever file you mouseover in the stacks.\"\n\tend if\non error\n\tset prValue to \"The highlight grid stack files on mouseover feature is disabled by default.\"\nend try\n\nset ttR to display alert \"Would you like to \" & tZ & \" grid view mouseover highlighting?\" message \"This also works with grid view style too. When the cursor is over a file, the gradient highlight will go over to the file that the cursor is pointing at.\" & return & return & prValue buttons {\"Cancel\", \"Clear\", toggleBut} default button 3 cancel button 1\nif the button returned of ttR is toggleBut then\n\tdo shell script \"defaults write com.apple.dock mouse-over-\" & sZ & \"-stack -boolean \" & sTz\nelse\n\tdo shell script \"defaults delete com.apple.dock mouse-over-hilite-stack\"\n\tdo shell script \"defaults delete com.apple.dock mouse-over-hlite-stack\"\n\ttell application \"Dock\"\n\t\tdisplay alert \"Dock hightlight grid stack files preference has been cleared.\" buttons [\"OK\"]\n\tend tell\n\terror number -128\nend if\n\ntell application \"Dock\"\n\tdisplay alert \"Dock - Changes Applied\" message bT & \" Your changes have been applied but have not yet taken effect. To see those changes you need to restart the Dock. Would you like to restart it now?\" buttons [\"Don't Restart\", \"Restart Dock\"] cancel button 1 default button 2\nend tell\ndo shell script \"killall Dock\"\nend","avg_line_length":42.5652173913,"max_line_length":353,"alphanum_fraction":0.7429349677} +{"size":543,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"# Sends keystrokes to type the current date and time, dependent on system formats.\n#\n# Create a new Quick Action workflow in Automator with one Run AppleScript action.\n# Then assign a Keyboard Shortcut to the action (found under the Services category).\non run {input, parameters}\n set now to (current date)\n set dateString to short date string of now\n set timeString to characters 1 thru 5 of (time string of now as string)\n \n tell application \"System Events\"\n keystroke dateString & \" \" & timeString\n end tell\nend run","avg_line_length":41.7692307692,"max_line_length":84,"alphanum_fraction":0.7348066298} +{"size":1802,"ext":"applescript","lang":"AppleScript","max_stars_count":102.0,"content":"#!\/usr\/bin\/osascript\n\n-- Return a string of the_list joined with delimiter\non join_list(the_list, delimiter)\n\tset the_string to \"\"\n\tset old_delims to AppleScript's text item delimiters\n\trepeat with the_item in the_list\n\t\tif the_string is equal to \"\" then\n\t\t\tset the_string to the_string & the_item\n\t\telse\n\t\t\tset the_string to the_string & delimiter & the_item\n\t\tend if\n\tend repeat\n\tset AppleScript's text item delimiters to old_delims\n\treturn the_string\nend join_list\n\n-- Return all connections\non list_connections()\n\tset connections to {}\n\ttell application \"Tunnelblick\"\n\t\t--repeat with the_conf in (get configurations)\n\t\tset i to 1\n\t\trepeat (count of (get configurations)) times\n\t\t\tset the_name to (get name of configuration i)\n\t\t\tset the_state to (get state of configuration i)\n\n\t\t\tif the_state = \"CONNECTED\" then\n\t\t\t\tset the_string to \"1 \"\n\t\t\telse\n\t\t\t\tset the_string to \"0 \"\n\t\t\tend if\n\t\t\tset the_string to the_string & the_name\n\t\t\tset the end of connections to the_string\n\t\t\tset i to i + 1\n\t\tend repeat\n\tend tell\n\treturn join_list(connections, linefeed)\nend list_connections\n\non run (argv)\n\tif (count of argv) is 0 then\n\t\tlog \"Usage: tunnelblick []\"\n\t\treturn\n\tend if\n\n\tset the_command to first item of argv\n\n\tif the_command = \"list\" then\n\t\treturn my list_connections()\n\tend if\n\n\tif the_command = \"disconnect-all\" then\n\t\ttell application \"Tunnelblick\" to disconnect all\n\t\treturn\n\tend if\n\n\t-- Other commands also require a name\n\tif (count of argv) is not 2 then\n\t\tlog \"Usage: tunnelblick []\"\n\t\treturn\n\tend if\n\n\tset the_name to second item of argv\n\n\tif the_command = \"connect\" then\n\t\ttell application \"Tunnelblick\" to connect the_name\n\t\treturn\n\tend if\n\n\tif the_command = \"disconnect\" then\n\t\ttell application \"Tunnelblick\" to disconnect the_name\n\t\treturn\n\tend if\nend run","avg_line_length":24.0266666667,"max_line_length":55,"alphanum_fraction":0.7375138735} +{"size":252,"ext":"scpt","lang":"AppleScript","max_stars_count":null,"content":"tell application \"Google Chrome\" \n if it is running then\n activate\n\n set bounds of front window to {0, 0, 1280, 720}\n\n open location \"https:\/\/www.youtube.com\/watch?v=9EE_ICC_wFw\"\n\n delay 3600 \n\n activate\n end if\n\nend tell","avg_line_length":18.0,"max_line_length":65,"alphanum_fraction":0.6388888889} +{"size":2590,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- rangeFormat :: [Int] -> String\non rangeFormat(xs)\n script rangeString\n on |\u03bb|(xs)\n if length of xs > 2 then\n (item 1 of xs as string) & \"-\" & (item -1 of xs as string)\n else\n intercalate(\",\", xs)\n end if\n end |\u03bb|\n end script\n\n script nonConsec\n on |\u03bb|(a, b)\n b - a > 1\n end |\u03bb|\n end script\n\n intercalate(\",\", map(rangeString, splitBy(nonConsec, xs)))\nend rangeFormat\n\n\n--TEST ------------------------------------------------------------------------\non run\n set xs to {0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, \u00ac\n 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, \u00ac\n 33, 35, 36, 37, 38, 39}\n\n rangeFormat(xs)\n\n --> \"0-2,4,6-8,11,12,14-25,27-33,35-39\"\nend run\n\n\n-- GENERIC FUNCTIONS ----------------------------------------------------------\n\n-- splitBy :: (a -> a -> Bool) -> [a] -> [[a]]\non splitBy(f, xs)\n set mf to mReturn(f)\n\n if length of xs < 2 then\n {xs}\n else\n script p\n on |\u03bb|(a, x)\n set {acc, active, prev} to a\n if mf's |\u03bb|(prev, x) then\n {acc & {active}, {x}, x}\n else\n {acc, active & x, x}\n end if\n end |\u03bb|\n end script\n\n set h to item 1 of xs\n set lstParts to foldl(p, {{}, {h}, h}, items 2 thru -1 of xs)\n item 1 of lstParts & {item 2 of lstParts}\n end if\nend splitBy\n\n-- foldl :: (a -> b -> a) -> a -> [b] -> a\non foldl(f, startValue, xs)\n tell mReturn(f)\n set v to startValue\n set lng to length of xs\n repeat with i from 1 to lng\n set v to |\u03bb|(v, item i of xs, i, xs)\n end repeat\n return v\n end tell\nend foldl\n\n-- map :: (a -> b) -> [a] -> [b]\non map(f, xs)\n tell mReturn(f)\n set lng to length of xs\n set lst to {}\n repeat with i from 1 to lng\n set end of lst to |\u03bb|(item i of xs, i, xs)\n end repeat\n return lst\n end tell\nend map\n\n-- intercalate :: Text -> [Text] -> Text\non intercalate(strText, lstText)\n set {dlm, my text item delimiters} to {my text item delimiters, strText}\n set strJoined to lstText as text\n set my text item delimiters to dlm\n return strJoined\nend intercalate\n\n-- Lift 2nd class handler function into 1st class script wrapper\n-- mReturn :: Handler -> Script\non mReturn(f)\n if class of f is script then\n f\n else\n script\n property |\u03bb| : f\n end script\n end if\nend mReturn\n","avg_line_length":24.9038461538,"max_line_length":79,"alphanum_fraction":0.4772200772} +{"size":3224,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"-- mdexplorer.applescript\n-- mdexplorer\n\n-- Created by Christopher Fox on 1\/9\/06.\n-- Copyright 2006 __MyCompanyName__. All rights reserved.\n\non will finish launching theObject\n\t(* Setting up the mdAttributes data source *)\n\tset mdAttributesDS to data source of table view \"mdAttributes\" of scroll view \"mdAttributes\" of split view \"tableSplitView\" of window \"mdexplorer\" of theObject\n\ttell mdAttributesDS\n\t\tmake new data column at the end of the data columns with properties {name:\"key\"}\n\t\tmake new data column at the end of the data columns with properties {name:\"description\"}\n\t\tset theKeys to do shell script \"mdimport -A | awk -F\\\\' 'BEGIN { OFS=\\\"\\\\t\\\"}{ print $2, $6 }'\"\n\t\tset oldTIDs to AppleScript's text item delimiters\n\t\tset AppleScript's text item delimiters to tab\n\t\trepeat with eachKey from 1 to (count of paragraphs of theKeys)\n\t\t\tset newRow to make new data row at the end of the data rows\n\t\t\tset contents of data cell \"key\" of newRow to text item 1 of paragraph eachKey of theKeys\n\t\t\tset contents of data cell \"description\" of newRow to text item 2 of paragraph eachKey of theKeys\n\t\tend repeat\n\t\tset AppleScript's text item delimiters to oldTIDs\n\tend tell\nend will finish launching\n\non selection changed theObject\n\t(* The user has selected a search key. Get the one selected. Set the contents of the searchKey textfield to the name of the key. *)\n\tset theWindow to the window of theObject\n\tset selectedRow to selected data row of theObject\n\ttell theWindow\n\t\tset contents of text field \"searchKey\" to contents of data cell \"key\" of selectedRow\n\tend tell\nend selection changed\n\non clicked theObject\n\t(* The user has clicked the Search button. *)\n\t\n\t-- Collect some data.\n\tset theWindow to window of theObject\n\ttell theWindow\n\t\tset theSearchKey to contents of text field \"searchKey\"\n\t\tset theSearchBool to title of current menu item of popup button \"searchBool\"\n\t\tset theSearchValue to contents of text field \"searchValue\"\n\t\t-- display dialog theSearchKey & return & theSearchBool & return & theSearchValue\n\tend tell\n\t\n\t-- Run the search.\n\tif theSearchValue = \"\" then\n\t\tset foundFiles to do shell script \"mdfind \\\"\" & theSearchKey & \" \" & theSearchBool & \" ''\\\"\"\n\telse\n\t\tset foundFiles to do shell script \"mdfind \\\"\" & theSearchKey & \" \" & theSearchBool & \" \" & \"'\" & theSearchValue & \"'\\\"\"\n\tend if\n\t\n\t-- Populate the search results window.\n\tset theSearchResultsDS to data source of table view \"foundItems\" of scroll view \"foundItems\" of split view \"tableSplitView\" of window of theObject\n\tdelete data rows of theSearchResultsDS\n\ttell theSearchResultsDS\n\t\tmake new data column at the end of the data columns with properties {name:\"filename\"}\n\t\tmake new data column at the end of the data columns with properties {name:\"keyValue\"}\n\t\trepeat with eachFile from 1 to (count of paragraphs of foundFiles)\n\t\t\tset filesKey to do shell script \"mdls -name \" & theSearchKey & \" \" & quoted form of (paragraph eachFile of foundFiles) & \" | awk '{ print $3 }' | tr -d \\\\\\\"\"\n\t\t\tset newRow to make new data row at the end of the data rows\n\t\t\tset contents of data cell \"filename\" of newRow to paragraph eachFile of foundFiles\n\t\t\tset contents of data cell \"keyValue\" of newRow to filesKey\n\t\tend repeat\n\tend tell\n\t\nend clicked\n","avg_line_length":47.4117647059,"max_line_length":161,"alphanum_fraction":0.7465880893} +{"size":1027,"ext":"applescript","lang":"AppleScript","max_stars_count":8.0,"content":"-- For help, bug reports, or feature suggestions, please visit https:\/\/github.com\/samschloegel\/qlab-scripts\n-- Built for QLab 4. v211121-01\n\nset userNumPrefix to \"y\"\nset userNamePrefix to \"Yamaha Scene\"\nset userColor to \"Purple\"\n\ntell application id \"com.figure53.QLab.4\" to tell front workspace\n\ttry\n\t\tset userInput to display dialog \"Scene?\" default answer \"\" buttons {\"Cancel\", \"Continue\"} default button \"Continue\"\n\t\tset theScene to text returned of userInput\n\t\tif button returned of userInput is \"Continue\" and theScene is not \"\" then\n\t\t\tmake type \"Start\"\n\t\t\tset theStart to last item of (selected as list)\n\t\t\tset cue target of theStart to cue (userNumPrefix & theScene)\n\t\t\tset q color of theStart to userColor\n\t\t\tmake type \"Group\"\n\t\t\tset theGroup to last item of (selected as list)\n\t\t\tset q name of theGroup to userNamePrefix & \" \" & theScene\n\t\t\tset q color of theGroup to userColor\n\t\t\tmove cue id (uniqueID of theStart) of parent of theStart to cue id (uniqueID of theGroup)\n\t\tend if\n\ton error\n\t\treturn\n\tend try\nend tell","avg_line_length":39.5,"max_line_length":117,"alphanum_fraction":0.7429406037} +{"size":495,"ext":"applescript","lang":"AppleScript","max_stars_count":7.0,"content":"set currentApp to path to frontmost application\ntell application \"Safari\" to activate\ndelay 1\ntell application \"Safari\"\n\tset tabtitle to name of front document\nend tell\n\nif {tabtitle starts with \"SAS Studio\"} then\n\ttell application \"System Events\"\n\t\tdelay 0.1\n\t\tkey code 21 using option down\n\t\tdelay 0.1\n\t\tkeystroke \"a\" using command down\n\t\tdelay 0.1\n\t\tkeystroke \"v\" using command down\n\t\tkey code 99\n\tend tell\nelse\n\tdisplay dialog \"SAS Studio is not on the active tab\"\nend if\nactivate currentApp","avg_line_length":23.5714285714,"max_line_length":53,"alphanum_fraction":0.7656565657} +{"size":1128,"ext":"applescript","lang":"AppleScript","max_stars_count":23.0,"content":"on run argv\n\ttell application \"Google Chrome\"\n\t\t-- Open incognito window\n\t\tset W to every window whose mode is \"incognito\"\n\t\tif W = {} then set W to {make new window with properties {mode:\"incognito\"}}\n\t\tset [W] to W\n\n\t\t-- Open new tab with incognito query\n\t\tset userQuery to item 1 of argv\n\t\tset incognitoQuery to \"https:\/\/www.google.com\/search?q=\" & userQuery\n\t\ttell W to set T to make new tab with properties {URL:incognitoQuery}\n\n\t\t-- Close empty tab if found\n\t\t-- Script creates an empty tab when opening an incognito window\n\t\tset emptyTab to my lookupTabWithUrl(\"chrome:\/\/newtab\/\")\n\t\tif emptyTab is not null then\n\t\t\tclose emptyTab\n\t\tend if\n\n\t\t-- Focus incognito window\n\t\tset index of W to 1\n\t\tactivate\n\tend tell\nend run\n\n-- Function:\n-- Look up tab with given URL\n-- Returns tab reference, if found\nto lookupTabWithURL(www)\n\tlocal www\n\n\ttell application \"Google Chrome\"\n\t\tset _T to a reference to (every tab of every window whose URL is www)\n\n\t\t-- Check if tab with given URL was found\n\t\tif (count _T) = 0 then return null\n\t\t-- Returns tab reference if found\n\n\t\treturn item 1 of item 1 of _T\n\tend tell\nend lookupTabWithURL","avg_line_length":27.512195122,"max_line_length":78,"alphanum_fraction":0.7207446809} +{"size":231,"ext":"applescript","lang":"AppleScript","max_stars_count":11.0,"content":"tell application \"System Events\"\n\tset ProcessList to name of every process\n\tif \"BetterTouchTool\" is in ProcessList then\n\t\tset ThePID to unix id of process \"BetterTouchTool\"\n\t\tdo shell script \"kill -KILL \" & ThePID\n\tend if\nend tell\n","avg_line_length":28.875,"max_line_length":52,"alphanum_fraction":0.7662337662} +{"size":2020,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"-- frequently used notebook\nproperty _notebook: \"01-\u5f85\u6574\u7406\"\n\n-- show user interact dialog for the first time\nif _notebook is \"\" then\n\n -- ask user to choose which notebook to save\n -- create new notebook or use created notebook\n try\n tell application \"Evernote\"\n -- get all created notebook to Notebook List\n set notebookList to {}\n set allNotebooks to every notebook\n repeat with currentNoteBook in allNotebooks\n set notebookList to notebookList & name of currentNoteBook\n end repeat\n\n -- ask user to choose one of the created notebook\n set selections to (choose from list notebookList with title \"\u9009\u62e9\u5df2\u521b\u5efa\u7684\u7b14\u8bb0\u672c\" with prompt \"\u5df2\u521b\u5efa\u7684\u7b14\u8bb0\u672c\uff1a\")\n if selections is not false then\n set _notebook to item 1 of selections\n end if\n end tell\n end try\nend if\n\n-- if _notebook is still empty then exit\nif _notebook is \"\" then\n return\nend if\n\n-- get related info\nset theDate to date string of (current date)\nset theTime to time string of (current date)\nset noteName to \"\u5907\u5fd8 - \" & theDate\nset appName to \"{popclip app name}\"\n\n-- create new note or append data to existed note\ntell application \"Evernote\"\n set queryResults to (find notes noteName)\n if count of queryResults is not 0 then\n set theNote to item 1 of queryResults\n set theNotebook to notebook of theNote\n if name of theNotebook equals _notebook then\n set contentInNote to \"
\" & \"{popclip text}\" & \"<\/pre>
<<< \" & appName & \" - \" & theTime & \"<\/strong><\/div>\"\n append theNote html contentInNote\n return\n end if\n end if\n\n set contentInNote to \"
\" & \"{popclip text}\" & \"<\/pre>
<<< \" & appName & \" - \" & theTime & \"<\/strong><\/div>\"\n create note title noteName notebook _notebook with html contentInNote\n\n display dialog \"\u5907\u5fd8\u6210\u529f\u6dfb\u52a0\u81f3\u7b14\u8bb0\u672c[\" & _notebook & \"]!\"\nend tell","avg_line_length":36.7272727273,"max_line_length":141,"alphanum_fraction":0.6287128713} +{"size":108,"ext":"scpt","lang":"AppleScript","max_stars_count":null,"content":"do shell script \"\/bin\/sh ~\/Dropbox\/workspace\/mika4-heroku-operation\/event.sh clock rankforce-nightly start\"\n","avg_line_length":54.0,"max_line_length":107,"alphanum_fraction":0.8055555556} +{"size":325,"ext":"applescript","lang":"AppleScript","max_stars_count":116.0,"content":"tell application \"QuickTime Player\"\n\tset check to name of every window\n\tif check is {} then\n\t\tset resultDocument to new screen recording\n\t\tdelay 1\n\t\ttell resultDocument\n\t\t\tstart\n\t\tend tell\n\telse\n\t\tset resultDocument to first document whose name is \"Screen Recording\"\n\t\ttell resultDocument\n\t\t\tstop\n\t\tend tell\n\tend if\nend tell\n","avg_line_length":20.3125,"max_line_length":71,"alphanum_fraction":0.7569230769} +{"size":41,"ext":"applescript","lang":"AppleScript","max_stars_count":2.0,"content":"do shell script \"echo \\\"Hello, world!\\\"\"\n","avg_line_length":20.5,"max_line_length":40,"alphanum_fraction":0.6585365854} +{"size":1590,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"--\n-- Created by Iain Moncrief on 2\/27\/17.\n-- Copyright \u00a9 2017 Iain Moncrief. All rights reserved.\n--\n\n\n-- Please note, that this file will not wrok as is. These snippets need to be edited to fit your needs.\n\n\n\n global serverConnectionStatus\n \n\non checkConnection_()\n \n set IP_address to \"(ANY STABLE WEBSITE)\"\n \n set serverConnectionStatus to false\n \n -- Initialise if conectivity is valid\n try\n \n set ping to (do shell script \"ping -c 2 \" & IP_address)\n\n set serverConnectionStatus to true\n \n on error\n \n -- if we get here, the ping failed\n \n set serverConnectionStatus to false\n \n end try\n \nend checkConnection_\n\n\n-- Connecting to cloud\n (**)\n on cloud_()\n\ncheckConnection_()\n\n if serverConnectionStatus is true then\n\nset volumeString to \"afp:\/\/\" & \"\" & \":\" & \"null\" & \"@YourDomain\"\n-- having the volume string in that configuration, will give the user a dialog to securley put their username and password into. the user also has the feature to save the user and pass to their keychain.\n\ntry\n \n mount volume volumeString\n --Cloud is connected after this point!\n \n on error\n \n -- could not connect to cloud\n display dialog \"Cannot connect to cloud. Please try checking your username and password.\" buttons {\"OK\"} with icon 2\n\nend try\n\nelse\n-- could not connect to cloud\ndisplay dialog \"Cannot connect to Cloud. Please check your connection.\" buttons {\"OK\"} with icon 2\n\nend if\n\nend cloud_\n \n","avg_line_length":23.0434782609,"max_line_length":203,"alphanum_fraction":0.6389937107} +{"size":799,"ext":"applescript","lang":"AppleScript","max_stars_count":8.0,"content":"-- For help, bug reports, or feature suggestions, please visit https:\/\/github.com\/samschloegel\/qlab-scripts\n-- Built for QLab 4. v211121-01\n\nset userPatch to 1\nset userPrefix to \"\"\nset userSuffix to \".\"\n\ntell application id \"com.figure53.QLab.4\" to tell front workspace\n\ttry\n\t\tset userInput to display dialog \"QLab Cue?\" default answer \"\" buttons {\"Cancel\", \"Continue\"} default button \"Continue\"\n\t\tset cueNumber to text returned of userInput\n\t\tif button returned of userInput is \"Continue\" then\n\t\t\tmake type \"Network\"\n\t\t\tset theNetwork to last item of (selected as list)\n\t\t\tset patch of theNetwork to userPatch\n\t\t\tset osc message type of theNetwork to custom\n\t\t\tset custom message of theNetwork to (\"\/cue\/\" & userPrefix & cueNumber & userSuffix & \"\/go\")\n\t\tend if\n\ton error\n\t\treturn\n\tend try\nend tell","avg_line_length":36.3181818182,"max_line_length":120,"alphanum_fraction":0.7409261577} +{"size":178,"ext":"applescript","lang":"AppleScript","max_stars_count":16.0,"content":"tell application \"System Events\" to tell process \"iTunes\"'s menu bar 1's menu bar item \"\u63a7\u5236\"'s menu 1's menu item \"\u91cd\u590d\"'s menu 1\n\tperform action \"AXPress\" of menu item \"\u5173\"\nend tell","avg_line_length":59.3333333333,"max_line_length":126,"alphanum_fraction":0.7303370787} +{"size":262,"ext":"scpt","lang":"AppleScript","max_stars_count":2.0,"content":"if application \"Rdio\" is running then\n tell application \"Rdio\"\n set theName to name of the current track\n set theArtist to artist of the current track\n try\n return \"\u266b \" & theName & \" - \" & theArtist\n on error err\n end try\n end tell\nend if\n","avg_line_length":23.8181818182,"max_line_length":48,"alphanum_fraction":0.6564885496} +{"size":1022,"ext":"applescript","lang":"AppleScript","max_stars_count":4.0,"content":"if isMusicPlaying() is true then\n\ttry\n\t\ttell application \"iTunes\" to set {artistName, songName, albumName, lyricsRaw} to {artist, name, album, lyrics} of current track\n\ton error e\n\t\tlogEvent(e)\n\tend try\n\n\tset myLyrics to {}\n\tset lyricsRaw to paragraphs of lyricsRaw\n\n\trepeat with aLine in lyricsRaw\n\t\tset myLyrics to myLyrics & aLine & \"\\n\" & return\n\tend repeat\n\n\treturn artistName & \"~\" & songName & \"~\" & albumName & \"~\" & myLyrics as string\nelse\n\treturn\nend if\n\non isMusicPlaying()\n\tset answer to false\n\ttell application \"System Events\" to set isRunning to (name of processes) contains \"iTunes\"\n\tif isRunning is true then\n\t\ttry\n\t\t\ttell application \"iTunes\" to if player state is playing then set answer to true\n\t\ton error e\n\t\t\tmy logEvent(e)\n\t\tend try\n\tend if\n\treturn answer\nend isMusicPlaying\n\non logEvent(e)\n\ttell application \"Finder\" to set myName to (name of file (path to me))\n\tdo shell script \"echo '\" & (current date) & space & quoted form of (e as string) & \"' >> ~\/Library\/Logs\/\" & myName & \".log\"\nend logEvent","avg_line_length":28.3888888889,"max_line_length":129,"alphanum_fraction":0.7142857143} +{"size":36745,"ext":"applescript","lang":"AppleScript","max_stars_count":5.0,"content":"global MymacOSFileExtension\nglobal macOS_App\nglobal macOS_DMG\nglobal macOSisFound\n\n\n---- We create a Log file. Might be useful in the future\u2026\n--\nset HomeFolder to quoted form of (do shell script \"echo $HOME\")\n\n--\nset LogPath to HomeFolder & \"\/Library\/Logs\/DiskMakerX.log\"\ntell me to do shell script \"touch \" & LogPath\ntell me to do shell script \"echo '--------------------------------------------------------------------------------' >> \" & LogPath\ntell me to do shell script \"date >> \" & LogPath\ntell me to do shell script \"echo 'Home Path: ' \" & HomeFolder & \">> \" & LogPath\n\n-- Get the language.\n\ntry\n\tset lang to do shell script \"defaults read NSGlobalDomain AppleLanguages\"\n\ttell application \"System Events\"\n\t\tset LanguageList to make new property list item with properties {text:lang}\n\t\tset MyLanguage to value of LanguageList\n\tend tell\n\tset MyLanguage to item 1 of MyLanguage\n\ttell me to do shell script \"echo 'Current Language: ' \" & MyLanguage & \">> \" & LogPath\nend try\n\nset ContinueButtonLoc to localized string of \"Continue\"\n\n-- Version of DiskMaker X\n\nset CurrentLDMVersion to \"900\"\n\nset DebugMode to false\n\nset LDMIcon to path to resource \"diskmakerx.icns\" in bundle (path to me)\n\n\n\nset CurrentOS to do shell script \"sw_vers -productVersion | cut -c 1-4\"\n\nset ShortOS to do shell script \"sw_vers -productVersion | cut -c 4-4\" as string\n\n\n-- The cut command is sometimes too short. And \"10.1\" may not run on Intel Mac so\u2026 :-)\n\nif CurrentOS is \"10.1\" then\n\tset CurrentOS to do shell script \"sw_vers -productVersion | cut -c 1-5\"\n\tset ShortOS to do shell script \"sw_vers -productVersion | cut -c 4-5\" as string\nend if\n\ntell me to do shell script \"echo 'Current OS: ' \" & CurrentOS & \">> \" & LogPath\nset ShortOS to ShortOS as integer\n\n\n\n-- Alert if running on OS smaller than 10.7\n\nif ShortOS is less than 10 then\n\tset NotmacOS106CompatibleLoc to localized string of \"Sorry! DiskMaker X won't work with your version of macOS. Upgrade to macOS 10.10 or later before using DiskMaker X.\"\n\tset QuitButtonLoc to localized string of \"Quit\"\n\tset MoreInfoButtonLoc to localized string of \"More information\"\n\tdisplay dialog NotmacOS106CompatibleLoc buttons {QuitButtonLoc, MoreInfoButtonLoc} default button 2 with icon path to resource \"diskmakerx.icns\" in bundle (path to me)\n\tset the button_pressed to the button returned of the result\n\tif button_pressed is MoreInfoButtonLoc then\n\t\topen location \"http:\/\/diskmakerx.com\/?page_id=28\"\n\telse\n\t\treturn\n\tend if\n\treturn\nend if\n\n-- Alert if running 10.7 or 10.8 : no notification will be displayed\n\nif ShortOS is \"10.7\" or ShortOS is \"10.8\" then\n\tif ShortOS is \"10.7\" then\n\t\tset macOSName to \"Mac OS X\"\n\telse\n\t\tif ShortOS is \"10.8\" then\n\t\t\tset macOSName to \"OS X\"\n\t\tend if\n\tend if\n\t\n\tset NotNotificationCompatible1Loc to localized string of \"You are currently running \"\n\tset NotNotificationCompatible2Loc to localized string of \". DiskMaker X won't be able to display notifications of current progress, but your Install disk should be built correctly.\"\n\t\n\tset NotificationDisplayed to false\n\t\n\tdisplay dialog (NotNotificationCompatible1Loc & macOSName & \" \" & ShortOS & NotNotificationCompatible2Loc) buttons ContinueButtonLoc default button 1 with icon path to resource \"diskmakerx.icns\" in bundle (path to me)\nelse\n\tset NotificationDisplayed to true\nend if\n\n\n\n\n\n\n(*************************************************\n*** Strings declarations to allow localization ********\n*************************************************)\n\n\n-- Update dialog\n\nset DialogUpdate1Loc to localized string of \"A newer version of DiskMaker X is available. Do you want to download it?\"\nset NotNowThanksLoc to localized string of \"Not now, thanks\"\nset GetNewVersionLoc to localized string of \"Get new version\"\n\n-- Welcome Dialog\n\nset WelcomeLoc to localized string of \"Welcome to DiskMaker X!\"\nset MyWhichmacOSVersion to localized string of \"Which version of macOS do you wish to make a boot disk of?\"\n\n\n-- Copy found dialog\n\nset AcopyofmacOSwasfoundinfolderLoc to localized string of \"I found a copy of the installer software in this folder:\"\nset DoyouwishtousethiscopyLoc to localized string of \"Do you wish to use this copy?\"\n\n\nset MyUseAnotherCopy to localized string of \"Use another copy\u2026\"\nset MyUseThisCopyLoc to localized string of \"Use this copy\"\n\n\n-- Some standard buttons\n\nset QuitButtonLoc to localized string of \"Quit\"\nset CancelButtonLoc to localized string of \"Cancel\"\n\n\n-- No installer found dialog\n\nset LDMDiskDetectedLoc1 to localized string of \"I detected that the following disk was already built with DiskMaker X:\"\nset LDMDiskDetectedLoc2 to localized string of \"Do you want to use it to build your new install disk ? WARNING: the disk will be completely erased!\"\n\nset MyCouldNotFoundInstallmacOSAppLoc to localized string of \"No macOS Catalina Installer application could be found. Click on Select a macOS Installation App and choose the macOS Catalina Installer application.\"\n\n\nset ChoosemacOSFileLoc to localized string of \"Select a macOS Installation App\u2026\"\nset ChoosemacOSFilePrompt1Loc to localized string of \"Select the Installation app for \"\n\n\nset MyCheckTheFaq to localized string of \"Check the FAQ\"\nset MyCreateTheUSBDrive to localized string of \"To create a boot disk, please connect a USB, FireWire disk or insert an SD-Card (16 GB minimum). Then click on Choose the disk.\"\n\nset MymacOSDiskIsReadyLoc to localized string of \"Your macOS boot disk is ready! To use it, reboot your Mac and press the Option (Alt) key, or select it in the Startup Disk preference.\"\nset MyMakeADonationLoc to localized string of \"Make a donation\"\nset MyWebSite to localized string of \"http:\/\/diskmakerx.com\/\"\nset WannaMakeADonation to localized string of \"If you enjoyed using DiskMaker X, your donations are also much appreciated.\"\nset StartupPrefLoc to localized string of \"Open Startup Disk Preference\"\n\n-- Error dialog\n\nset MyDiskCouldNotBeCreatedError to localized string of \"The disk could not be created because of an error: \"\nset MyAnErrorOccured to localized string of \"An error occured: \"\nset MyUseThisDisk to localized string of \"Use this disk\"\nset MyEraseAndCreateTheDisk to localized string of \"Erase then create the disk\"\n\n-- Kind of physical disk dialog \n\nset WhichKindOfDiskYouUseLoc to localized string of \"Which kind of disk will you use?\"\nset WhichKindOfDiskExplainationLoc to localized string of \"If you have a 16 GB USB thumb drive, it will be completely erased. If you choose another kind of disk, ONLY the chosen volume will be erased. Your other disks and volumes will be left untouched.\"\nset ProTipLoc to localized string of \"PRO TIP: If you wish to build a multi-installations disk, use Another kind of disk each time, and choose a different partition for each OS you want to make a boot disk for!\"\nset WhichKindOfDiskIsUSB8GBLoc to localized string of \"A 16 GB USB thumb drive (ERASE ALL DISK)\"\nset WhichKindOfDiskIsAnyOtherDiskLoc to localized string of \"Another kind of disk (erase only partition)\"\n\n\n-- Last alert dialog\n\nset LastAlertMessageLocVolume to localized string of \"WARNING ! THE WHOLE CONTENTS OF THIS VOLUME WILL BE ERASED!\"\nset LastAlertMessageLocDisc to localized string of \"WARNING: THE WHOLE CONTENT OF THE DISK (AND EVERY OTHER VOLUME OF THIS DISK) WILL BE ERASED!\"\nset LastAlertPart1Loc to localized string of \"You are about to erase the volume : \"\nset LastAlertPart2Loc to localized string of \"If you continue, all the data on it will be lost. Are you sure you want to do this ?\"\nset LastAlertPart3Loc to localized string of \"The following volumes are on the same disk and will be erased:\"\n\n-- Alert for Mavericks\n\nset AdminAlertLoc to localized string of \"You will be required to type your login and password soon.\"\n\nset AdminAlertTitleLoc to localized string of \"The next step will ask for administrator privileges to build the install disk, so please type your administrator login and password when necessary.\"\n\n\n-- Can't use this disk dialog\n\nset MyNotTheCorrectmacOSFileLoc to localized string of \"This file can't be used to create an OS X Installation disk.\"\n\n-- Can't eject disk Dialog\n\nset CantEjectDiskLoc to localized string of \"Sorry, I can't eject the following volume :\"\nset PleaseEjectAgainLoc to localized string of \"Please eject it and try again.\"\n\n-- Disk selection dialog\n\nset HereAreTheDisksLoc to localized string of \"Here are the disks you may want to use to create your boot disk\"\nset ChooseDiskToErase to localized string of \"Please choose the disk you wish to erase\"\nset ChooseThisDiskLoc to localized string of \"Choose this disk\"\n\n\n-- Miscellanous localizations\n\nset MyCantUseThisDisk to localized string of \"This disk can't be used because it is not a removable disk.\"\nset ChooseDiskToEraseLoc to localized string of \"Please choose the disk you wish to erase\"\n\n\n-- No disk available alert\n\nset NoDiskAvailableLoc to localized string of \"Sorry, I can't find a disk to use\u2026 Please plug a disk, then relaunch DiskMaker X.\"\n\n-- Icon Error Management\n\nset IconError1Loc to localized string of \"Sorry, I could not get the icon to personnalize the disk. Don't worry, your macOS disk will work fine.\"\nset IconError2Loc to localized string of \"I will leave a copy of the compressed icon named \"\nset IconError3Loc to localized string of \".zip on your Desktop so that you can still personnalize the disk yourself.\"\nset IconError4Loc to localized string of \"Check the FAQ on the web site for more info.\"\n\n\n\n\nset AlreadyALDMDiskLoc to localized string of \"The following volume has already been used as a bootable install disk. Do you want DiskMaker X to use it ? Its content will be completely erased.\"\nset AlreadyALDMDiskConfirmLoc to localized string of \"Update this volume\"\nset AlreadyALDMDiskCancelLoc to localized string of \"Use another volume\"\n\nset CopyingFilesLoc to localized string of \"Copying files\u2026\"\n\nset MyPaypalLoc to localized string of \"http:\/\/diskmakerx.com\/donations\/\"\n\nset MoreInfoButtonLoc to localized string of \"More information\"\nset DMGIncompleteLoc to localized string of \"Sorry, your macOS Install app may be incomplete. Delete your install application, then download it again from the App Store.\"\n\n\nset OpenAppStoreLoc to localized string of \"Open App Store\"\n\nset DarkModeBackgroundDialogLoc to localized string of \"Last question: would you rather go dark?\"\nset GoDarkLoc to localized string of \"I want to come to the Dark side!\"\nset GoLightLoc to localized string of \"I'm more in a light mood.\"\n\n-- Path to sound resource\n\nset SoundPath to ((path to resource \"Roar.mp3\"))\n\nset MySupportSite to \"http:\/\/diskmakerx.com\/faq\/\"\n\n-- We check if the application is running in an admin session. If not, it's not necessary to go further\u2026\n\nset YouAreNotAdminLoc to localized string of \"Sorry, DiskMaker X requires to be run in an admin session. Please switch to an admin session, then launch DiskMaker X again.\"\n\nset imadmin to \"80\" is in (do shell script \"id -G\")\n\ntell me to do shell script \"echo 'Is this user an admin : ' \" & imadmin & \">> \" & LogPath\n\n\nif imadmin is false then\n\tdisplay dialog YouAreNotAdminLoc buttons QuitButtonLoc default button 1\n\treturn\nend if\n\n\n-- Check for Path Finder presence. It's not recommended to use it when using DiskMaker X.\n\nset PathFinderOpenLoc to localized string of \"Sorry, DiskMaker X is not compatible with Path Finder. Please quit Path Finder, relaunch the Finder if necessary, then run DiskMaker X again.\"\n\nset PathFinderLaunched to \"Path Finder\" is in (do shell script \" ps auxc\")\ntell me to do shell script \"echo 'Path Finder launched : ' \" & PathFinderLaunched & \">> \" & LogPath\n\nif PathFinderLaunched is true then\n\tdisplay dialog PathFinderOpenLoc buttons QuitButtonLoc default button 1\n\t\n\treturn\nend if\n\n\n-- Check if a new version is available.\n\ntry\n\twith timeout of 3 seconds\n\t\tset LatestDMXVersion to do shell script \"curl http:\/\/diskmakerx.com\/CurrentLDMVersion\" as string\n\t\tif LatestDMXVersion is greater than CurrentLDMVersion then\n\t\t\t\n\t\t\tdisplay dialog DialogUpdate1Loc buttons {QuitButtonLoc, NotNowThanksLoc, GetNewVersionLoc} default button 3\n\t\t\t\n\t\t\tset ResultButton to the button returned of the result\n\t\t\t\n\t\t\tif ResultButton is GetNewVersionLoc then\n\t\t\t\topen location MyWebSite\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\tif ResultButton is QuitButtonLoc then\n\t\t\t\t\treturn\n\t\t\t\tend if\n\t\t\tend if\n\t\tend if\n\tend timeout\nend try\n\n\n\n-- First, we ask which OS we want to deal with so that we can declare a few variables.\n\n\n\n\nset First_DMG_Volume to \"OS X Install ESD\"\nset Second_DMG_Volume to \"OS X Base System\"\n\n\n\n-- Variables for macOS 10.15 Catalina\n\nset macOSVersion to \"10.15\"\nset OSFileName to \"Install macOS Catalina\"\nset IconName to \"Catalina.icns\"\nset DiskIconName to \"CatalinaIcon1024\"\nset FinalDiskName to \"macOS Catalina Install Disk\"\nset InstallDiskNameLoc to localized string of \"macOS Catalina 10.15 Install\"\nset CreateInstallMediaDiskName to \"Install macOS Catalina\"\nset DarkBackground to \"DarkCatalinaBackground.jpg\"\nset LightBackground to \"LightCatalinaBackground.jpg\"\n\n\ntell me to do shell script \"echo 'Selected OS: ' \" & macOSVersion & \">> \" & LogPath\n\n-- First I check if I can find the install app in the Applications folder.\n-- I will use Spotlight only if it does not exist here.\n\nset macOSisFound to \"Not found yet\"\n\ntell application \"System Events\"\n\tif exists file (\"\/Applications\/\" & OSFileName & \".app\/Contents\/SharedSupport\/InstallESD.dmg\") then\n\t\tset macOS_DMG to \"'\/Applications\/\" & OSFileName & \".app\/Contents\/SharedSupport\/InstallESD.dmg'\"\n\t\t\n\t\t\n\t\tset macOS_App to quoted form of \"\/Applications\/Install macOS Catalina Beta.app\"\n\t\t\n\t\tset macOSisFound to \"Found\"\n\t\t\n\t\t\n\t\ttell me to do shell script \"echo 'Install App Path: ' \" & macOS_App & \">> \" & LogPath\n\t\t\n\t\t\n\t\tdisplay dialog (AcopyofmacOSwasfoundinfolderLoc & return & return & \"\/Applications\" & return & return & DoyouwishtousethiscopyLoc) buttons {CancelButtonLoc, MyUseAnotherCopy, MyUseThisCopyLoc} default button 3 with icon path to resource IconName in bundle (path to me)\n\t\tset the button_pressed to the button returned of the result\n\t\t\n\t\t-- If it's not the right app, you may want to choose another app.\n\t\t\n\t\tif the button_pressed is MyUseThisCopyLoc then\n\t\t\t\n\t\t\tset macOS_DMG to quoted form of (\"\/Applications\/\" & OSFileName & \".app\/Contents\/SharedSupport\/InstallESD.dmg\")\n\t\t\tset macOSisFound to \"Found\"\n\t\t\tset macOS_App to quoted form of (\"\/Applications\/\" & OSFileName & \".app\")\n\t\telse\n\t\t\tif the button_pressed is MyUseAnotherCopy then\n\t\t\t\t\n\t\t\t\tmy theChoiceOfAnotherCopy(ChoosemacOSFilePrompt1Loc, OSFileName, MyNotTheCorrectmacOSFileLoc, CancelButtonLoc, LogPath)\n\t\t\t\t\n\t\t\tend if\n\t\t\t\n\t\t\tif the button_pressed is CancelButtonLoc then\n\t\t\t\treturn\n\t\t\tend if\n\t\tend if\n\tend if\nend tell\n\n\n-- If we can't find in \/Applications, then we use Spotlight\n\nif macOSisFound is \"Not found yet\" then\n\t\n\tset OSSearch to (do shell script \"mdfind -name '\" & OSFileName & \"' | grep -v Library | head -1\")\n\tset OSSearchResultNumber to (do shell script \"echo \" & quoted form of OSSearch & \" | wc -l \") as integer\n\t\n\t\n\tif OSSearch is not \"\" then\n\t\t\n\t\tset macOSFolder to OSSearch\n\t\tdisplay dialog (AcopyofmacOSwasfoundinfolderLoc & return & return & macOSFolder & return & return & DoyouwishtousethiscopyLoc) buttons {CancelButtonLoc, MyUseAnotherCopy, MyUseThisCopyLoc} default button 3 with icon path to resource IconName in bundle (path to me)\n\t\tset the button_pressed to the button returned of the result\n\t\t\n\t\tif the button_pressed is MyUseThisCopyLoc then\n\t\t\t\n\t\t\tset macOS_App to quoted form of (POSIX path of macOSFolder)\n\t\t\tset macOS_DMG to quoted form of ((POSIX path of macOSFolder) & \"\/Contents\/SharedSupport\/InstallESD.dmg\")\n\t\t\t\n\t\t\t\n\t\telse\n\t\t\tif the button_pressed is MyUseAnotherCopy then\n\t\t\t\t\n\t\t\t\tmy theChoiceOfAnotherCopy(ChoosemacOSFilePrompt1Loc, OSFileName, MyNotTheCorrectmacOSFileLoc, CancelButtonLoc, LogPath)\n\t\t\tend if\n\t\t\t\n\t\t\tif the button_pressed is CancelButtonLoc then\n\t\t\t\treturn\n\t\t\tend if\n\t\t\t\n\t\tend if\n\t\t\n\telse\n\t\tdisplay dialog MyCouldNotFoundInstallmacOSAppLoc buttons {CancelButtonLoc, MyCheckTheFaq, ChoosemacOSFileLoc} default button 3 with icon caution\n\t\t\n\t\tset the button_pressed to the button returned of the result\n\t\t\n\t\tif the button_pressed is MyCheckTheFaq then\n\t\t\topen location MyWebSite\n\t\t\treturn\n\t\telse\n\t\t\tif the button_pressed is ChoosemacOSFileLoc then\n\t\t\t\t\n\t\t\t\tmy theChoiceOfAnotherCopy(ChoosemacOSFilePrompt1Loc, OSFileName, MyNotTheCorrectmacOSFileLoc, CancelButtonLoc, LogPath)\n\t\t\t\t\n\t\t\tend if\n\t\t\t\n\t\tend if\n\t\t\n\tend if\nend if\n\n(************************************************************************************************)\n\n(*** We empirically test the size of the Install App's dmg, to be sure there's not an issue with it.\nCurrently the size of the installer for macOS Catalina is more than 7 GB.\n***)\n\n\n\nset InstallESD_DMG_Size to (do shell script \"ls -la \" & macOS_App & \"\/Contents\/SharedSupport\/InstallESD.dmg | awk '{ print $5 }'\") as integer\n\nif InstallESD_DMG_Size is less than 7.0E+9 then\n\tactivate\n\tdisplay dialog (DMGIncompleteLoc & return & return) buttons {MoreInfoButtonLoc} default button 1 with icon path to resource IconName in bundle (path to me)\n\tset the button_pressed to the button returned of the result\n\topen location MySupportSite\n\treturn\nend if\n\n\n\n(********************* Creating a bootable disc ***************************)\n\n\n-- New routine checks if a file exists with a .LionDiskMaker_OSVersion hidden file at root. \n\ntell application \"Finder\"\n\tset DontEraseTheDisk to false\n\tset LDMAlreadyThere to false\n\t\n\tset TheNumberOfEjectableDisks to the number of (every disk whose (ejectable is true))\n\t\n\ttry\n\t\tset TheEjectableDiskList to the name of (every disk whose (ejectable is true))\n\ton error\n\t\tdisplay dialog NoDiskAvailableLoc buttons QuitButtonLoc default button 1\n\t\treturn\n\t\t\n\tend try\n\tset n to 1\n\t\n\trepeat with loopVar from n to TheNumberOfEjectableDisks\n\t\tset MyDisk to (item n of TheEjectableDiskList)\n\t\tset HiddenFileToFind to \"\/Volumes\/\" & MyDisk & \"\/.LionDiskMaker_OSVersion\" as string\n\t\tif exists HiddenFileToFind as POSIX file then\n\t\t\tset LDMAlreadyThere to true\n\t\t\t\n\t\t\ttell me to do shell script \"echo 'Another DiskMaker X disk found: true' >> \" & LogPath\n\t\t\tset NewVolumeName to MyDisk\n\t\t\t\n\t\t\ttell me to do shell script \"echo 'Previous DiskMaker X disk name found: ' \" & MyDisk & \">> \" & LogPath\n\t\t\t\n\t\t\tset AlreadyLDMDisk to MyDisk\n\t\t\tset MyErasefullDisc to false\n\t\tend if\n\t\t\n\t\tset n to n + 1\n\tend repeat\nend tell\n\nif LDMAlreadyThere is true then\n\tactivate\n\tdisplay dialog LDMDiskDetectedLoc1 & return & return & AlreadyLDMDisk & return & return & LDMDiskDetectedLoc2 & return buttons {AlreadyALDMDiskCancelLoc, AlreadyALDMDiskConfirmLoc} default button 2 with icon path to resource IconName in bundle (path to me)\n\tset the button_pressed to the button returned of the result\n\tif the button_pressed is AlreadyALDMDiskConfirmLoc then\n\t\tset MyTargetDisk to AlreadyLDMDisk\n\t\tset MyTargetDiskPath to the quoted form of (POSIX path of MyTargetDisk)\n\t\ttell me to do shell script \"echo 'Path to target: ' \" & MyTargetDiskPath & \">> \" & LogPath\n\telse\n\t\tset LDMAlreadyThere to false\n\t\tset MyErasefullDisc to false\n\tend if\nend if\n\n\nif LDMAlreadyThere is false then\n\t-- We have to know if the selected disk is a 16 GB thumbnail disk or something else to choose the proper way to erase the disk.\n\tactivate\n\tdisplay alert WhichKindOfDiskYouUseLoc message WhichKindOfDiskExplainationLoc & return & return & ProTipLoc & return & return buttons {CancelButtonLoc, WhichKindOfDiskIsAnyOtherDiskLoc, WhichKindOfDiskIsUSB8GBLoc} default button 3 as critical\n\tset the button_pressed to the button returned of the result\n\tif the button_pressed is WhichKindOfDiskIsUSB8GBLoc then\n\t\tset MyErasefullDisc to true\n\t\t\n\telse\n\t\tif the button_pressed is WhichKindOfDiskIsAnyOtherDiskLoc then\n\t\t\tset MyErasefullDisc to false\n\t\telse\n\t\t\treturn\n\t\tend if\n\tend if\n\t\n\ttell me to do shell script \"echo 'Erase Full Disk: ' \" & MyErasefullDisc & \">> \" & LogPath\n\t\n\t-- We have to define the list of disks available for use.\n\t\n\t\n\ttell application \"Finder\"\n\t\tif MyErasefullDisc is true then\n\t\t\ttell me to do shell script \"echo 'Erase full Disk: True' >> \" & LogPath\n\t\t\ttry\n\t\t\t\tset ListOfDisks to the name of (every disk whose (ejectable is true) and (capacity is less than 1.45E+11))\n\t\t\ton error\n\t\t\t\tdisplay dialog NoDiskAvailableLoc buttons {QuitButtonLoc} default button 1 with icon path to resource IconName in bundle (path to me)\n\t\t\t\treturn\n\t\t\tend try\n\t\t\tset LastAlertMessageLoc to LastAlertMessageLocDisc\n\t\telse\n\t\t\ttry\n\t\t\t\ttell me to do shell script \"echo 'Current OS: ' \" & CurrentOS & \">> \" & LogPath\n\t\t\t\t\n\t\t\t\tset ListOfDisks to the name of (every disk whose (ejectable is true))\n\t\t\t\t\n\t\t\ton error\n\t\t\t\tdisplay dialog NoDiskAvailableLoc buttons {QuitButtonLoc} default button 1 with icon path to resource IconName in bundle (path to me)\n\t\t\t\treturn\n\t\t\tend try\n\t\t\tset LastAlertMessageLoc to LastAlertMessageLocVolume\n\t\tend if\n\tend tell\n\t\n\tset MyTargetDisk to choose from list ListOfDisks with prompt HereAreTheDisksLoc with title ChooseDiskToEraseLoc cancel button name CancelButtonLoc OK button name ChooseThisDiskLoc default items 1 without multiple selections allowed and empty selection allowed\n\tif MyTargetDisk is not false then\n\t\tset MyTargetDiskPath to the quoted form of (POSIX path of MyTargetDisk)\n\telse\n\t\tdisplay dialog NoDiskAvailableLoc buttons {QuitButtonLoc} default button 1 with icon path to resource IconName in bundle (path to me)\n\t\t\n\t\treturn\n\tend if\n\t\n\t-- We get all the volumes which are part of the same disk as our target volume. Just to let the user know\u2026 \n\t\n\tset FullDiskName to last word of (do shell script \"diskutil info \/Volumes\/\" & quoted form of (MyTargetDisk as string) & \" | grep 'Part of Whole'\")\n\t\n\t-- And we get the full size of the disk. Necessary a bit later.\n\t-- thanks @lolopb who managed to find a way to workaround a bad limitation with diskutil in 10.6\u2026\n\t\n\tif MyErasefullDisc is true then\n\t\ttry\n\t\t\tset FullListOfDisks to do shell script \"for (( i = 2; i <= $(diskutil list \" & FullDiskName & \" | tail -n 1 | cut -c 75-76); i++)); do diskutil info \" & FullDiskName & \"s$i | grep \\\"Volume Name: \\\" | cut -c 30-75; done | grep -v 'Recovery HD'\"\n\t\t\t\n\t\t\ttell me to do shell script \"echo 'List of volumes on same disk : ' \" & FullListOfDisks & \">> \" & LogPath\n\t\t\t\n\t\t\t\n\t\ton error errMsg number errNum\n\t\t\tset FullListOfDisks to \"\"\n\t\t\tset LastAlertPart2Loc to \"\"\n\t\t\tset LastAlertPart3Loc to \"\"\n\t\tend try\n\telse\n\t\tset FullListOfDisks to \"\"\n\t\tset LastAlertPart3Loc to \"\"\n\tend if\n\t\n\t-- Last Warning !!!\tThere's no turning back from here.\n\t\n\tdisplay alert LastAlertMessageLoc message LastAlertPart1Loc & return & return & MyTargetDisk & return & return & LastAlertPart2Loc & return & LastAlertPart3Loc & return & return & FullListOfDisks buttons {CancelButtonLoc, MyEraseAndCreateTheDisk} default button 2 as warning\n\t\n\tset the button_pressed to the button returned of the result\n\tif the button_pressed is CancelButtonLoc then\n\t\treturn\n\tend if\nend if\n\n\n\n-- Choose your Background picture. Absolutely, completely useless, so completely unmissable.\n\nset DarkModeBackgroundDialogLoc to localized string of \"Last question: would you rather go dark?\"\nset GoDarkLoc to localized string of \"I want to come to the Dark side!\"\nset GoLightLoc to localized string of \"I'm more in a light mood.\"\n\n\ndisplay dialog DarkModeBackgroundDialogLoc buttons {GoLightLoc, GoDarkLoc} default button 1 with icon path to resource IconName in bundle (path to me)\nset the button_pressed to the button returned of the result\nif the button_pressed is GoDarkLoc then\n\tset macOSBackground to DarkBackground\nelse\n\tset macOSBackground to LightBackground\nend if\n\n\n\ndisplay alert AdminAlertTitleLoc message AdminAlertLoc buttons {CancelButtonLoc, ContinueButtonLoc} default button 2 as warning\n\n\n-- Disk creations begins ! --\n\n\n\n-- We use uuidgen to warrant a unique name to the disk (avoiding to erase other drives in the process\u2026)\nif DontEraseTheDisk is false then\n\t\n\tset NewVolumeName to (do shell script \"uuidgen\")\n\t\n\t-- To avoid errors, we check that the disk is really ejectable.\n\t\n\tset IsEjectable to do shell script \"diskutil info \" & MyTargetDiskPath & \" | grep -i \\\"Ejectable\\\" | awk '{ print $2}' \"\n\tif IsEjectable is \"No\" then\n\t\t\n\t\ttell me to do shell script \"echo 'No ejectable disk !'>> \" & LogPath\n\t\t\n\t\tdisplay dialog MyCantUseThisDisk with icon stop\n\t\t\n\telse\n\t\t\n\t\t\n\t\t-- ADD LOCALIZATION HERE\n\t\t\n\t\tdisplay notification \"Erasing drive \" & MyTargetDiskPath & \"\u2026\"\n\t\t\n\t\t\n\t\tif MyErasefullDisc is true then\n\t\t\ttell me to do shell script \"echo 'Target Disk Path: ' \" & MyTargetDiskPath & \">> \" & LogPath\n\t\t\ttell me to do shell script \"echo 'New Volume Name: ' \" & NewVolumeName & \">> \" & LogPath\n\t\t\t\n\t\t\ttell me to do shell script \"diskutil partitionDisk $(diskutil info \" & MyTargetDiskPath & \" | grep -i \\\"Part Of Whole\\\" | awk '{ print $4}') 1 GPT jhfs+ \" & NewVolumeName & \" R\"\n\t\telse\n\t\t\ttell me to do shell script \"diskutil eraseVolume JHFS+ \" & NewVolumeName & \" \" & MyTargetDiskPath\n\t\tend if\n\t\t\n\tend if\nend if\n\n-- sometimes the volume is not mounted yet while the copy begins. We need to delay a bit...\n\ndelay 2\n\n\nwith timeout of 9999 seconds\n\t\n\t-- First, we unmount any occurence of the Base System and the OS X Install ESD disk. Just in case.\n\t\n\ttry\n\t\ttell me to do shell script \"hdiutil detach -force '\/Volumes\/\" & Second_DMG_Volume & \"'\"\n\t\tdelay 2\n\tend try\n\t\n\ttry\n\t\ttell me to do shell script \"hdiutil detach -force '\/Volumes\/\" & First_DMG_Volume & \"'\"\n\t\tdelay 2\n\tend try\n\t\n\t\n\ttell application \"Finder\"\n\t\topen disk NewVolumeName\n\t\t\n\t\t-- Total Finder can prevent the modification of windows, so this piece of code will not run if it is running . Thanks to Dj Padzenzky for this part.\n\t\ttry\n\t\t\t\u00abevent BATFchck\u00bb\n\t\ton error\n\t\t\tset bounds of Finder window 1 to {1, 44, 503, 493}\n\t\t\tset sidebar width of Finder window 1 to 0\n\t\t\tset statusbar visible of Finder window 1 to true\n\t\t\tset current view of Finder window 1 to icon view\n\t\tend try\n\t\t\n\t\t\n\tend tell\n\t(*********************************************************************************************************************************)\n\t\n\t\n\tdelay 1\n\t\n\t-- ADD LOCALIZATION HERE\n\t\n\tdisplay notification \"Restoring macOS on \" & NewVolumeName & \"\u2026\"\n\t\n\t-- We get the size of the InstallESD.dmg file as it takes the longest time to copy\n\t\n\tset InstallESD_DMG_Size to do shell script \"ls -la \" & macOS_App & \"\/Contents\/SharedSupport\/InstallESD.dmg | awk '{ print $5 }'\"\n\t\n\t\n\ttell me to do shell script \"sudo \" & macOS_App & \"\/Contents\/Resources\/createinstallmedia --volume \/Volumes\/\" & NewVolumeName & \" --nointeraction &> \/tmp\/createinstallmedia.log &\" with administrator privileges\n\ttell me to do shell script \"echo 'OS X App path: ' \" & macOS_App & \">> \" & LogPath\n\ttell me to do shell script \"echo 'New Volume Name: ' \" & NewVolumeName & \">> \" & LogPath\n\t\n\t-- We reset the counter which will be used to display notifications \n\t\n\tdisplay notification \"Now preparing your disk !\" subtitle \"We'll notify you of current progress\u2026\"\n\t\n\t\n\tdelay 10\n\tset myPreviousPercentage to 0\n\t\n\t\n\t\n\trepeat with i from 1 to 9999999\n\t\t\n\t\tset CreateInstallMediaStatus to (do shell script \"ps auxc | grep createinstallmedia | wc -l | awk '{ print $1 }'\")\n\t\tset CreateInstallMediaLog to (do shell script \"tail -n 1 \/tmp\/createinstallmedia.log\")\n\t\tset CheckIfDiskIsErased to (do shell script \"tail -n 1 \/tmp\/createinstallmedia.log | grep '100%' | wc -l | cut -c 8\")\n\t\t\n\t\t\n\t\tdelay 5\n\t\t\n\t\t\n\t\tif CheckIfDiskIsErased is \"1\" then\n\t\t\tset CreateInstallMediaLog to CopyingFilesLoc\n\t\tend if\n\t\t\n\t\t\n\t\t-- We check the current size of InstallESD.dmg\n\t\ttry\n\t\t\tset CurrentInstallESD_DMG_Size to do shell script \"ls -la '\/Volumes\/\" & CreateInstallMediaDiskName & \"\/\" & OSFileName & \".app\/Contents\/SharedSupport\/InstallESD.dmg' | awk '{ print $5 }'\"\n\t\t\tif CurrentInstallESD_DMG_Size is not \"\" then\n\t\t\t\tset InstallESDPercentage to (CurrentInstallESD_DMG_Size \/ InstallESD_DMG_Size) * 100 as integer\n\t\t\t\t\n\t\t\t\tif ((InstallESDPercentage mod 5) is 0) and (InstallESDPercentage > myPreviousPercentage) then\n\t\t\t\t\tif InstallESDPercentage = 100 then\n\t\t\t\t\t\tdisplay notification \"Copy is done.\" subtitle \"Percentage complete: \" & InstallESDPercentage & \"%\"\n\t\t\t\t\telse\n\t\t\t\t\t\tdisplay notification \"Now copying data\u2026 Please wait.\" subtitle \"Percentage complete: \" & InstallESDPercentage & \"%\"\n\t\t\t\t\tend if\n\t\t\t\t\t\n\t\t\t\t\tdelay 5\n\t\t\t\t\tset myPreviousPercentage to InstallESDPercentage\n\t\t\t\tend if\n\t\t\tend if\n\t\tend try\n\t\t\n\t\t\n\t\t-- Is createinstallmedia still running ?\n\t\t\n\t\tif CreateInstallMediaStatus is \"0\" then\n\t\t\texit repeat\n\t\t\t\n\t\tend if\n\t\t\n\tend repeat\n\t\n\t\n\t\n\t\n\t\n\t----------- Mounting the DMG files -----------\n\t\n\t-- ADD LOCALIZATION HERE\n\t\n\t\n\ttry\n\t\t\n\t\t-- We get the version number. We will use it to rename the USB disk properly later.\n\t\t-- And YES, OS name is hardcoded because escaping this stuff is just boring.\n\t\t\n\t\tset macOSImageVersion to do shell script \"defaults read '\/Volumes\/Install macOS Catalina Beta\/Install macOS Catalina Beta.app\/Contents\/SharedSupport\/InstallInfo.plist' \\\"System Image Info\\\" | grep version | awk '{ print $3 }' | tr -d '\\\"' | tr -d ';' \"\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tset QuoteCreateInstallMediaDiskName to quoted form of CreateInstallMediaDiskName\n\t\t\n\t\t-- This fixes a bug where the Install Disk was not visible in Startup Disk system Preference. Thanks to Eric Knibbe (@EricFromCanada) for the fix !\n\t\ttry\n\t\t\ttell me to do shell script \"touch \/Volumes\/\" & QuoteCreateInstallMediaDiskName & \"\/mach_kernel\"\n\t\t\ttell me to do shell script \"chflags hidden \/Volumes\/\" & QuoteCreateInstallMediaDiskName & \"\/mach_kernel\"\n\t\tend try\n\t\t\n\t\ttell application \"Finder\"\n\t\t\ttry\n\t\t\t\tset position of alias (CreateInstallMediaDiskName & \":\" & OSFileName & \".app\") to {693, 165}\n\t\t\tend try\n\t\t\topen disk CreateInstallMediaDiskName\n\t\t\tclose front window\n\t\t\topen disk CreateInstallMediaDiskName\n\t\t\tset icon size of icon view options of front window to 128\n\t\t\ttry\n\t\t\t\tset sidebar width of front window to 0\n\t\t\tend try\n\t\t\tset bounds of front window to {5, 5, 815, 455}\n\t\t\t\n\t\tend tell\n\t\t\n\t\t\n\t\t\n\t\t-- Apply background\n\t\t\n\t\ttry\n\t\t\tset BackgroundImage to path to resource macOSBackground in bundle (path to me)\n\t\t\tset BackgroundImagePath to quoted form of (POSIX path of BackgroundImage)\n\t\t\t\n\t\t\ttell me to do shell script \"cp \" & BackgroundImagePath & \" '\/Volumes\/\" & CreateInstallMediaDiskName & \"'\"\n\t\t\t\n\t\tend try\n\t\t\n\t\ttell application \"Finder\"\n\t\t\tactivate\n\t\t\topen disk CreateInstallMediaDiskName\n\t\t\ttry\n\t\t\t\tset background picture of icon view options of front window to file macOSBackground of disk CreateInstallMediaDiskName\n\t\t\tend try\n\t\tend tell\n\t\t\n\t\ttry\n\t\t\ttell me to do shell script \"chflags hidden '\/Volumes\/\" & CreateInstallMediaDiskName & \"\/\" & macOSBackground & \"'\"\n\t\tend try\n\t\t\n\t\t\n\t\t-- We need to close and re-open the window to refresh position of icons. Known bug. Oh well\u2026\n\t\t\n\t\ttell application \"Finder\"\n\t\t\tclose front window\n\t\t\tdelay 1\n\t\t\topen disk CreateInstallMediaDiskName\n\t\tend tell\n\t\t\n\ton error the error_message number the error_number\n\t\tset the error_text to MyAnErrorOccured & the error_number & \". \" & the error_message\n\t\tdisplay dialog MyDiskCouldNotBeCreatedError & error_text\n\t\treturn\n\tend try\n\t\n\t-------------------------------------------------------------------------------------------\n\t-- Don't forget the custom icon ! \t\t\t\t\t\t\t\t\t--\n\t-------------------------------------------------------------------------------------------\n\t\n\t-- We copy the icon in the \/tmp folder, otherwise AppleScript will complain that it won't be able to access the icon file inside the bundle. Oh well.\n\t\n\twith timeout of 9999 seconds\n\t\t\n\t\tset ZipIconPath to quoted form of ((POSIX path of (path to me) & \"Contents\/Resources\/\" & DiskIconName & \".zip\"))\n\t\t\n\t\ttry\n\t\t\ttell me to do shell script \"cp \" & ZipIconPath & \" \/tmp\/\"\n\t\tend try\n\t\t\n\t\t-- We could have used gzip or another command, but this was the only way to preserve the icon file on the picture.\n\t\t\n\t\tif ShortOS is greater than 9 then\n\t\t\ttell me to do shell script \"open -a '\/System\/Library\/CoreServices\/Applications\/Archive Utility.app' \/private\/tmp\/\" & DiskIconName & \".zip\"\n\t\telse\n\t\t\ttell me to do shell script \"open -a '\/System\/Library\/CoreServices\/Archive Utility.app' \/private\/tmp\/\" & DiskIconName & \".zip\"\n\t\tend if\n\t\t\n\t\tdelay 2\n\t\t\n\t\ttry\n\t\t\ttell me to do shell script \"killall -9 'Archive Utility'\"\n\t\tend try\n\t\t\n\t\t-- We had to add some delay because SSDs may be too fast and not provide time to copy and paste the icon.\n\t\t\n\t\tdelay 3\n\t\t\n\t\ttry\n\t\t\ttell application \"Finder\"\n\t\t\t\tactivate\n\t\t\t\t\n\t\t\t\topen information window of file (\"private:tmp:\" & DiskIconName & \".png\") of startup disk\n\t\t\t\t\n\t\t\tend tell\n\t\t\t\n\t\t\t\n\t\t\ttell application \"System Events\"\n\t\t\t\ttell application process \"Finder\"\n\t\t\t\t\ttell front window\n\t\t\t\t\t\tkeystroke tab\n\t\t\t\t\t\tdelay 1\n\t\t\t\t\t\tkeystroke \"c\" using command down\n\t\t\t\t\t\tkeystroke \"w\" using command down\n\t\t\t\t\tend tell\n\t\t\t\tend tell\n\t\t\tend tell\n\t\t\tdelay 1\n\t\t\t\n\t\t\ttell application \"Finder\"\n\t\t\t\topen information window of disk CreateInstallMediaDiskName\n\t\t\tend tell\n\t\t\t\n\t\t\ttell application \"System Events\"\n\t\t\t\ttell application process \"Finder\"\n\t\t\t\t\ttell front window\n\t\t\t\t\t\tdelay 1\n\t\t\t\t\t\tkeystroke tab\n\t\t\t\t\t\tdelay 1\n\t\t\t\t\t\tkeystroke \"v\" using command down\n\t\t\t\t\t\tdelay 2\n\t\t\t\t\t\t\n\t\t\t\t\t\tkeystroke \"w\" using command down\n\t\t\t\t\tend tell\n\t\t\t\tend tell\n\t\t\tend tell\n\t\t\t\n\t\t\t\n\t\t\t-- Too many icons errors with third-party utilities with decompression tools. In this case, we'll just leave the icon file on the Desktop.\n\t\t\t\n\t\ton error\n\t\t\tdisplay dialog IconError1Loc & return & IconError2Loc & DiskIconName & IconError3Loc & return & return & IconError4Loc buttons ContinueButtonLoc\n\t\t\ttell me to do shell script \"cp \" & ZipIconPath & \" ~\/Desktop\"\n\t\t\t\n\t\tend try\n\t\t\n\t\ttell application \"Finder\"\n\t\t\ttry\n\t\t\t\tclose window \"tmp\"\n\t\t\tend try\n\t\t\t\n\t\t\t-- We personnalize the disk name with OS version now\n\t\t\t\n\t\t\ttry\n\t\t\t\tset CompleteDiskName to (InstallDiskNameLoc & \" - \" & macOSImageVersion)\n\t\t\t\tset name of disk CreateInstallMediaDiskName to CompleteDiskName\n\t\t\tend try\n\t\tend tell\n\t\t\n\t\t\n\t\t-- Let's delete the temporary icon.\n\t\t--\n\t\ttry\n\t\t\ttell me to do shell script \"rm -f \/tmp\/\" & DiskIconName & \".png\"\n\t\t\ttell me to do shell script \"rm -f \/tmp\/\" & DiskIconName & \".zip\"\n\t\tend try\n\t\t\n\t\t-- We create an invisible file with OS Version in it. Useful to re-use the disk rapidly.\n\t\t\n\t\ttell me to do shell script \"echo \" & macOSImageVersion & \" &> \" & quoted form of (\"\/Volumes\/\" & CompleteDiskName) & \"\/.LionDiskMaker_OSVersion\"\n\t\t\n\t\t\n\t\t\n\tend timeout\n\t\n\t(********************************************************************\n\t\t\t********************* VICTORY ! ******************** \n\t\t\t********************************************************************)\n\t\n\t\n\twith timeout of 9999 seconds\n\t\t\n\t\t\n\t\t-- Roar ! :)\n\t\t\n\t\t\n\t\ttry\n\t\t\ttell me to do shell script (\"afplay \" & (quoted form of POSIX path of SoundPath))\n\t\t\ttell me to do shell script \"echo 'Roar !'>> \" & LogPath\n\t\t\t\n\t\tend try\n\t\t\n\t\t\n\t\t\n\t\t-- Display final dialog\n\t\ttry\n\t\t\ttell me to activate\n\t\tend try\n\t\t\n\t\tdisplay dialog MymacOSDiskIsReadyLoc & return & return & WannaMakeADonation buttons {QuitButtonLoc, StartupPrefLoc, MyMakeADonationLoc} default button 3 with icon path to resource IconName in bundle (path to me)\n\t\tset the button_pressed to the button returned of the result\n\t\tif the button_pressed is MyMakeADonationLoc then\n\t\t\topen location MyPaypalLoc\n\t\t\treturn\n\t\telse\n\t\t\tif the button_pressed is StartupPrefLoc then\n\t\t\t\ttell me to do shell script \"open '\/System\/Library\/PreferencePanes\/StartupDisk.prefPane'\"\n\t\t\tend if\n\t\tend if\n\t\t\n\tend timeout\n\t\nend timeout\n\n-- End of the choice of method to create the disk --\n\n\n\n---------------------------------------------------------------------------------------\n------------------------------------- HANDLERS ------------------------------------\n---------------------------------------------------------------------------------------\n\n\n-- RemoveTheCrubs Handler\n\non RemoveTheCrubs()\n\ttry\n\t\ttell me to do shell script \"rm \/tmp\/rsyncldm.log\"\n\tend try\n\ttry\n\t\ttell me to do shell script \"killall -9 rsync\"\n\tend try\n\tdelay 2\n\t\n\t\nend RemoveTheCrubs\n\n-- Handler to manually choose an OS X install app or DMG.\n\non theChoiceOfAnotherCopy(ChoosemacOSFilePrompt1Loc, OSFileName, MyNotTheCorrectmacOSFileLoc, CancelButtonLoc, LogPath)\n\tset MymacOSFile to (choose file with prompt ChoosemacOSFilePrompt1Loc & OSFileName)\n\t\n\ttell application \"Finder\"\n\t\tset MymacOSFileExtension to name extension of MymacOSFile\n\tend tell\n\t\n\tif MymacOSFileExtension is \"app\" then\n\t\tset macOS_App to quoted form of ((POSIX path of MymacOSFile))\n\t\tset macOS_DMG to quoted form of ((POSIX path of MymacOSFile) & \"\/Contents\/SharedSupport\/InstallESD.dmg\")\n\t\tset macOSisFound to \"Found\"\n\t\ttell me to do shell script \"echo 'Install App Path: ' \" & macOS_App & \">> \" & LogPath\n\telse\n\t\tdisplay dialog MyNotTheCorrectmacOSFileLoc buttons {CancelButtonLoc} with icon stop\n\t\treturn\n\tend if\n\t\n\t\nend theChoiceOfAnotherCopy\n\n\n\n","avg_line_length":35.8487804878,"max_line_length":275,"alphanum_fraction":0.7214587019} +{"size":458,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- Another sort function.\nscript sort_colex\n\ton sort(table, column, reverse)\n\t\t-- Implement colexicographic Sorting process here.\n\t\treturn table\n\tend sort\nend script\n\n-- Populate a table (list) with data.\nset table to {{1,2},{3,4}}\n\nsortTable({sequence:table, ordering:sort_lexicographic, column:1, reverse:false})\nsortTable({sequence:table, ordering:sort_colex, column:2, reverse:true})\nsortTable({sequence:table, reverse:true})\nsortTable({sequence:table})\n","avg_line_length":28.625,"max_line_length":81,"alphanum_fraction":0.7598253275} +{"size":200,"ext":"applescript","lang":"AppleScript","max_stars_count":83.0,"content":"-- AppleScript template for activating a Chrome tab under a specific window\n-- `target` - a string that describes the tab target\ntell application \"Google Chrome\" to set active tab index of {{target}}\n","avg_line_length":50.0,"max_line_length":75,"alphanum_fraction":0.77} +{"size":1167,"ext":"applescript","lang":"AppleScript","max_stars_count":4.0,"content":"#!\/usr\/bin\/env osascript\n\n-- Copyright (c) 2015-present, Facebook, Inc.\n-- All rights reserved.\n--\n-- This source code is licensed under the BSD-style license found in the\n-- LICENSE file in the root directory of this source tree. An additional grant\n-- of patent rights can be found in the PATENTS file in the same directory.\n\non run argv\n set theURL to item 1 of argv\n\n tell application \"Chrome\"\n activate\n\n if (count every window) = 0 then\n make new window\n end if\n\n -- Find a tab currently running the debugger\n set found to false\n set theTabIndex to -1\n repeat with theWindow in every window\n set theTabIndex to 0\n repeat with theTab in every tab of theWindow\n set theTabIndex to theTabIndex + 1\n if theTab's URL is theURL then\n set found to true\n exit repeat\n end if\n end repeat\n\n if found then\n exit repeat\n end if\n end repeat\n\n if found then\n set index of theWindow to 1\n set theWindow's active tab index to theTabIndex\n else\n tell window 1\n make new tab with properties {URL:theURL}\n end tell\n end if\n end tell\nend run\n","avg_line_length":24.3125,"max_line_length":78,"alphanum_fraction":0.6589545844} +{"size":390,"ext":"applescript","lang":"AppleScript","max_stars_count":3305.0,"content":"#!\/usr\/bin\/osascript\n\n# @raycast.title Play\n# @raycast.author Caleb Stauffer\n# @raycast.authorURL https:\/\/github.com\/crstauf\n# @raycast.description Play TV.\n\n# @raycast.icon images\/apple-tv-logo.png\n# @raycast.mode silent\n# @raycast.packageName TV\n# @raycast.schemaVersion 1\n\ntell application \"TV\"\n\tif player state is paused then \n\t\tplay\n\t\tdo shell script \"echo Playing TV\"\n\tend if\nend tell","avg_line_length":21.6666666667,"max_line_length":47,"alphanum_fraction":0.7461538462} +{"size":107,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"tell application \"Google Chrome\"\n\ttell front window\n\t\ttell front tab\n\t\t\tclose\n\t\tend tell\n\tend tell\nend tell","avg_line_length":15.2857142857,"max_line_length":32,"alphanum_fraction":0.7476635514} +{"size":329,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"global HandyAdiumScripts\n\non run\n\ttell application \"Adium\"\n\t\ttry\n\t\t\tmake new window\n\t\t\terror\n\t\ton error number num --trap all errors\n\t\t\tif num is -2700 then error -- if the error is the default error, caused by the 'error' directive, pass it along the chain\n\t\t\t--otherwise, the command threw correctly\n\t\tend try\n\tend tell\nend run","avg_line_length":25.3076923077,"max_line_length":124,"alphanum_fraction":0.7325227964} +{"size":212,"ext":"applescript","lang":"AppleScript","max_stars_count":27.0,"content":"\non run argv\n tell document id (item 1 of argv) of application \"Keynote\"\n tell slide (item 2 of argv as number)\n set presenter notes to (item 3 of argv)\n end tell\n end tell\nend run\n","avg_line_length":23.5555555556,"max_line_length":62,"alphanum_fraction":0.6226415094} +{"size":728,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"set R to text returned of (display dialog \"Enter number of rows:\" default answer 2) as integer\nset c to text returned of (display dialog \"Enter number of columns:\" default answer 2) as integer\nset array to {}\nrepeat with i from 1 to R\n\tset temp to {}\n\trepeat with j from 1 to c\n\t\tset temp's end to 0\n\tend repeat\n\tset array's end to temp\nend repeat\n\n-- Address the first column of the first row:\nset array's item 1's item 1 to -10\n\n-- Negative index values can be used to address from the end:\nset array's item -1's item -1 to 10\n\n-- Access an item (row 2 column 1):\nset x to array's item 2's item 1\n\nreturn array\n\n-- Destroy array (typically unnecessary since it'll automatically be destroyed once script ends).\nset array to {}\n","avg_line_length":29.12,"max_line_length":97,"alphanum_fraction":0.7293956044} +{"size":935,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"property programme : \"jazz line-up\"\nproperty python_script : \"\\\"\/Users\/robjwells\/Programming\/Python\/BBC Radio AHP\/beebhijack\\\"\"\n\non process(theArgs)\n\tset saveTID to AppleScript's text item delimiters\n\tset AppleScript's text item delimiters to {\"|\"}\n\t\n\tset details to the text items of (do shell script python_script & \" details '\" & programme & \"'\")\n\t\n\tset AppleScript's text item delimiters to saveTID\n\t\n\tset track_name to (item 1 of details) & \": \" & (item 2 of details)\n\tset track_list to item 3 of details\n\t\n\ttell application \"iTunes\"\n\t\tset recording to item 1 of theArgs\n\t\tset imported_track to (add recording)\n\t\t\n\t\tdelay 60 -- Give iTunes a chance to get going\n\t\t\n\t\tset name of imported_track to track_name\n\t\tset bookmarkable of imported_track to true\n\t\tset shufflable of imported_track to false\n\t\tset lyrics of imported_track to track_list\n\t\tadd (get location of imported_track) to playlist \"Radio 3 Jazz\"\n\tend tell\nend process\n","avg_line_length":33.3928571429,"max_line_length":98,"alphanum_fraction":0.7497326203} +{"size":370,"ext":"applescript","lang":"AppleScript","max_stars_count":3.0,"content":"tell application \"QuarkXPress\"\n\tset x to selection as text\n\ttell document 1\n\t\tset CurrentPage to page number of current page\n\tend tell\nend tell\nset VersionNumber to x + 1\ntell application \"Keyboard Maestro Engine\"\n\tmake variable with properties {name:\"Version Number\", value:VersionNumber}\n\tmake variable with properties {name:\"Current Page\", value:CurrentPage}\nend tell","avg_line_length":33.6363636364,"max_line_length":75,"alphanum_fraction":0.7945945946} +{"size":226,"ext":"applescript","lang":"AppleScript","max_stars_count":116.0,"content":"tell application \"Script Debugger\"\n\ttell front document\n\t\tset sourceText to source text\n\t\tset thename to name\n\tend tell\n\tset d to make new document with properties {source text:sourceText}\n\ttell d\n\t\tcompile\n\tend tell\nend tell\n","avg_line_length":20.5454545455,"max_line_length":68,"alphanum_fraction":0.7743362832} +{"size":679,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"-- @description Toggle arming\n-- @author Ben Smith\n-- @link bensmithsound.uk\n-- @source Rich Walsh\n-- @version 1.0\n-- @testedmacos 10.13.6\n-- @testedqlab 4.6.9\n-- @about Toggles the arm state of selected cues\n-- @separateprocess FALSE\n\n-- @changelog\n-- v1.0 + init\n\n\ntell front workspace\n\tset selectedCues to (selected as list)\n\tif (count selectedCues) is 0 then -- If no cues are selected arm\/disarm the current cue list\n\t\tset armed of current cue list to not armed of current cue list\n\telse\n\t\trepeat with eachCue in reverse of selectedCues -- Reversed so as to do a Group Cue's children before it\n\t\t\tset armed of eachCue to not armed of eachCue\n\t\tend repeat\n\tend if\nend tell","avg_line_length":28.2916666667,"max_line_length":105,"alphanum_fraction":0.7290132548} +{"size":2756,"ext":"applescript","lang":"AppleScript","max_stars_count":5.0,"content":"(*\nMade for ZNBC (https:\/\/znbc.com) to process images in batch with photoshop\n*)\n(*\n Description: Description: You have to create a script in Photoshop then all the files presented in the source folder will be proceeded with actions you have made in the script and be saved in the destination folder. For the moment the photoshop script executed is \"resize_60_percent_solar_apply\" from a directory named \"bruno\". \n\n ! CAUTION !\n - Name for script and directory in Photoshop are case-sensitive.\n - Do not register a save action and close action in your Photoshop script.\n\n Version: 1.1\n Author: Bruno Flaven\n Author URI: http:\/\/flaven.fr\n *)\n\n-- This chooses the master folder where all your sub folders with images are stored\nsay \"Choose your source Folder for this batch job\" using \"Victoria\"\nset raw_folder to choose folder\n\n-- This chooses the destination folder where all your result images are stored\nsay \"Choose your destination Folder for the processed files\" using \"Victoria\"\nset live_folder to choose folder\n\n\n\n\n-- This checks when the batch started and stores the date value\nset startTime to time of (current date)\n\n\n(* for actions *)\n-- This the file counter\nset fileCounter to 0\n\ntell application \"Finder\"\n\tset itemList to files in raw_folder\nend tell\n\nrepeat with j from 1 to (number of itemList)\n\tset fileCounter to fileCounter + 1\nend repeat\n\n(* for fileCounter *)\n\n\n(* for fileCounter *)\n--source and destination folders for the images\ntell application \"Finder\"\n\tset imageSet to get every file of folder raw_folder\nend tell\n\ntell application \"Finder\"\n\trepeat with i from 1 to (count of imageSet)\n\t\t-- coerce Finder style path to string\n\t\tset currentImg to (item i of imageSet) as string\n\t\ttell application \"Adobe Photoshop CS6\"\n\t\t\t-- no dialog box\n\t\t\tset display dialogs to never\n\t\t\tactivate\n\t\t\topen alias currentImg\n\t\t\tset currentImg to current document\n\t\t\t-- tell current document\n\t\t\t\n\t\t\t\n\t\t\t-- choose your action in the folder, caution the naming is case sensitive\n\t\t\t\n\t\t\t(* \n\n\t\t\tThe script name is \"resize_50_percent_demo\" from the directory \"demo\" \n\t\t\tfrom the Actions tabs inside Adobe Photoshop CS6\n\n\t\t\t*)\n\t\t\tdo action \"resize_to_60_percent_good\" from \"demo_1\"\n\t\t\t\n\t\t\t\n\t\t\t-- close the file in photoshop after the job is done\n\t\t\tclose every document without saving\n\t\t\t\n\t\tend tell\n\tend repeat\n\t\n\t(* for actions *)\n\tset endTime to time of (current date)\n\t\n\t(* end *)\n\tsay \"The job is done, please have a look to the destination folder. The operation took \" & endTime - startTime & \" seconds. The directory contains \" & fileCounter & \" files.\" using \"Victoria\"\n\t\n\t(* Dialog box if needed *)\n\t-- display dialog \"nThe operation took \" & endTime - startTime & \" seconds\" & \".nThe directory contains \" & fileCounter & \" files.n\"\n\t\nend tell","avg_line_length":30.2857142857,"max_line_length":329,"alphanum_fraction":0.7380261248} +{"size":651,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- The following line is needed to use ASPashua\nuse script \"ASPashua\"\n-- When you don't have any \"use\" statements, the following is included automatically.\n-- When including ASPashua, you need to add this when using standard things \n-- like \"display alert\" or \"path to me\"\nuse scripting additions\n\n\n-- Get the path to the current folder, and create an alias for the mentioned file\nset script_path to (path to me as text) & \"::\"\nset config_file_name to \"1.dpd-with file.pashua\"\nset config_file to alias (script_path & config_file_name)\n\n\n-- Show the dialog, the results of the dialog will be shown in the Results-pane\ndisplay pashua dialog config_file\n","avg_line_length":38.2941176471,"max_line_length":85,"alphanum_fraction":0.7649769585} +{"size":452,"ext":"scpt","lang":"AppleScript","max_stars_count":5.0,"content":"#!\/usr\/bin\/env osascript\nglobal frontApp, frontAppName, windowTitle\nset windowTitle to \"\"\ntell application \"System Events\"\n\tset frontApp to first application process whose frontmost is true\n\tset frontAppName to name of frontApp\n\ttell process frontAppName\n\t\ttell (1st window whose value of attribute \"AXMain\" is true)\n\t\t\ttry \n\t\t\t\tset windowTitle to value of attribute \"AXTitle\"\n\t\t\tend try\n\t\tend tell\n\tend tell\nend tell\nreturn {frontAppName,windowTitle}\n","avg_line_length":28.25,"max_line_length":66,"alphanum_fraction":0.7787610619} +{"size":821,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"on run\n\n map(test, {|and|, |or|})\n\nend run\n\n-- test :: ((Bool, Bool) -> Bool) -> (Bool, Bool, Bool, Bool)\non test(f)\n map(f, {{true, true}, {true, false}, {false, true}, {false, false}})\nend test\n\n\n\n-- |and| :: (Bool, Bool) -> Bool\non |and|(tuple)\n set {x, y} to tuple\n\n a(x) and b(y)\nend |and|\n\n-- |or| :: (Bool, Bool) -> Bool\non |or|(tuple)\n set {x, y} to tuple\n\n a(x) or b(y)\nend |or|\n\n-- a :: Bool -> Bool\non a(bool)\n log \"a\"\n return bool\nend a\n\n-- b :: Bool -> Bool\non b(bool)\n log \"b\"\n return bool\nend b\n\n\n-- map :: (a -> b) -> [a] -> [b]\non map(f, xs)\n script mf\n property lambda : f\n end script\n set lng to length of xs\n set lst to {}\n repeat with i from 1 to lng\n set end of lst to mf's lambda(item i of xs, i, xs)\n end repeat\n return lst\nend map\n","avg_line_length":15.4905660377,"max_line_length":72,"alphanum_fraction":0.5176613886} +{"size":676,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- The following line is needed to use ASPashua\nuse script \"ASPashua\"\n-- When you don't have any \"use\" statements, the following is incluced automatically.\n-- When including ASPashua, you need to uncomment this when using standard things \n-- like \"display alert\" or \"path to me\"\nuse scripting additions\n\n\n-- Get the path to the current folder, and create an alias for the mentioned file\nset script_path to (path to me as text) & \"::\"\nset config_file_name to \"1. display pashua dialog-with file.pashua\"\nset config_file to alias (script_path & config_file_name)\n\n\n-- Show the dialog, the results of the dialog will be shown in the Results-pane\ndisplay pashua dialog config_file\n","avg_line_length":39.7647058824,"max_line_length":85,"alphanum_fraction":0.7692307692} +{"size":743,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"on pathExists(thePath)\n\tif thePath starts with \"~\" then set thePath to POSIX path of (path to home folder) & text 3 thru -1 of (get thePath)\n\ttry\n\t\tPOSIX file thePath as alias\n\t\treturn true\n\ton error\n\t\treturn false\n\tend try\nend pathExists\n\nif pathExists(\"~\/Library\/Application Support\/discordcanary\/Cache\/\") = true then\n\treturn do shell script \"rm -rf ~\/Library\/Application\\\\ Support\/discordcanary\/Cache\/*\"\nend if\n\nif pathExists(\"~\/Library\/Application Support\/discord\/Cache\/\") = true then\n\treturn do shell script \"rm -rf ~\/Library\/Application\\\\ Support\/discord\/Cache\/*\"\nend if\n\nif pathExists(\"~\/Library\/Application Support\/discord\/Cache\/\") = true then\n\treturn do shell script \"rm -rf ~\/Library\/Application\\\\ Support\/discordptb\/Cache\/*\"\nend if\n","avg_line_length":33.7727272727,"max_line_length":117,"alphanum_fraction":0.7496635262} +{"size":2777,"ext":"scpt","lang":"AppleScript","max_stars_count":null,"content":"tell application \"Finder\" to set folderRoot to (choose folder with prompt \"Please select directory.\")\n\n\n\non returnNumbersInString(inputString)\n\tset s to quoted form of inputString\n\tdo shell script \"sed s\/[a-zA-Z\\\\']\/\/g <<< \" & s's quoted form\n\tset dx to the result\n\tset numlist to {}\n\trepeat with i from 1 to count of words in dx\n\t\tset this_item to word i of dx\n\t\ttry\n\t\t\tset this_item to this_item as number\n\t\t\tset the end of numlist to this_item\n\t\tend try\n\tend repeat\n\treturn numlist\nend returnNumbersInString\n\n\n\non gimmieFilesInSubfolders(inputFolder)\n\ttell application \"Finder\" to get every file in the entire contents of (inputFolder) as alias list\nend gimmieFilesInSubfolders\n\nset filePile to gimmieFilesInSubfolders(folderRoot)\n\nrepeat with theFile in filePile\n\t--do shell script \"echo \" & theFile & \" >>~\/Desktop\/test.txt\"\n\ttry\n\t\t\n\t\tset this_posix_item to (the POSIX path of (theFile))\n\t\tlog this_posix_item\n\t\t\n\t\t\n\t\ttell application \"System Events\"\n\t\t\t--set path_only to POSIX path of ((container of theFile) as text)\n\t\t\t\n\t\t\t\n\t\t\t--\t\tset path_only to characters 1 thru -((offset of \"\/\" in (reverse of items of this_posix_item as string)) + 1) of this_posix_item as string\n\t\t\t--\t\tlog path_only\n\t\tend tell\n\t\t\n\t\tset filename_only to do shell script \"basename \" & quoted form of this_posix_item\n\t\t--\tdo shell script (\"cd \" & quoted form of path_only)\n\t\t--\tdelay 1\n\t\t\n\t\t\n\t\tset output to do shell script (\"\/usr\/local\/bin\/ffmpeg -y -i \" & quoted form of this_posix_item & \" -map 0:v:0 -filter:v idet -frames:v 500 -an -f rawvideo \/dev\/null 2>&1\")\n\t\t\n\t\tset text item delimiters to {\"Multi frame detection:\"}\n\t\tset trimmedNums to text items 2 thru 2 of output as string\n\t\tlog trimmedNums\n\t\t--\t\tset output to do shell script (\"ls\")\n\t\t\n\t\t--do shell script \"echo \" & output & \" >>~\/Desktop\/test.txt\"\n\t\t\n\t\t\n\t\tset justNums to returnNumbersInString(trimmedNums)\n\t\t--log justNums\n\t\t\n\t\tset tffValue to the first item of justNums\n\t\t--log tffValue\n\t\tset bffValue to the second item of justNums\n\t\t--log bffValue\n\t\tset progValue to the (third item of justNums) + 5 --Margin of error for text files\n\t\t--log progValue\n\t\t\n\t\tset isVideoInterlaced to false\n\t\tif progValue is less than tffValue then\n\t\t\tset isVideoInterlaced to true\n\t\t\tlog isVideoInterlaced\n\t\t\tdo shell script \"echo TFF: \" & this_posix_item & \" >>~\/Desktop\/Interlaced.txt\"\n\t\t\tlog \"TFF\"\n\t\telse if progValue is less than bffValue then\n\t\t\tset isVideoInterlaced to true\n\t\t\tlog isVideoInterlaced\n\t\t\tdo shell script \"echo BFF: \" & this_posix_item & \" >>~\/Desktop\/Interlaced.txt\"\n\t\t\tlog \"BFF\"\n\t\tend if\n\t\t\n\tend try\nend repeat\n\ndisplay dialog \"Done scanning this folder and subfolders for interlaced files. Check Interlaced.txt on the desktop for the full list.\"\n--beep\n--log \"Done scanning this folder and subfolders for interlaced files\"\n","avg_line_length":31.5568181818,"max_line_length":173,"alphanum_fraction":0.7220021606} +{"size":32028,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"(*\rMacDisplaySettings.applescript\rDenis G. Pelli, denis.pelli@nyu.edu\rMay 9, 2020. \r\rINTRODUCTION\rThis applescript run handler allows you read and set seven parameters of\rthe macOS System Preferences Displays panel: Brightness (slider),\r\"Automatically adjust brightness\" (checkbox), True Tone (checkbox)\r(present only on some Macs made in 2018 or later), Night Shift pop up\rand checkbox), and Color Profile (by name or row number) and a checkbox\r\"Show Profiles For This Display Only\". Apple invites users to use these\rparameters to personally customize their experience by enabling dynamic\radjustments of all displayed images in response to personal preference,\rambient lighting, and time of day. Users seem to like that, but those\radjustments could defeat our efforts to calibrate the display one day\rand, at a later date, use our calibrations to reliably present an\raccurately specified stimulus. MacDisplaySettings aims to satisfy\reveryone, by allowing your calibration and test programs to use the\rcomputer in a fixed state, unaffected by user whims, ambient lighting,\rand time of day, while saving and restoring whatever custom states the\rusers have customized it to. MacDisplaySettings reports and controls\rthese five settings. It allows you to read their current states, set\rthem to standard values for your critical work, and, when you're done,\rrestore them to their original values.\r\rI wrote this script to be invoked from MATLAB, but you could call it \rfrom any application running under macOS. To support an external monitor\ryou must provide the global rect of the external screen; that's not \rnecessary for the main screen.\r\rMacDisplaySettings allows you to temporarily override any macOS user\rcustomization of the display, to allow calibration and user testing with\rstable display settings. It allows you to peek and poke seven settings in\rthe System Preferences:Displays panel by using the corresponding fields\rin the oldXXX and newXXX arguments, where XXX is as follows:\r\r DISPLAY\rbrightness the Brightness slider\rautomatically the \"Automatically adjust brightness\" checkbox (true or false)\rtrueTone the \"True Tone\" checkbox (true or false)\r NIGHT SHIFT\rnightShiftSchedule the Night Shift Schedule pop up menu ('Off','Custom', or 'Sunset to Sunrise')\rnightShiftManual the Night Shift Manual checkbox (true or false)\r COLOR\rshowProfilesForThisDisplayOnly\tthe checkbox (true or false)\rprofile name of selection in Color Profile menu (text)\rprofileRow row # of selection in Color Profile menu (integer)\r\rINPUT ARGS: The screenNumber, if provided, must be an integer of an available \rscreen, i.e. one of the values returned by Screen('Screens'). If newProfileRow \ris specified then newProfile is ignored. True Tone is not available on Macs \rmanufactured before 2018.\r\rOUTPUT ARGS: The variables oldXXX (where XXX stands for any of the fields \rlisted above) report the prior state of all available parameters. errorMsg\ris the last output argument. If everything worked then errorMsg is an empty\rstring. Otherwise it will describe one failure, even if there were\rseveral. In peeking, the fields corresponding to parameters that could\rnot be read will be empty [], and is not flagged as an error. Any omission \rin poking is flagged as an error. If you get an error while poking, you might \rcall MacDisplaySettings again to compare the new peek with what you poked.\r\r\rSCREENNUMBER (AND GLOBAL RECT): We endeavor to interpret \rscreenNumber in the same way as Screen (0 for main screen, \r1 for first external monitor, etc.). To achieve this we\rrequest the global rect of the desired monitor as 4 input \rarguments. We anticipate that the rect will be provided by \rScreen('GlobalRect',screenNumber). We use this rect to select \rwhichever window of System Preferences: Displays is on the \rdesired monitor. This is reliable, provided the user\rdoes not move those windows to different screens. \rThis applescript code works with whichever Displays \rwindow is currently on the desired monitor. (If there are\rseveral, it will randomly pick one.)\r\rBRIGHTNESS is a slider on the Displays panel, allowing users to easily\radjust the \"Brightness\" of Apple Macintosh liquid crystal displays.\rSetting this parameter is equivalent to manually opening the System\rPreference:Displays and adjusting the \"brightnes\" slider.\rThe \"brightness\" setting controls the luminance of the fluorescent light\rthat is behind the liquid crystal display. I believe that this\r\"brightness\" setting controls only the luminance of the source, and does\rnot affect the liquid crystal display. The screen luminance is\rpresumably the product of the two factors: luminance of the source and\rtransmission of the liquid crystal, at each wavelength.\r\rAUTOMATICALLY is a checkbox on the Displays panel. WHen enabled the\rmacOS adjusts the display luminance to track ambient lighting. I find\rthat pleasant as a user, but it's terrible for calibrationg.\r\rTRUE TONE checkbox on the Displays panel.\r\rNIGHT SHIFT panel has a \"Schedule\" pop-up menu and a \"Manual\" \rcheckbox.\r\rDISPLAY PROFILE is a menu of named profiles on the \"Color\" panel.\r\rMost of these controls don't interact. However,\rshowProfilesForThisDisplayOnly affects the choices available for\rselecting a Profile. When you call MacDisplaySettings with a setting for\rshowProfilesForThisDisplayOnly, that setting is applied before it peeks\ror pokes the Profile selection.\r\rERROR CHECKING. Most of the controls are straightforward. You are just\rpeeking and poking a Boolean (0 or 1) or a small integer with a known\rrange. Brightness and Profile are more subtle, so MacDisplaySettings\ralways checks by peeking immediately after poking Brightness (float) \ror Profile (whether by name or by row). A discrepancy will be flagged \rby a string in errorMsg. Note that you provide a float to Brightness \rbut within the macOS it's quantized to roughly 18-bit precision. The \rpeek of Brightness is considered erroneous only if it differes by more \rthan 0.001 from what we poked.\r\rSYSTEM PREFERENCES TAKES 30 S TO OPEN: This script uses the \"System\rPreferences: Displays\" panel, which takes 30 s to launch, if it isn't\ralready running. We leave it running.\r\rAll returned values are [] if your application (e.g. MATLAB) does not\rhave permission to control your computer (see APPLE SECURITY below).\r\rIn MATLAB, you should call MacDisplaySettings.m, which calls this\rapplescript.:\r\roldSettings=MacDisplaySettings(screenNumber,newSettings);\r\rTo call this applescript directly from MATLAB:\r\r[status, errorMsg, oldBrightness, oldAutomatically, oldTrueTone, ...\r\toldNightSchedule, oldNightShiftManual, oldProfileRow, oldProfile] ...\r\t= ...\r\tsystem(['osascript MacDisplaySettings.applescript ' ...\r\tnum2str(screenNumber) ' '...\r\tnum2str(newBrightness) ' ' ...\r\tnum2str(newAutomatically) ' '...\r\tnum2str(newTrueTone) ' '...\r\tnum2str(newNightShiftSchedule) ' ' ...\r\tnum2str(ewNightShiftManual) ' '...\r\tnum2str(newShowProfilesForThisDisplayOnly) ' '...\r\tnum2str(newProfileRow) ' ' ...\r\t'\"' newProfile '\"']);\r\rCalling from any other language is very similar. Ignore the returned \r\"status\", which seems to always be zero.\r\rCOMPATIBILITY: macOS VERSION: Works on Mavericks, Yosemite, El Capitan,\rand Mojave (macOS 10.9 to 10.14). Not yet tested on macOS 10.8 or\rearlier, or on Catalina (10.15). INTERNATIONAL: It is designed (but not\ryet tested) to work internationally, with macOS localized for any\rlanguage, not just English. (For example, that is why we select the\rDisplay\/Colors panel by the internal name \"displaysDisplayTab\" instead\rusing the localized name \"Display\".) MULTIPLE SCREENS: All my computers\rhave only one screen, so I haven't yet tested it with values of\rscreenNumber other than zero.\r\rFOR SPEED WE LEAVE SYSTEM PREFERENCES OPEN: This script uses the \rSystem Preferences app, which takes 30 s to open, if it isn't already \ropen, so we leave it open. \r\t\rAPPLE SECURITY. Unless the application (e.g. MATLAB) calling this script\rhas permission to control the computer, attempts to changes settings\rwill be blocked. In that case the appropriate Security and Privacy\rSystem Preference panel is opened and an error dialog window asks the\ruser to provide the permission. A user with admin privileges should then\rclick as requested to provide that permission. This needs to be done\ronly once for each application that calls this script. The permission is\rremembered forever. Once permission has been granted, subsequent calls\rof this script will work. Note that a user lacking admin access is\runable to grant the permission; in that case every time you call this\rscript, you'll get the error dialog window.\r\rPsychtoolbox Screen.mex. Screen(... 'Brightness'): The Psychtoolbox for\rMATLAB and macOS has a Screen call to get and set the brightness. \r\rTHANKS to Mario Kleiner for explaining how macOS \"brightness\" works.\rThanks to nick.peatfield@gmail.com for sharing his applescript code for\rdimmer.scpt and brighter.scpt.\r\rSEE ALSO:\rScript Debugger app from Late Night Software. https:\/\/latenightsw.com\/\rUI Browser app from UI Browser by PFiddlesoft. https:\/\/pfiddlesoft.com\/uibrowser\/\rScriptingAllowed.applescript (http:\/\/psych.nyu.edu\/pelli\/software.html)\rThe Psychtoolbox call to get and set the Macintosh brightness:\r[oldBrightness]=Screen('ConfigureDisplay','Brightness', ...);\rhttp:\/\/www.manpagez.com\/man\/1\/osascript\/\rhttps:\/\/developer.apple.com\/library\/mac\/documentation\/AppleScript\/Conceptual\/AppleScriptLangGuide\/reference\/ASLR_cmds.html\rhttps:\/\/discussions.apple.com\/thread\/6418291\rhttps:\/\/stackoverflow.com\/questions\/13415994\/how-to-get-the-number-of-items-in-a-pop-up-menu-without-opening-it-using-applesc\r\rHISTORY\rMay 21, 2015. Wrote AutoBrightness to control the \"Automatically adjust\rbrightness\" checkbox of the Displays panel.\rMay 29, 2015 Enhanced to allow specification of screenNumber.\rJune 1, 2015. Polished the comments.\rJuly 25, 2015 Previously worked on Mavericks (Mac OS X 10.9). Now\renhanced to also support Yosemite (Mac OS X 10.10.4).\rAugust 3, 2015 Now uses try-blocks to try first group 1 and then group 2\rto cope with variations in Apple's macOS. I find that under macOS 10.9\rthe checkbox is always in group 1. Under macOS 10.10 I have previously\rfound it in group 2, but now I find it in group 1, so it seems best for\rthe program to keep trying groups until it finds the checkbox: first 1,\rthen 2, then give up.\rFebruary 29, 2016 Improved the wording of the pop-up screen to spell out\rwhat the user needs to do to allow MATLAB to control the computer.\rJune 25, 2017. First version of Brightness, based on my \rAutoBrightness.applescript\rApril 9, 2020. Now called MacDisplaySettings.applescript merging code\rfrom Brightness and AutoBrightness, and adding code for True Tone and\rNight Shift.\rApril 14, 2020. Added loops to wait \"until exists tab group 1 of window\rwindowNumber\" before accessing it. This change has enormously increased\rthe reliability. I think the old failures were timeouts, and the wait\rloops seem to have almost entirely fixed that.\rMay 2, 2020. Watching it work, I notice that the operations on the\rSystem Preferences panel are glacially slow while it's in background, \rbehind MATLAB, but zippy, like a fast human operator, when System\rPreferences is foremost. Observing that, I now \"activate\" System\rPreferences at the beginning (and reactivate the former app when we\rexit), and this runs much faster. Formerly delays of 60 s were common.\rNow it reliably takes 3 s.\rMay 5, 2020. Return an error message if anything went wrong. The user\rwill know that everything's ok if the error string is empty. Also apply\rthe user's setting of newShowProfilesForThisDisplayOnly before peeking\rand poking.\rMay 9, 2020. Improved speed (from 3 to 1.6 s) by replacing fixed delays\rin applescript with wait loops. Enhanced the built-in peek of brightness\rafer poking. Now if the peek differs by more than 0.001,\rMacDisplaySettings waits 100 ms and tries again, to let the value settle,\ras the visual effect is a slow fade. Then it reports in errorMsg if the\rnew peek differs by more than 0.001. In limited testing, waiting for a\rgood answer works: the peek-poke difference rarely exceeds +\/-5e-6 and\rnever exceeds 0.001. It's my impression that if we always waited 100 ms,\rthen the discrepancy would always be less than +\/-5e-6.\r*)\r\ron run argv\r\t-- INPUT SETTINGS: screenNumber, newBrightness, newAutomatically, newTrueTone, \r\t-- newNightShiftSchedule, newNightShiftManual,\r\t-- newShowProfilesForThisDisplayOnly, newProfileRow, newProfile.\r\t-- OUTPUT SETTINGS: olsdBrightness, oldAutomatically, oldTrueTone, oldNightShift,\r\t-- oldShowProfilesForThisDisplayOnly, oldProfileRow, oldProfile.\r\t-- integer screenNumber. Zero for main screen. Default is zero.\r\t--integer 4 values for global rect of desired screen. (Can be -1 -1 -1 -1 for main screen.)\r\t-- float newBrightness: -1.0 (ignore) or 0.0 to 1.0 value of brightness slider.\r\t-- integer newAutomatically: -1 (ignore) or 0 or 1 logical value of checkbox.\r\t-- integer newTrueTone: -1 (ignore) or 0 or 1 logical value of checkbox.\r\t-- A value of -1 leaves the setting unchanged.\r\t-- Returns oldBrightness (-1, or 0.0 to 1.0), oldAutomatically (-1, or 0 or 1), \r\t-- oldTrueTone (-1, or 0 or 1), oldNightShiftSchedule (-1, or 1, 2, or 3), \r\t-- oldNightShiftManual (-1 or 0 or 1), \r\t-- oldShowProfilesForThisDisplayOnly (-1, or 0 or 1), \r\t-- oldProfileRow (-1 or integer), oldProfile (string).\r\t-- TrueTone only exists on some Macs manufactured 2018 or later. When not \r\t-- available, oldTrueTone is [].\r\t\r\ttell application \"Finder\"\r\t\tset mainRect to bounds of window of desktop\r\tend tell\r\t\r\t--GET ARGUMENTS\r\tset theRect to {-1, -1, -1, -1}\r\ttry\r\t\tset screenNumber to item 1 of argv as integer\r\ton error\r\t\tset screenNumber to 0 -- Default is the main screen.\r\tend try\r\ttry\r\t\tset item 1 of theRect to item 2 of argv as integer\r\ton error\r\t\tset item 1 of theRect to item 1 of mainRect -- Default is the main screen.\r\tend try\r\ttry\r\t\tset item 2 of theRect to item 3 of argv as integer\r\ton error\r\t\tset item 2 of theRect to item 2 of mainRect -- Default is the main screen.\r\tend try\r\ttry\r\t\tset item 3 of theRect to item 4 of argv as integer\r\ton error\r\t\tset item 3 of theRect to item 3 of mainRect -- Default is the main screen.\r\tend try\r\ttry\r\t\tset item 4 of theRect to item 5 of argv as integer\r\ton error\r\t\tset item 4 of theRect to item 4 of mainRect -- Default is the main screen.\r\tend try\r\ttry\r\t\tset newBrightness to item 6 of argv as real\r\ton error\r\t\tset newBrightness to -1.0 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\tset newAutomatically to item 7 of argv as integer\r\ton error\r\t\tset newAutomatically to -1 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\tset newTrueTone to item 8 of argv as integer\r\ton error\r\t\tset newTrueTone to -1 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\t--To ease passing the Night Shift Schedule menu choice back and forth\r\t\t--between MATLAB and AppleScript (and for compatibility with international\r\t\t--variations of macOS), we receive and pass just the integer index into\r\t\t--the list: {'Off','Custom','Sunset to Sunrise'}. This should work in\r\t\t--international (i.e. translated) versions of macOS.\r\t\tset newNightShiftSchedule to item 9 of argv as integer\r\ton error\r\t\tset newNightShiftSchedule to -1 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\tset newNightShiftManual to item 10 of argv as integer\r\ton error\r\t\tset newNightShiftManual to -1 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\tset newShowProfilesForThisDisplayOnly to item 11 of argv as integer\r\ton error\r\t\tset newShowProfilesForThisDisplayOnly to -1 -- Unspecified value, so don't change the setting.\r\tend try\r\ttry\r\t\tset newProfileRow to item 12 of argv as integer\r\ton error\r\t\tset newProfileRow to -1 -- Unspecified value is ignored.\r\tend try\r\ttry\r\t\tset newProfile to item 13 of argv as string\r\ton error\r\t\tset newProfile to -1 -- Unspecified value is ignored.\r\tend try\r\tif newProfile as string is equal to \"\" then\r\t\tset newProfile to -1\r\tend if\r\t\r\t-- CHECK ARGUMENTS\r\tif newNightShiftSchedule is not in {-1, 1, 2, 3} then\r\t\treturn -991\r\tend if\r\tset leaveSystemPrefsRunning to true -- This could be made a further argument.\r\tset versionString to system version of (system info)\r\tconsidering numeric strings\r\t\tset isMojaveOrBetter to versionString \u2265 \"10.14.0\"\r\t\tset isNightShiftAvailable to versionString \u2265 \"10.12.4\"\r\tend considering\r\t-- Default values. The value -1 means don't modify this setting.\r\tset oldBrightness to -1.0\r\tset oldAutomatically to -1\r\tset oldTrueTone to -1\r\tset oldProfile to \"\"\r\tset oldProfileRow to -1\r\tset oldShowProfilesForThisDisplayOnly to -1\r\tset oldNightShiftSchedule to -1\r\tset oldNightShiftManual to -1\r\tset errorMsg to \"\"\r\t\r\t-- The \"ok\" flags help track what failed. We return an error message if \r\t-- any failed (that shouldn't).\r\tset trueToneOk to false\r\tset groupOk to false\r\tset brightnessOk to false\r\tset profileOk to false\r\tset manualOk to false\r\tset scheduleOk to false\r\tset windowIsOpen to true\r\t\r\t-- GET NAME OF CURRENT APP.\r\t-- Save name of current active application (probably MATLAB) to\r\t-- restore at end as the fronmost.\r\t--https:\/\/stackoverflow.com\/questions\/44017508\/set-application-to-frontmost-in-applescript\r\t--https:\/\/stackoverflow.com\/questions\/13097426\/activating-an-application-in-applescript-with-the-application-as-a-variable\r\tset currentApp to path to frontmost application as text\r\ttell application \"System Preferences\"\r\t\tactivate -- Bring it to the front, which makes the rest MUCH faster.\r\t\t-- This is the international way to get to the right pane of Displays, immune to \r\t\t-- language localizations.\r\t\tset current pane to pane id \"com.apple.preference.displays\"\r\t\tset wasRunning to running\r\t\treveal anchor \"displaysDisplayTab\" of pane id \"com.apple.preference.displays\"\r\tend tell\r\t\r\t-- FIND THE SYSTEM PREFS WINDOWS ON THE DESIRED SCREEN.\r\t-- theRect is received as an argument. In MATLAB theRect=Screen('GlobalRect',screen).\r\t-- Formerly we always referred to \"window windowNumber\" but windowNumber changes if \r\t-- a window is brought forward. The frontmost window always has number 1. So now we \r\t-- refer to theWindow which is stable, even after we bring the window to the front.\r\t-- We know a window is on the desired screen by checking whether its x y position\r\t-- is inside the global rect of the desired screen, which is received as an\r\t-- argument when MacDisplayScreen is called. (If the gloabl rect is not provided, \r\t-- the default is the reect of the main screen, which we caompute above.)\r\tset theWindow to -1\r\tset mainWindow to -1\r\tif screenNumber is equal to 0 then\r\t\tset theRect to mainRect\r\tend if\r\t\r\t--set theRect to {1000, 0, 3600, 1000} -- for debugging\r\t\r\ttell application \"System Events\"\r\t\ttell application process \"System Preferences\"\r\t\t\trepeat with w from 1 to (count windows)\r\t\t\t\tset winPos to position of window w\r\t\t\t\tset x to item 1 of winPos\r\t\t\t\tset y to item 2 of winPos\r\t\t\t\tif (x \u2265 item 1 of theRect and x \u2264 item 3 of theRect and \u00ac\r\t\t\t\t\ty \u2265 item 2 of theRect and y \u2264 item 4 of theRect) then\r\t\t\t\t\tset theWindow to window w\r\t\t\t\tend if\r\t\t\t\t-- We never use the variable \"mainWindow\", but it's cheap to \r\t\t\t\t-- find it, and it's handy to have when debugging.\r\t\t\t\tif (x \u2265 item 1 of mainRect and x \u2264 item 3 of mainRect and \u00ac\r\t\t\t\t\ty \u2265 item 2 of mainRect and y \u2264 item 4 of mainRect) then\r\t\t\t\t\tset mainWindow to window w\r\t\t\t\tend if\r\t\t\tend repeat\r\t\tend tell\r\tend tell\r\tif theWindow is equal to -1 then\r\t\tset errorMsg to \"Could not find screenNumber \" & screenNumber & \".\"\r\t\tactivate application currentApp -- Restore active application.\r\t\t--delay 0.1 -- May not be needed.\r\t\treturn {oldBrightness, oldAutomatically, \u00ac\r\t\t\toldTrueTone, oldNightShiftSchedule, oldNightShiftManual, \u00ac\r\t\t\toldShowProfilesForThisDisplayOnly, oldProfileRow, \u00ac\r\t\t\t\"|\" & oldProfile & \"|\", \"|\" & errorMsg & \"|\"}\r\tend if\r\t\r\t-- PERMISSION CHECK, TRUE TONE, BRIGHTNESS & AUTOMATIC, \r\ttell application \"System Events\"\r\t\t\r\t\t-- CHECK FOR PERMISSION\r\t\tset applicationName to item 1 of (get name of processes whose frontmost is true)\r\t\tif not UI elements enabled then\r\t\t\ttell application \"System Preferences\"\r\t\t\t\tactivate\r\t\t\t\treveal anchor \"Privacy_Accessibility\" of pane id \"com.apple.preference.security\"\r\t\t\t\tif windowIsOpen > 0 then\r\t\t\t\t\treturn -999\r\t\t\t\tend if\r\t\t\t\tdisplay alert \"To set Displays preferences, \" & applicationName & \u00ac\r\t\t\t\t\t\" needs your permission to control this computer. \" & \u00ac\r\t\t\t\t\t\"BEFORE you click OK below, please unlock System Preferences: Security & Privacy: \" & \u00ac\r\t\t\t\t\t\"Privacy and click the boxes to grant permission for Full Disk Access and Automation. \" & \u00ac\r\t\t\t\t\t\"THEN click OK.\"\r\t\t\tend tell\r\t\t\treturn -99\r\t\tend if\r\t\t\r\t\t--DISPLAY PANEL\r\t\t-- TRUE TONE, BRIGHTNESS & AUTOMATIC\r\t\tset screenNumber to 1\r\t\ttell process \"System Preferences\"\r\t\t\trepeat 10 times\r\t\t\t\tif exists theWindow then exit repeat\r\t\t\t\tdelay 0.05\r\t\t\tend repeat\r\t\t\tif not (exists theWindow) then\r\t\t\t\tset errorMsg to \"screenNumber \" & screenNumber & \" is not available.\"\r\t\t\t\tactivate application currentApp -- Restore active application.\r\t\t\t\t--delay 0.1\r\t\t\t\treturn {oldBrightness, oldAutomatically, \u00ac\r\t\t\t\t\toldTrueTone, oldNightShiftSchedule, oldNightShiftManual, \u00ac\r\t\t\t\t\toldShowProfilesForThisDisplayOnly, oldProfileRow, \u00ac\r\t\t\t\t\t\"|\" & oldProfile & \"|\", \"|\" & errorMsg & \"|\"}\r\t\t\tend if\r\t\t\t\r\t\t\trepeat until exists tab group 1 of theWindow\r\t\t\t\tdelay 0.05\r\t\t\tend repeat\r\t\t\ttell tab group 1 of theWindow\r\t\t\t\t\r\t\t\t\t-- TRUE TONE\r\t\t\t\tset trueToneOk to false\r\t\t\t\ttry\r\t\t\t\t\ttell checkbox 1\r\t\t\t\t\t\tset oldTrueTone to value\r\t\t\t\t\t\tif newTrueTone is in {0, 1} and newTrueTone is not oldTrueTone then\r\t\t\t\t\t\t\tclick -- It's stale, so update it.\r\t\t\t\t\t\tend if\r\t\t\t\t\tend tell\r\t\t\t\t\t--Succeeded with True Tone.\r\t\t\t\t\tset trueToneOk to true\r\t\t\t\ton error\r\t\t\t\t\t-- Don't report True Tone error. \r\t\t\t\t\t-- Just return oldTrueTone=-1.\r\t\t\t\t\tset trueToneOk to false\r\t\t\t\tend try\r\t\t\t\t\r\t\t\t\t-- BRIGHTNESS & AUTOMATIC\r\t\t\t\trepeat with iGroup from 1 to 2\r\t\t\t\t\t-- Find the right group\r\t\t\t\t\t-- 1 works on macOS 10.9 and 10.14, and some versions of 10.10.\r\t\t\t\t\t-- 2 works on macOS 10.11 through 10.13, and some versions of 10.10.\r\t\t\t\t\ttry\r\t\t\t\t\t\ttell group iGroup\r\t\t\t\t\t\t\tset oldBrightness to slider 1's value -- Get brightness\r\t\t\t\t\t\tend tell\r\t\t\t\t\t\tset groupOk to true\r\t\t\t\t\t\tset theGroup to iGroup\r\t\t\t\t\t\texit repeat\r\t\t\t\t\ton error errorMessage\r\t\t\t\t\t\tset groupOk to false\r\t\t\t\t\tend try\r\t\t\t\tend repeat\r\t\t\t\tif groupOk is false then\r\t\t\t\t\tset errorMsg to \"Could not find valid group for brightness.\"\r\t\t\t\telse\r\t\t\t\t\ttry\r\t\t\t\t\t\ttell group theGroup\r\t\t\t\t\t\t\t\r\t\t\t\t\t\t\t-- BRIGHTNESS\r\t\t\t\t\t\t\tset brightnessOk to false\r\t\t\t\t\t\t\tset oldBrightness to slider 1's value -- Get brightness\r\t\t\t\t\t\t\tif newBrightness > -1 then\r\t\t\t\t\t\t\t\tset slider 1's value to newBrightness -- Set brightness\r\t\t\t\t\t\t\t\t-- Check the poke by peeking.\r\t\t\t\t\t\t\t\t-- We can't demand equality (of peek and poke) because\r\t\t\t\t\t\t\t\t-- macOS uses only about 18-bit precision internally.\r\t\t\t\t\t\t\t\t--Visually, moving the slider causes a slow\r\t\t\t\t\t\t\t\t--fade. (Maybe that's why they gave it such high precision.) \r\t\t\t\t\t\t\t\t--It's possible that the value we\r\t\t\t\t\t\t\t\t--read similarly takes time to reach the\r\t\t\t\t\t\t\t\t--requested setting. So when we read a bad\r\t\t\t\t\t\t\t\t--value (different by at least 0.001 from the newBrightness we poked)\r\t\t\t\t\t\t\t\t--then we wait a bit and try again. After 2000 \r\t\t\t\t\t\t\t\t--poke-peek pairs with random brightnesses (0.0 to 1.0), \r\t\t\t\t\t\t\t\t--only 5 immediate peeks differed by at least 0.01, and only 11 differed \r\t\t\t\t\t\t\t\t-- by at least 0.0001. The rest were within \r\t\t\t\t\t\t\t\t--+\/- 5e-6 of the value poked. (The outliers were all \r\t\t\t\t\t\t\t\t--brighter than desired, suggesting that dimming is \r\t\t\t\t\t\t\t\t--slower than brightening.) In limited testing, this delay\r\t\t\t\t\t\t\t\t--seems to have eliminated the outliers, so the peek-poke \r\t\t\t\t\t\t\t\t--difference never exceeds +\/- 5e-6. Given\r\t\t\t\t\t\t\t\t--that the brightness always settles to the desired value\r\t\t\t\t\t\t\t\t--perhaps the extra peek is superfluous. I'm leaving it in\r\t\t\t\t\t\t\t\t--because MacDisplaySettings is slow anyway, due to applescript,\r\t\t\t\t\t\t\t\t--so the extra up to 200 ms of the peek seems good insurance\r\t\t\t\t\t\t\t\t--for detecting unanticipated problems in particular Macs,\r\t\t\t\t\t\t\t\t--or different versions of the macOS.\r\t\t\t\t\t\t\t\t\r\t\t\t\t\t\t\t\tset b to slider 1's value -- Get brightness\r\t\t\t\t\t\t\t\tset bErr to (b - newBrightness)\r\t\t\t\t\t\t\t\t--is the peek bad?\r\t\t\t\t\t\t\t\tif bErr > 1.0E-3 or bErr < -1.0E-3 then\r\t\t\t\t\t\t\t\t\t-- yep, it's bad. Wait and peek again.\r\t\t\t\t\t\t\t\t\tdelay 0.1\r\t\t\t\t\t\t\t\t\tset b to slider 1's value -- Get brightness\r\t\t\t\t\t\t\t\t\tset bErr to (b - newBrightness)\r\t\t\t\t\t\t\t\t\tif bErr > 1.0E-3 or bErr < -1.0E-3 then\r\t\t\t\t\t\t\t\t\t\terror \"Poked Brightness \" & newBrightness & \" but peeked \" & b & \".\"\r\t\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\t--Succeeded with Brightness.\r\t\t\t\t\t\t\t\r\t\t\t\t\t\t\t-- AUTOMATICALLY\r\t\t\t\t\t\t\ttell checkbox 1 -- Enable\/disable Automatically adjust brightness \r\t\t\t\t\t\t\t\tset oldAutomatically to value\r\t\t\t\t\t\t\t\tif newAutomatically is in {0, 1} and \u00ac\r\t\t\t\t\t\t\t\t\tnewAutomatically is not oldAutomatically then\r\t\t\t\t\t\t\t\t\tclick -- It's stale, so update it.\r\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\tend tell -- checkbox 1\r\t\t\t\t\t\t\t--Succeeded with Automatically.\r\t\t\t\t\t\t\t\r\t\t\t\t\t\tend tell -- group iGroup\r\t\t\t\t\t\t--Succeeded with Brightness and Automatically.\r\t\t\t\t\t\tset brightnessOk to true\r\t\t\t\t\ton error errorMessage\r\t\t\t\t\t\tset errorMsg to errorMessage\r\t\t\t\t\t\tset brightnessOk to false\r\t\t\t\t\tend try\r\t\t\t\tend if\r\t\t\t\t\r\t\t\tend tell\r\t\tend tell\r\tend tell\r\t\r\t-- This block of code selects the right window (a System Preferences window on \r\t-- the desired screen) and selects the Color pane within it. \r\ttell application \"System Events\"\r\t\ttell process \"System Preferences\"\r\t\t\ttell theWindow\r\t\t\t\tselect\r\t\t\t\tperform action \"AXRaise\" of theWindow\r\t\t\t\ttell tab group 1\r\t\t\t\t\ttell radio button 2\r\t\t\t\t\t\t--This click selects color.\r\t\t\t\t\t\tclick\r\t\t\t\t\tend tell\r\t\t\t\tend tell\r\t\t\tend tell\r\t\tend tell\r\tend tell\r\t\r\t-- COLOR PANEL\r\ttell application \"System Events\"\r\t\ttell process \"System Preferences\"\r\t\t\trepeat until exists tab group 1 of theWindow\r\t\t\t\tdelay 0.05\r\t\t\tend repeat\r\t\t\ttell tab group 1 of theWindow\r\t\t\t\t-- Show all profiles.\r\t\t\t\ttry\r\t\t\t\t\trepeat until exists checkbox 1\r\t\t\t\t\t\tdelay 0.05\r\t\t\t\t\tend repeat\r\t\t\t\t\ttell checkbox 1 -- Yes\/no: Show profiles for this display only. \r\t\t\t\t\t\tset oldShowProfilesForThisDisplayOnly to value\r\t\t\t\t\t\tif newShowProfilesForThisDisplayOnly is not equal to -1 then\r\t\t\t\t\t\t\t-- Set new value.\r\t\t\t\t\t\t\tif newShowProfilesForThisDisplayOnly is not equal to oldShowProfilesForThisDisplayOnly \u00ac\r\t\t\t\t\t\t\t\tthen\r\t\t\t\t\t\t\t\tclick\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\tend if\r\t\t\t\t\tend tell -- checkbox 1\r\t\t\t\t\t-- Read selection and select new Display Profile\r\t\t\t\t\trepeat until exists row 1 of table 1 of scroll area 1\r\t\t\t\t\t\tdelay 0.05\r\t\t\t\t\tend repeat\r\t\t\t\t\ttell table 1 of scroll area 1\r\t\t\t\t\t\tset oldProfile to value of static text 1 of \u00ac\r\t\t\t\t\t\t\t(row 1 where selected is true)\r\t\t\t\t\t\trepeat with profileRow from 1 to 101\r\t\t\t\t\t\t\tif selected of row profileRow then exit repeat\r\t\t\t\t\t\tend repeat\r\t\t\t\t\t\tset oldProfileRow to profileRow\r\t\t\t\t\t\tif oldProfileRow is 101 then\r\t\t\t\t\t\t\tset oldProfileRow to -1\r\t\t\t\t\t\t\terror \"Could not select Profile by row.\"\r\t\t\t\t\t\tend if\r\t\t\t\t\t\tif newProfileRow is not equal to -1 then\r\t\t\t\t\t\t\t--newProfileRow specifies Profile row.\r\t\t\t\t\t\t\tif selected of row newProfileRow is true then\r\t\t\t\t\t\t\t\t-- If the desired row is already selected\r\t\t\t\t\t\t\t\t-- then we first select and activate another row, \r\t\t\t\t\t\t\t\t-- and then reselect and activate the one we want. \r\t\t\t\t\t\t\t\t-- This makes sure that a fresh copy of the profile \r\t\t\t\t\t\t\t\t-- is loaded from disk.\r\t\t\t\t\t\t\t\tif newProfileRow is equal to 1 then\r\t\t\t\t\t\t\t\t\tselect last row\r\t\t\t\t\t\t\t\telse\r\t\t\t\t\t\t\t\t\tselect row 1\r\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\t\tactivate\r\t\t\t\t\t\t\t\tclick\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\tselect row newProfileRow\r\t\t\t\t\t\t\tactivate\r\t\t\t\t\t\t\tclick\r\t\t\t\t\t\t\tif selected of row newProfileRow is false then\r\t\t\t\t\t\t\t\terror \"Could not set Profile row.\"\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\telse\r\t\t\t\t\t\t\t--newProfile specifies Profile name.\r\t\t\t\t\t\t\tif newProfile is not equal to -1 then\r\t\t\t\t\t\t\t\ttry\r\t\t\t\t\t\t\t\t\tif selected of \u00ac\r\t\t\t\t\t\t\t\t\t\t(row 1 where value of static text 1 is newProfile) then\r\t\t\t\t\t\t\t\t\t\tif oldProfileRow is equal to 1 then\r\t\t\t\t\t\t\t\t\t\t\tselect last row\r\t\t\t\t\t\t\t\t\t\telse\r\t\t\t\t\t\t\t\t\t\t\tselect row 1\r\t\t\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\t\t\t\tactivate\r\t\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\t\t\tselect (row 1 where value of static text 1 is newProfile)\r\t\t\t\t\t\t\t\t\tactivate\r\t\t\t\t\t\t\t\t\tclick\r\t\t\t\t\t\t\t\ton error\r\t\t\t\t\t\t\t\t\terror \"Could not select Profile '\" & newProfile & \"' by name.\"\r\t\t\t\t\t\t\t\tend try\r\t\t\t\t\t\t\t\tif newProfile is not equal to value \u00ac\r\t\t\t\t\t\t\t\t\tof static text 1 of (row 1 where selected is true) then\r\t\t\t\t\t\t\t\t\terror \"Could not select Profile '\" & newProfile & \"' by name.\"\r\t\t\t\t\t\t\t\tend if\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\tend if\r\t\t\t\t\tend tell\r\t\t\t\t\tset profileOk to true\r\t\t\t\ton error errorMessage number errorNumber\r\t\t\t\t\tset profileOk to false\r\t\t\t\t\tset errorMsg to errorMessage\r\t\t\t\tend try\r\t\t\tend tell\r\t\tend tell\r\tend tell\r\t\r\t-- NIGHT SHIFT PANEL\r\ttell application \"System Preferences\"\r\t\treveal anchor \"displaysNightShiftTab\" of pane id \"com.apple.preference.displays\"\r\tend tell\r\ttell application \"System Events\"\r\t\ttell process \"System Preferences\"\r\t\t\trepeat until exists tab group 1 of theWindow\r\t\t\t\tdelay 0.05\r\t\t\tend repeat\r\t\t\ttell tab group 1 of theWindow\r\t\t\t\t\r\t\t\t\t-- NIGHT SHIFT MANUAL\r\t\t\t\ttry\r\t\t\t\t\ttell checkbox 1 -- Enable\/disable Night Shift Manual \r\t\t\t\t\t\tset oldNightShiftManual to value\r\t\t\t\t\t\t--display alert \"4 Read!\"\r\t\t\t\t\t\tif newNightShiftManual is in {0, 1} and \u00ac\r\t\t\t\t\t\t\tnewNightShiftManual is not oldNightShiftManual then\r\t\t\t\t\t\t\tclick -- It's stale, so update it.\r\t\t\t\t\t\t\t--display alert \"5 Wrote!\"\r\t\t\t\t\t\tend if\r\t\t\t\t\tend tell\r\t\t\t\t\t--Succeeded with Night Shift Manual.\r\t\t\t\t\tset manualOk to true\r\t\t\t\ton error\r\t\t\t\t\tset manualOk to false\r\t\t\t\tend try\r\t\t\t\t\r\t\t\t\t-- NIGHT SHIFT SCHEDULE\r\t\t\t\ttry\r\t\t\t\t\ttell pop up button 1 -- Select Night Shift Schedule \r\t\t\t\t\t\t-- We get the selection value, i.e. text which may \r\t\t\t\t\t\t-- be in foreign language.\r\t\t\t\t\t\tset theLabel to value\r\t\t\t\t\t\t-- Then we find it in the pop up menu and keep its index.\r\t\t\t\t\t\tclick -- reveal pop up menu\r\t\t\t\t\t\trepeat until exists menu 1\r\t\t\t\t\t\t\tdelay 0.05\r\t\t\t\t\t\tend repeat\r\t\t\t\t\t\trepeat with i from 1 to 3\r\t\t\t\t\t\t\tset x to name of menu item i of menu 1\r\t\t\t\t\t\t\tif theLabel is x then\r\t\t\t\t\t\t\t\tset oldNightShiftSchedule to i\r\t\t\t\t\t\t\t\texit repeat\r\t\t\t\t\t\t\tend if\r\t\t\t\t\t\tend repeat\r\t\t\t\t\t\t--Hit escape key to hide the menu.\r\t\t\t\t\t\tkey code 53\r\t\t\t\t\t\tif newNightShiftSchedule > 0 then\r\t\t\t\t\t\t\tclick\r\t\t\t\t\t\t\trepeat until exists menu 1\r\t\t\t\t\t\t\t\tdelay 0.05\r\t\t\t\t\t\t\tend repeat\r\t\t\t\t\t\t\tclick menu item newNightShiftSchedule of menu 1\r\t\t\t\t\t\tend if\r\t\t\t\t\tend tell\r\t\t\t\t\t--Succeeded with Night Shift Schedule.\r\t\t\t\t\tset scheduleOk to true\r\t\t\t\ton error\r\t\t\t\t\tset scheduleOk to false\r\t\t\t\tend try\r\t\t\t\t\r\t\t\tend tell\r\t\tend tell\r\tend tell\r\t\r\t--SHOW MAIN DISPLAYS PANEL AS WE LEAVE\r\ttell application \"System Preferences\"\r\t\treveal anchor \"displaysDisplayTab\" of pane id \"com.apple.preference.displays\"\r\tend tell\r\t\r\tif wasRunning or leaveSystemPrefsRunning then\r\t\t-- Leave it running.\r\telse\r\t\tquit application \"System Preferences\"\r\tend if\r\t\r\tif errorMsg as string is equal to \"\" then\r\t\tif not profileOk then set errorMsg to \"Could not peek\/poke Profile selection.\"\r\t\tif isNightShiftAvailable then\r\t\t\tif not manualOk then set errorMsg to \"Could not peek\/poke Night Shift manual.\"\r\t\t\tif not scheduleOk then set errorMsg to \"Could not peek\/poke Night Shift schedule.\"\r\t\tend if\r\t\t-- Many computers don't support True Tone, so we don't flag this as an error.\r\t\t-- It's enough that the field is left empty.\r\t\t--if not trueToneOk then set errorMsg to \"Could not peek\/poke True Tone.\"\r\t\tif not brightnessOk then set errorMsg to \"Could not peek\/poke Brightness and Automatically.\"\r\tend if\r\t\r\t-- RESTORE FRONTMOST APPLICATION (PROBABLY MATLAB).\r\tactivate application currentApp -- Restore active application.\r\t--delay 0.1 --Not sure if we need this at all.\r\t\r\treturn {oldBrightness, oldAutomatically, \u00ac\r\t\toldTrueTone, oldNightShiftSchedule, oldNightShiftManual, \u00ac\r\t\toldShowProfilesForThisDisplayOnly, oldProfileRow, \u00ac\r\t\t\"|\" & oldProfile & \"|\", \"|\" & errorMsg & \"|\"}\rend run\r","avg_line_length":32028.0,"max_line_length":32028,"alphanum_fraction":0.7248032971} +{"size":41,"ext":"scpt","lang":"AppleScript","max_stars_count":16.0,"content":"tell application \"Safari\"\n\tquit\nend tell\n","avg_line_length":10.25,"max_line_length":25,"alphanum_fraction":0.7804878049} +{"size":459,"ext":"applescript","lang":"AppleScript","max_stars_count":16.0,"content":"--\n-- AppleScripts for Avid Pro Tools.\n--\n-- Script description:\n-- Opens Inserts A-E panel.\n--\n-- (C) 2017 Ilya Putilin\n-- http:\/\/github.com\/fantopop\n-- \n\ntell application \"Finder\"\n\ttell application \"System Events\"\n\t\tset PT to the first application process whose creator type is \"PTul\"\n\t\ttell PT\n\t\t\tactivate\n\t\t\tset frontmost to true\n\t\t\t\n\t\t\tclick menu item \"Color Palette\" of menu \"Window\" of menu bar item \"Window\" of menu bar 1\n\t\tend tell\n\tend tell\nend tell","avg_line_length":21.8571428571,"max_line_length":91,"alphanum_fraction":0.7015250545} +{"size":2309,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"(*\n Mark Mynsted 2020-04-18\n Growing Liberty LLC \n Simplify providing values for placeholders used in templates\n*)\n\nuse framework \"Foundation\"\nuse scripting additions\n\n-- properties to make script more DRY\nproperty ca : a reference to current application -- current application\n\n\n(*\n-- might want later to read in placeholders or configuration data\n-- \nproperty NSJSONSerialization : a reference to ca's NSJSONSerialization -- marshal JSON\nhttps:\/\/developer.apple.com\/documentation\/foundation\/nsjsonserialization?language=occ\n\nproperty NSString : a reference to ca's NSString -- immutable string\nhttps:\/\/developer.apple.com\/documentation\/foundation\/nsstring?language=objc\n\nproperty NSUTF8StringEncoding : a reference to 4 -- 8-bit representation of Unicode characters\nhttps:\/\/developer.apple.com\/documentation\/foundation\/1497293-anonymous\/nsutf8stringencoding?language=objc\n\nproperty NSData : a reference to ca's NSData -- byte buffer\nhttps:\/\/developer.apple.com\/documentation\/foundation\/nsdata?language=objc\n--\n*)\n\n-- want now\nproperty NSDictionary : a reference to ca's NSDictionary -- immutable associative array\n-- https:\/\/developer.apple.com\/documentation\/foundation\/nsdictionary?language=objc\n\nproperty NSMutableDictionary : a reference to ca's NSMutableDictionary -- mutable associative array\n-- https:\/\/developer.apple.com\/documentation\/foundation\/nsmutabledictionary?language=objc\n\n\non reviewPlaceholders(orig)\n\t-- make immutable dictionary with source\n\tset sDict to NSDictionary's dictionaryWithDictionary:orig\n\t\n\t-- make mutable dictionary for results\n\tset res to NSMutableDictionary's dictionary\n\t\n\t-- obtain keys from original record\n\tset keys to sDict's allKeys()\n\t\n\t-- loop over the items to be reviewed\n\trepeat with theKey in keys\n\t\t-- get the value for this key \n\t\tset theRec to (sDict's valueForKey:theKey) as record\n\t\t\n\t\t-- display a dialog to capture changes to the value for the key\n\t\tset responseRec to display dialog (desc in theRec) default answer (val in theRec)\n\t\t-- set responseButtonName to the button returned of responseRec\n\t\tset responseText to the text returned of the responseRec\n\t\t\n\t\t-- add to NSMutableDictionary\n\t\t(res's setValue:responseText forKey:theKey)\n\tend repeat\n\t\n\t-- return the res as an AppleScript record\n\treturn res as record\nend reviewPlaceholders\n","avg_line_length":34.9848484848,"max_line_length":105,"alphanum_fraction":0.7882200087} +{"size":518,"ext":"applescript","lang":"AppleScript","max_stars_count":86.0,"content":"on run(q)\n set theURLs to \"\"\n set oldItemDelimiters to text item delimiters\n set text item delimiters to \", \"\n set qList to every text item of (q as text)\n set text item delimiters to oldItemDelimiters\n repeat with aTarget in qList\n set aTarget to (POSIX file aTarget as alias)\n tell application \"System Events\" to set aTarget to URL of aTarget\n if theURLs is \"\" then\n set theURLs to aTarget\n else\n set theURLs to theURLs & \", \" & aTarget\n end if\n end repeat\n return (theURLs)\nend run\n","avg_line_length":28.7777777778,"max_line_length":69,"alphanum_fraction":0.6988416988} +{"size":1007,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"use AppleScript version \"2.4\" -- Yosemite (10.10) or later\ruse scripting additions\r\ron displayMessage(message)\r\tdisplay notification \"Disk \" & message with title \"TogglMount\" subtitle \"Operation Complete\"\rend displayMessage\r\r# Toggles the mount\/unmounting of the storage disk through Arch Linux\rto mountDisk()\r\tdo shell script \"ssh -t dthole@localarch 'sudo \/home\/dthole\/tools\/bin\/mount_storage'\"\r\tdelay 3\r\ttell application \"Finder\"\r\t\tmount volume \"smb:\/\/localarch\/Storage_Disk\"\r\t\tmount volume \"smb:\/\/localarch\/Public_Storage_Disk\"\r\tend tell\rend mountDisk\r\rto unmountDisk()\r\ttell application \"Finder\"\r\t\teject disk \"Storage_Disk\"\r\t\teject disk \"Public_Storage_Disk\"\r\tend tell\r\tdelay 3\r\tdo shell script \"ssh -t dthole@localarch 'sudo \/home\/dthole\/tools\/bin\/umount_storage'\"\rend unmountDisk\r\rtell application \"Finder\"\r\tset mounted_Disks to list disks\rend tell\r\rif mounted_Disks does not contain \"Storage_Disk\" then\r\tmountDisk()\r\tdisplayMessage(\"Mounted\")\relse\r\tunmountDisk()\r\tdisplayMessage(\"Unmounted\")\rend if\r","avg_line_length":1007.0,"max_line_length":1007,"alphanum_fraction":0.7805362463} +{"size":712,"ext":"applescript","lang":"AppleScript","max_stars_count":3305.0,"content":"#!\/usr\/bin\/osascript\n\n# @raycast.title Refresh Wallpaper\n# @raycast.author Caleb Stauffer\n# @raycast.authorURL https:\/\/github.com\/crstauf\n# @raycast.description Apply a random image from the [wallpaper directory](https:\/\/support.apple.com\/guide\/mac-help\/change-your-desktop-picture-mchlp3013\/mac) for the main display's current [Space](https:\/\/support.apple.com\/guide\/mac-help\/work-in-multiple-spaces-mh14112\/mac).\n\n# @raycast.icon \ud83d\uddbc\ufe0f\n# @raycast.mode silent\n# @raycast.packageName System\n# @raycast.schemaVersion 1\n\ntell application \"System Events\"\n\tset rotinterval to change interval of current desktop\n\tset change interval of current desktop to rotinterval\nend tell\n\ndo shell script \"echo Refreshed wallpaper\"\n","avg_line_length":37.4736842105,"max_line_length":276,"alphanum_fraction":0.7865168539} +{"size":130,"ext":"scpt","lang":"AppleScript","max_stars_count":5.0,"content":"tell application \"Finder\"\n\tmake new Finder window\n\tset target of front window to path to home folder as string\n\tactivate\nend tell\n","avg_line_length":21.6666666667,"max_line_length":60,"alphanum_fraction":0.7923076923} +{"size":2643,"ext":"scpt","lang":"AppleScript","max_stars_count":36.0,"content":"# =============================================================================\n# @file\t Create document from template.applescript\n# @brief Script to create a document from a template and name it\n# @author Michael Hucka \n# @license MIT license -- please see the file LICENSE in the parent directory\n# @repo\t https:\/\/github.com\/mhucka\/devonthink-hacks\n# =============================================================================\n\n# Configuration variables -- THE FOLLOWING MUST BE UPDATED MANUALLY\n# .............................................................................\n\nset templates to {\"Clipboard to markdown.md\", \"Code.md\", \"Diary.ooutline\", \u00ac\n\t\"Document.ooutline\", \"Goal plan.ooutline\", \"Markdown.md\", \u00ac\n\t\"Meeting.ooutline\", \"Note.ooutline\", \"Plain text.txt\", \u00ac\n\t\"Reading notes.ooutline\", \"Term.ooutline\"}\n\n\n# Helper functions\n# .............................................................................\n\n# The following code is based on a function posted by \"jobu\" on 2004-08-11\n# at https:\/\/macscripter.net\/viewtopic.php?pid=32191#p32191\n\non withoutExtension(name)\n\tif name contains \".\" then\n\t\tset delim to AppleScript's text item delimiters\n\t\tset AppleScript's text item delimiters to \".\"\n\t\tset basename to (text items 1 through -2 of (name as string) as list) as string\n\t\tset AppleScript's text item delimiters to delim\n\t\treturn basename\n\telse\n\t\treturn name\n\tend if\nend withoutExtension\n\n\n# Main body\n# .............................................................................\n\ntell application id \"DNtp\"\n\tset templateNames to {}\n\trepeat with t from 1 to length of templates\n\t\tcopy my withoutExtension(item t of templates) to the end of templateNames\n\tend repeat\n\n\tset chosenTemplate to first item of (choose from list templateNames \u00ac\n\t\twith prompt \"Template to use for new document:\" default items {\"Notebook\"})\n\n\tset prompt to \"Name for the new \" & chosenTemplate & \" document:\"\n\tset reply to display dialog prompt default answer \"\"\n\tset docName to text returned of reply\n\n\tset templateDir to \"\/Users\/\" & (short user name of (system info)) \u00ac\n\t\t& \"\/Library\/Application Support\/DEVONthink 3\/Templates.noindex\/\"\n\n\trepeat with n from 1 to (count of templateNames)\n\t\tif templates's item n starts with chosenTemplate then\n\t\t\tset templatePath to (POSIX path of templateDir & templates's item n)\n\t\tend if\n\tend repeat\n\n\tset newRecord to import templatePath to current group\n\tset creation date of newRecord to current date\n\tset modification date of newRecord to current date\n\tset the name of newRecord to docName\n\ttry\n\t\tperform smart rule \"auto-label my notes\" record newRecord\n\tend try\nend tell\n\n\n","avg_line_length":36.7083333333,"max_line_length":81,"alphanum_fraction":0.6375331063} +{"size":402,"ext":"applescript","lang":"AppleScript","max_stars_count":27.0,"content":"\non run argv\n set slideid to (item 2 of argv)\n tell document id (item 1 of argv) of application \"Keynote\"\n set notes to the presenter notes of every slide\n repeat with i from 1 to the count of notes\n set notei to item i of notes\n\t if (offset of slideid in notei) > 0\n return i\n end if\n end repeat\n return 0\n end tell\nend run\n","avg_line_length":26.8,"max_line_length":62,"alphanum_fraction":0.5895522388} +{"size":972,"ext":"scpt","lang":"AppleScript","max_stars_count":1.0,"content":"on run argv\n set diskImage to item 1 of argv\n\n tell application \"Finder\"\n tell disk diskImage\n open\n set current view of container window to icon view\n set toolbar visible of container window to false\n set statusbar visible of container window to false\n set the bounds of container window to {400, 100, 1000, 550}\n set theViewOptions to the icon view options of container window\n set arrangement of theViewOptions to not arranged\n set icon size of theViewOptions to 72\n set background picture of theViewOptions to file \".background:background.png\"\n set position of item \"Tenacity\" of container window to {170, 350}\n set position of item \"Applications\" of container window to {430, 350}\n close\n open\n update without registering applications\n end tell\n end tell\nend run\n","avg_line_length":42.2608695652,"max_line_length":91,"alphanum_fraction":0.6244855967} +{"size":999,"ext":"scpt","lang":"AppleScript","max_stars_count":4.0,"content":"#! \/usr\/bin\/env osascript\n# no restart needed: http:\/\/apple.stackexchange.com\/questions\/168540\/show-hide-hidden-files-without-restarting-finder?newsletter=1&nlcode=57435|323e\n\n\nset newHiddenVisiblesState to \"YES\"\ntry\n set oldHiddenVisiblesState to do shell script \"defaults read com.apple.finder AppleShowAllFiles\"\n if oldHiddenVisiblesState is in {\"1\", \"YES\"} then\n set newHiddenVisiblesState to \"NO\"\n end if\nend try\ndo shell script \"defaults write com.apple.finder AppleShowAllFiles \" & newHiddenVisiblesState\n\ntell application \"Finder\"\n set theWindows to every Finder window\n repeat with i from 1 to number of items in theWindows\n set this_item to item i of theWindows\n set theView to current view of this_item\n if theView is list view then\n set current view of this_item to icon view\n else\n set current view of this_item to list view\n\n end if\n set current view of this_item to theView\n end repeat\nend tell\n","avg_line_length":35.6785714286,"max_line_length":148,"alphanum_fraction":0.7257257257} +{"size":118,"ext":"scpt","lang":"AppleScript","max_stars_count":2.0,"content":"tell application \"System Preferences\"\n\t\t\n\tset current pane to pane id \"com.slimdevices.slim\"\n\t\t\n\tactivate\n\t\t\nend tell\n","avg_line_length":14.75,"max_line_length":51,"alphanum_fraction":0.7372881356} +{"size":314,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"tell application \"BBEdit\"\n\ttell window 1\n\t\tset dialog_results to display dialog \"wrap text in?\" default answer \"****\"\n\t\tset wrapping_string to text returned of dialog_results\n\t\tget selection as string\n\t\tset selection to wrapping_string & return & (selection as string) & return & wrapping_string\n\tend tell\nend tell","avg_line_length":39.25,"max_line_length":94,"alphanum_fraction":0.7707006369} +{"size":96,"ext":"applescript","lang":"AppleScript","max_stars_count":2.0,"content":"on run arg\n\t--do whatever you want with arg\n\tlog arg's first item\n\tlog arg's second item\nend run","avg_line_length":19.2,"max_line_length":32,"alphanum_fraction":0.7395833333} +{"size":254,"ext":"applescript","lang":"AppleScript","max_stars_count":3.0,"content":"on run {targetBuddyPhone, targetMessage}\ntell application \"Messages\"\n set targetService to 1st service whose service type = iMessage\n set targetBuddy to buddy targetBuddyPhone of targetService\n send targetMessage to targetBuddy\nend tell\nend run\n","avg_line_length":31.75,"max_line_length":66,"alphanum_fraction":0.8031496063} +{"size":1330,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"(* Version 1.1 thomas@dyhr.com March 2021 \nnote: implement with automator - service - run applescript\n*)\non run {input, parameters}\n\t\n\tset chosenFile to \"\"\n\t-- get file\n\tif (count of input) is 1 then\n\t\tset chosenFile to input\n\telse\n\t\tdisplay alert \"Multible selections are not allowed!\" as warning giving up after 5\n\tend if\n\t\n\t-- get filename\n\tset fileName to name of (info for chosenFile)\n\t\n\t-- get the sha256 checksum text...\n\tset checkSum to the text returned of (display dialog \"Paste SHA1\" default answer \"\" with title fileName)\n\t\n\t-- Calculate MD5 sum checksum quitely and translate to UPPER case\n\tset checkSumResult to first word of (do shell script \"\/usr\/bin\/openssl dgst -sha1 \" & quoted form of POSIX path of chosenFile & \" | awk '{print $2}'\")\n\t\n\t\n\t-- compairing check sums\n\tignoring white space\n\t\tcheckSumResult = checkSum\n\tend ignoring\n\tset checkSumComp to result\n\t\n\t-- setting & formating display text\n\tset displayText to \"\n\t\" & checkSum & \"\n\t\" & first word of checkSumResult & \"\n\t\"\n\t\n\t-- show checksum results to user\n\tif checkSumComp = true then\n\t\tdisplay dialog displayText & \"SHA1 OK!\" buttons {\"OK\"} default button \"OK\" with title fileName\n\telse\n\t\tdisplay dialog displayText & \"NB! No SHA1 match!\" buttons {\"CANCEL\"} default button \"CANCEL\" with title fileName with icon caution\n\tend if\n\t\n\treturn input\nend run","avg_line_length":30.2272727273,"max_line_length":151,"alphanum_fraction":0.7233082707} +{"size":1263,"ext":"scpt","lang":"AppleScript","max_stars_count":2.0,"content":"(*\n\tSCRIPT CREATED BY LUO YU, INDIE.LUO@GMAIL.COM\n\tTHURSDAY, MAY 10, 2018\n *)\n\ntell application \"System Events\"\n\n\t-- OPEN ITERMS\n\tkeystroke space using {control down}\n\n\t-- WAIT FOR IT INITIALIZED\n\tdelay 1\n\n\t-- CHANGE INPUT METHOD ENGLISH MODE\n\t--key down shift\n\t--key up shift\n\n\t-- SPLIT WINDOWS AS THREE COLUMNS\n\tkeystroke \"d\" using {command down}\n\tkeystroke \"d\" using {command down}\n\n\t-- RUN HTOP AT 3RD COLUMN\n\tkeystroke \"htop\"\n\tkeystroke return\n\n\t-- MOVE TO 2ND COLUMN\n\tkeystroke \"[\" using {command down}\n\n\t-- SPLIT UP & DOWN\n\tkeystroke \"d\" using {command down, shift down}\n\n\t-- RUN UPDATE COCOAPODS AND BREW LIBS SHELL SCRIPT\n\tkeystroke \".\/updates.sh\"\n\tkeystroke return\n\t-- WAIT FOR IT RESPONSE\n\tdelay 1\n\n\t-- MOVE UP\n\tkeystroke \"[\" using {command down}\n\t-- MOVE TO GITHUB PROJECTS FOLDER AND LIST FILES\n\tkeystroke \"la && cd Project\/GitHub && la\"\n\tkeystroke return\n\n\t-- MOVE TO 1ST COLUMN\n\tkeystroke \"[\" using {command down}\n\n\t-- MOVE TO WORKING PROJECT FOLDER AND LIST ALL FILES WITH GIT STATUS\n\tkeystroke \"la && cd Project\/com.company\/workin_app && la && git status\"\n\tkeystroke return\n\n\t-- OPEN XCODE WORKSPACE\n\tkeystroke \"openws\"\n\tkeystroke return\n\n\t-- WAIT XCODE TO RESPONSE\n\tdelay 3\n\n\t-- GO BACK TO ITERMS\n\tkeystroke space using {control down}\n\nend tell\n","avg_line_length":20.3709677419,"max_line_length":72,"alphanum_fraction":0.7110055424} +{"size":143,"ext":"scpt","lang":"AppleScript","max_stars_count":3715.0,"content":"if application \"Spotify\" is running then\n\ttell application \"Spotify\"\n\t\tif player state is playing then\n\t\t\tnext track\n\t\tend if\n\tend tell\nend if\n","avg_line_length":17.875,"max_line_length":40,"alphanum_fraction":0.7482517483} +{"size":152,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"tell application \"Chromium\"\n activate\n tell application \"System Events\"\n key code 40 using {shift down, command down}\n end tell\nend tell","avg_line_length":25.3333333333,"max_line_length":52,"alphanum_fraction":0.6973684211} +{"size":915,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- fmGUI_ManageDb_GoToTab_Fields({})\n-- Erik Shagdar, NYHTC\n-- Go to the \"Fields\" tab of manage database\n\n\n(*\nHISTORY:\n\t1.4 - 2016-06-30 ( eshagdar ): use fmGUI_ManageDb_GoToTab(prefs) handler. Renamed from 'fmGUI_ManageDb_FieldsTab' to 'fmGUI_ManageDb_GoToTab_Fields'\n\t1.3 - 2016-03-18 ( eshagdar ): use reference to tab control object to deal with different FM app types running concurrently.\n\t1.2 - only click if needed\n\t1.1 - \n\t1.0 - created\n\n\nREQUIRES:\n\tfmGUI_ManageDb_GoToTab\n*)\n\n\non run\n\tfmGUI_ManageDb_GoToTab_Fields({})\nend run\n\n--------------------\n-- START OF CODE\n--------------------\n\non fmGUI_ManageDb_GoToTab_Fields(prefs)\n\t-- version 1.4\n\t\n\tfmGUI_ManageDb_GoToTab({tabName:\"Fields\"})\n\t\nend fmGUI_ManageDb_GoToTab_Fields\n\n--------------------\n-- END OF CODE\n--------------------\n\non fmGUI_ManageDb_GoToTab(prefs)\n\ttell application \"htcLib\" to fmGUI_ManageDb_GoToTab(prefs)\nend fmGUI_ManageDb_GoToTab\n","avg_line_length":21.7857142857,"max_line_length":149,"alphanum_fraction":0.6961748634} +{"size":116,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"tell application \"Google Chrome\"\n\tmake new window\n\tset URL of active tab of window 0 to \"http:\/\/google.com\"\nend tell","avg_line_length":29.0,"max_line_length":57,"alphanum_fraction":0.7586206897} +{"size":1471,"ext":"applescript","lang":"AppleScript","max_stars_count":3.0,"content":"on open droppedItems\n\t\n\tset theOutputFolder to choose folder with prompt \"Please select an output folder:\"\n\t\n\trepeat with a from 1 to count of droppedItems\n\t\tset current to item a of droppedItems\n\t\ttell application \"Finder\"\n\t\t\tset was_hidden to extension hidden of current\n\t\t\tset extension hidden of current to true\n\t\t\tset currentWithout to displayed name of current\n\t\t\tset ext to name extension of current\n\t\t\tset extension hidden of current to was_hidden\n\t\tend tell\n\t\tset target to (theOutputFolder as text) & currentWithout & \".pdf\"\n\t\tif (ext = \"doc\") or (ext = \"docx\") then\n\t\t\tsaveWordAsPDF(current, target)\n\t\telse if (ext = \"xls\") or (ext = \"xlsx\") then\n\t\t\tsaveExcelAsPDF(current, target)\n\t\tend if\n\tend repeat\nend open\n\non saveExcelAsPDF(documentPath, PDFPath)\n\tset tFile to (POSIX path of documentPath) as POSIX file\n\ttell application \"Microsoft Excel\"\n\t\tset isRun to running\n\t\tset wkbk1 to open workbook workbook file name tFile\n\t\talias PDFPath\n\t\tsave workbook as wkbk1 filename PDFPath file format PDF file format\n\t\tclose wkbk1 saving no\n\t\tif not isRun then quit\n\tend tell\nend saveExcelAsPDF\n\non saveWordAsPDF(documentPath, PDFPath)\n\tset tFile to (POSIX path of documentPath) as POSIX file\n\ttell application \"Microsoft Word\"\n\t\tset isRun to running\n\t\topen tFile\n\t\tset theDocument to active document\n\t\talias PDFPath\n\t\tsave as active document file name PDFPath file format format PDF\n\t\tclose theDocument saving no\n\t\tif not isRun then quit\n\tend tell\nend saveWordAsPDF\n","avg_line_length":31.2978723404,"max_line_length":83,"alphanum_fraction":0.7634262407} +{"size":195,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"tell application \"Viscosity\"\n if the state of the first connection is \"Connected\" then\n disconnect the first connection\n else\n connect the first connection\n end if\nend tell","avg_line_length":27.8571428571,"max_line_length":60,"alphanum_fraction":0.7076923077} +{"size":399,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"-- ___FILENAME___\n-- ___PACKAGENAME___\n\n-- Created by ___FULLUSERNAME___ on ___DATE___.\n-- ___COPYRIGHT___\n\nscript ___PACKAGENAMEASIDENTIFIER___\n\tproperty parent : class \"AMBundleAction\"\n\t\n\ton runWithInput_fromAction_error_(input, anAction, errorRef)\n\t\t-- Add your code here, returning the data to be passed to the next action.\n\t\t\n\t\treturn input\n\tend runWithInput_fromAction_error_\n\t\nend script\n","avg_line_length":23.4705882353,"max_line_length":76,"alphanum_fraction":0.7894736842} +{"size":135,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"#!\/usr\/loca\/bin\/osascript\ntell application \"iCal\"\n\trepeat with t in every todo of every calendar\n\t\tproperties of t\n\tend repeat\nend tell","avg_line_length":22.5,"max_line_length":46,"alphanum_fraction":0.7703703704} +{"size":1373,"ext":"applescript","lang":"AppleScript","max_stars_count":2.0,"content":"set MIN_VALUE to 64\nset MAX_VALUE to 255\nset STEP_SIZE to 30\n\nset RED_FACTOR to 1.0\nset GREEN_FACTOR to 0.635\nset BLUE_FACTOR to 0.295\n\non brighter(brightness)\n global MAX_VALUE, STEP_SIZE\n set brightness to brightness + STEP_SIZE\n if brightness > MAX_VALUE then\n set brightness to MAX_VALUE\n end if\n return brightness\nend brighter\n\non darker(brightness)\n global MIN_VALUE, STEP_SIZE\n set brightness to brightness - STEP_SIZE\n if brightness < MIN_VALUE then\n set brightness to MIN_VALUE\n end if\n return brightness\nend darker\n\ntell application \"DarkAdapted\"\n set rgb to getGamma\nend tell\n\nset oldDelimiters to AppleScript's text item delimiters\nset AppleScript's text item delimiters to \",\"\nset rgb to every text item of rgb\nset AppleScript's text item delimiters to oldDelimiters\n\nset red to (item 1 of rgb as integer)\nset green to (item 2 of rgb as integer)\nset blue to (item 3 of rgb as integer)\n\n# log \"old rgb = \" & red & \",\" & green & \",\" & blue\n\nset brightness to brighter(red)\n# set brightness to darker(red)\n\nset red to (brightness * RED_FACTOR) as integer\nset green to (brightness * GREEN_FACTOR) as integer\nset blue to (brightness * BLUE_FACTOR) as integer\n\nset newrgb to \"\" & red & \",\" & green & \",\" & blue\n\n# log \"new rgb = \" & newrgb\n\ntell application \"DarkAdapted\"\n setGamma value newrgb\nend tell\n","avg_line_length":24.5178571429,"max_line_length":55,"alphanum_fraction":0.7203204661} +{"size":1786,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- @description Speaker Polarity Check\n-- @author Ben Smith\n-- @link bensmithsound.uk\n-- @version 1.0\n-- @testedmacos 10.13.6\n-- @testedqlab 4.6.9\n-- @about Designed to work with the android app \"Polarity Checker\", with audio files stored in a hidden cue list. This script launches audio files.\n-- @separateprocess TRUE\n\n-- @changelog\n-- v1.0 + init\n\n\n-- RUN SCRIPT -----------------------------\n\n-- If there is no audio, check the routing of the audio files (in \"Other Scripts\")\n\ntell application id \"com.figure53.Qlab.4\" to tell front workspace\n\t\n\tset playbackOptions to {\"STOP\", \"Full Range\", \"80 Hz\", \"160 Hz\", \"500 Hz\", \"1k2 Hz\", \"4 kHz\"}\n\t\n\tset polarityCheck to choose from list playbackOptions with title \"Sample Selection\" with prompt \"Select the sample to play\"\n\tif polarityCheck is {\"STOP\"} then\n\t\tif cue \"SPC\" is running then\n\t\t\tstop cue \"SPC\"\n\t\t\treturn\n\t\telse\n\t\t\treturn\n\t\tend if\n\telse if polarityCheck is false then\n\t\treturn\n\tend if\n\t\n\tdisplay dialog \"Invert signal?\" buttons {\"Yes\", \"No\"} default button \"No\"\n\tset invertCheck to button returned of result\n\t\n\tif polarityCheck is {\"Full Range\"} then set cueNum to \"All\"\n\tif polarityCheck is {\"80 Hz\"} then set cueNum to \"80\"\n\tif polarityCheck is {\"160 Hz\"} then set cueNum to \"160\"\n\tif polarityCheck is {\"500 Hz\"} then set cueNum to \"500\"\n\tif polarityCheck is {\"1k2 Hz\"} then set cueNum to \"1k2\"\n\tif polarityCheck is {\"4 Khz\"} then set cueNum to \"4k\"\n\t\n\tif invertCheck is \"Yes\" then set cuePrefix to \"i\"\n\tif invertCheck is \"No\" then set cuePrefix to \"n\"\n\t\n\tset fullCueNumber to cuePrefix & cueNum as string\n\t\n\tif cue \"SPC\" is running then\n\t\tif cue fullCueNumber is running then\n\t\t\tstop cue \"SPC\"\n\t\telse\n\t\t\tstop cue \"SPC\"\n\t\t\tdelay 0.1\n\t\t\tstart cue fullCueNumber\n\t\tend if\n\telse\n\t\tstart cue fullCueNumber\n\tend if\n\t\n\t\nend tell","avg_line_length":28.8064516129,"max_line_length":147,"alphanum_fraction":0.6942889138} +{"size":347,"ext":"applescript","lang":"AppleScript","max_stars_count":24.0,"content":"(*\n
.applescript\nSample Script for CotEditor\n\nDescription:\nReplace the selection with .\n\nwritten by nakamuxu on 2005-03-14\nmodified by 1024jp on 2015\n*)\n\n--\nproperty newStr : \"\"\n\n--\ntell application \"CotEditor\"\n\tif not (exists front document) then return\n\t\n\ttell front document\n\t\tset contents of selection to newStr\n\tend tell\nend tell","avg_line_length":15.7727272727,"max_line_length":43,"alphanum_fraction":0.7406340058} +{"size":1970,"ext":"applescript","lang":"AppleScript","max_stars_count":3305.0,"content":"#!\/usr\/bin\/osascript\n\n# Dependencies:\n# MeetingBar: https:\/\/github.com\/leits\/MeetingBar\n\n# Recommended installation:\n# brew install --cask meetingbar\n\n# Required parameters:\n# @raycast.schemaVersion 1\n# @raycast.title Join Meeting\n# @raycast.mode silent\n\n# Optional parameters:\n# @raycast.icon images\/meetingbar.png\n# @raycast.packageName MeetingBar\n\n# Documentation:\n# @raycast.author Jakub Lanski\n# @raycast.authorURL https:\/\/github.com\/jaklan\n# @raycast.description Join the ongoing or upcoming meeting.\n\non run\n\t\n\ttry\n\t\trunMeetingBar()\n\t\tjoinMeeting()\n\t\treturn\n\t\t\n\ton error errorMessage\n\t\tcloseMenu()\n\t\treturn errorMessage\n\t\t\n\tend try\n\t\nend run\n\n### Functions ###\n\non joinMeeting()\n\topenMenu()\n\ttell application \"System Events\" to tell application process \"MeetingBar\"\n\t\ttell menu 1 of menu bar item 1 of menu bar 2\n\t\t\tif menu item \"Join current event meeting\" exists then\n\t\t\t\tclick menu item \"Join current event meeting\"\n\t\t\telse if menu item \"Join next event meeting\" exists then\n\t\t\t\tclick menu item \"Join next event meeting\"\n\t\t\telse\n\t\t\t\terror \"No meetings found\"\n\t\t\tend if\n\t\tend tell\n\tend tell\nend joinMeeting\n\non MeetingBarIsRunning()\n\treturn application \"MeetingBar\" is running\nend MeetingBarIsRunning\n\non runMeetingBar()\n\tif not MeetingBarIsRunning() then do shell script \"open -a 'MeetingBar'\"\nend runMeetingBar\n\non menuIsOpen()\n\ttell application \"System Events\" to tell application process \"MeetingBar\"\n\t\treturn menu 1 of menu bar item 1 of menu bar 2 exists\n\tend tell\nend menuIsOpen\n\non openMenu()\n\tset killDelay to 0\n\trepeat\n\t\ttell application \"System Events\" to tell application process \"MeetingBar\"\n\t\t\tif my menuIsOpen() then return\n\t\t\tignoring application responses\n\t\t\t\tclick menu bar item 1 of menu bar 2\n\t\t\tend ignoring\n\t\tend tell\n\t\tset killDelay to killDelay + 0.1\n\t\tdelay killDelay\n\t\tdo shell script \"killall System\\\\ Events\"\n\tend repeat\nend openMenu\n\non closeMenu()\n\tif menuIsOpen() then tell application \"System Events\" to key code 53\nend closeMenu","avg_line_length":22.9069767442,"max_line_length":75,"alphanum_fraction":0.7517766497} +{"size":357,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"set appname to \"Pulse Secure\"\n\ntell application appname\n\tif it is not running then\n\t\tactivate\n\tend if\nend tell\n\ntell application \"System Events\"\n\ttell process \"Pulse Secure\"\n\t\tset frontmost to true\n\t\tclick menu item \"Connect\" of menu of menu item \"Connections\" of menu \"File\" of menu bar 1\n\t\tdelay 2\n\t\tkeystroke \"push\"\n\t\tkeystroke return\n\tend tell\nend tell\n","avg_line_length":19.8333333333,"max_line_length":91,"alphanum_fraction":0.7478991597} +{"size":1004,"ext":"applescript","lang":"AppleScript","max_stars_count":16.0,"content":"use BibDesk : application \"BibDesk\"\nuse scripting additions\n\ntell BibDesk\n\tset theDoc to get first document\n\tset originalPub to selection of theDoc\n\tset originalPub to item 1 of originalPub\n\tset theDoi to value of originalPub's field \"DOI\"\n\tif theDoi = \"\" then\n\t\tdisplay notification \"There is no DOI there.\"\n\t\treturn\n\tend if\n\t\n\tset tempPub to (import theDoc from theDoi)\n\t\n\tif length of tempPub = 1 then\n\t\tset tempPub to item 1 of tempPub\n\telse\n\t\tdisplay notification \"Umm, I didn't find anything at that DOI. Bummer.\"\n\t\treturn\n\tend if\n\t\n\tset theNewFields to every field of tempPub\n\trepeat with theField in every field of tempPub\n\t\tset fieldName to name of theField\n\t\tset value of field fieldName of originalPub to (get value of field fieldName of tempPub)\n\tend repeat\n\tdelete tempPub\n\t\n\tset originalPub's cite key to originalPub's generated cite key\n\tif linked file of originalPub is not {} then auto file originalPub\n\t\n\tselect originalPub -- So it appears nicely at the top of the window\nend tell\n\n\n\n\n","avg_line_length":25.7435897436,"max_line_length":90,"alphanum_fraction":0.7619521912} +{"size":247,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"#!\/usr\/bin\/osascript\n\n# Required parameters:\n# @raycast.schemaVersion 1\n# @raycast.title Play\n# @raycast.mode silent\n# @raycast.packageName Spotify\n\n# Optional parameters:\n# @raycast.icon images\/spotify-logo.png\n\ntell application \"Spotify\" to play","avg_line_length":20.5833333333,"max_line_length":39,"alphanum_fraction":0.7651821862} +{"size":669,"ext":"applescript","lang":"AppleScript","max_stars_count":3305.0,"content":"#!\/usr\/bin\/osascript\n\n# Required parameters:\n# @raycast.schemaVersion 1\n# @raycast.title Open Current Terminal Directory in Finder\n# @raycast.mode silent\n# @raycast.packageName Navigation\n#\n# Optional parameters:\n# @raycast.icon \ud83d\udcdf\n#\n# Documentation:\n# @raycast.description Open current Terminal directory in Finder\n# @raycast.author Kirill Gorbachyonok\n# @raycast.authorURL https:\/\/github.com\/japanese-goblinn\n\ntell application \"Terminal\"\n if not (exists window 1) then reopen\n activate\n if busy of window 1 then\n tell application \"System Events\" to keystroke \"t\" using command down\n end if\n do script \"open -a Finder .\/\" in window 1\nend tell\n","avg_line_length":26.76,"max_line_length":76,"alphanum_fraction":0.735426009} +{"size":2549,"ext":"applescript","lang":"AppleScript","max_stars_count":3.0,"content":"--removes characters from beginning or end of string\non trim_line(this_text, trim_chars, trim_indicator)\n\t-- 0 = beginning, 1 = end, 2 = both\n\tset x to the length of the trim_chars\n\t-- TRIM BEGINNING\n\tif the trim_indicator is in {0, 2} then\n\t\trepeat while this_text begins with the trim_chars\n\t\t\ttry\n\t\t\t\tset this_text to characters (x + 1) thru -1 of this_text as string\n\t\t\ton error\n\t\t\t\t-- the text contains nothing but the trim characters\n\t\t\t\treturn \"\"\n\t\t\tend try\n\t\tend repeat\n\tend if\n\t-- TRIM ENDING\n\tif the trim_indicator is in {1, 2} then\n\t\trepeat while this_text ends with the trim_chars\n\t\t\ttry\n\t\t\t\tset this_text to characters 1 thru -(x + 1) of this_text as string\n\t\t\ton error\n\t\t\t\t-- the text contains nothing but the trim characters\n\t\t\t\treturn \"\"\n\t\t\tend try\n\t\tend repeat\n\tend if\n\treturn this_text\nend trim_line\n\ntell application \"Finder\"\n\tset sel to selection as alias\n\tset filePath to sel as string\n\tset fileName to name of sel\n\tset noExt to my trim_line(fileName, \".psd\", 1)\n\tset parentFolder to my trim_line(filePath, fileName, 1)\n\tset qxp to parentFolder & noExt & \".qxp\" as string\n\n\tset selection to parentFolder\nend tell\n\ntell application \"Adobe Photoshop CS6\"\n\tdo javascript file \"Macintosh HD:Applications:Adobe Photoshop CS6:Presets:Scripts:save&exportEPS.jsx\"\nend tell\n\n(*tell application \"QuarkXPress\"\n\n\topen file qxp\n\n\ttell document 1\n\n\t\tset allBoxes to every generic box\n\n\t\trepeat with thisBox in allBoxes\n\t\t\t-- name die line\n\t\t\tif name of color of frame of thisBox is \"Die Cut\" then\n\t\t\t\tset name of thisBox to \"Die Cut\"\n\t\t\tend if\n\n\t\t\tif class of thisBox is picture box then\n\n\t\t\t\t--update BG image to new image\n\n\t\t\t\tset filePath to file path of image 1 of thisBox\n\t\t\t\tif filePath is not no disk file then\n\t\t\t\t\ttell application \"Finder\"\n\t\t\t\t\t\tset filePath to filePath as alias\n\t\t\t\t\t\tset imgName to name of filePath\n\t\t\t\t\t\tset imgParent to my trim_line(filePath as string, imgName, 1)\n\t\t\t\t\t\tset newImgName to characters 1 thru 4 of imgName & \"16\" & characters 7 thru 14 of imgName as string\n\t\t\t\t\t\tset newImg to imgParent & newImgName as string as alias\n\t\t\t\t\tend tell\n\n\t\t\t\t\t--change path to 2016 path\n\t\t\t\t\tset image 1 of thisBox to newImg\n\n\t\t\t\tend if\n\t\t\tend if\n\n\t\tend repeat\n\n\t\tsave\n\t\tset fileName to name\n\t\tset fileName to fileName as string\n\t\tset gpDest to (\"HOM_Shortrun:SUPERmergeIN:Custom Magnet Backgrounds:CA:\" & characters 1 thru 10 of fileName as string) & \".gp\"\n\n\t\t--group entire document\n\t\tset selected of every generic box to true\n\t\tset grouped of group box 1 to true\n\n\t\tsave in gpDest\n\n\n\n\t\tclose\n\n\tend tell\nend tell*)\n\n\n","avg_line_length":25.49,"max_line_length":128,"alphanum_fraction":0.7179285995} +{"size":1417,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"use script \"ASPashua\"\nuse framework \"Foundation\"\nuse scripting additions\n\n-- This script demonstrates form validation and re-displays the entered\n-- data, so the user doesn't have to re-enter the data.\n\n\n-- The form definition. \n-- See the documentation for more options: http:\/\/www.bluem.net\/pashua-docs-latest.html \nset config_text to \"# Pashua dialog config\nmessage.type = text\nmessage.default = Select a country from the list (or enter one below to add it to the list.\ncountry.type = popup\ncountry.label = Country\ncountry_to_add.type = textfield\ncountry_to_add.label = Country to add\ncb.type = cancelbutton\ndb.type = defaultbutton\"\n\nset landenlijst to {\"UK\", \"US\", \"USSR\"}\nset selected_country to item 1 of landenlijst\n\ntry\n\trepeat\n\t\tset val_rec to {|country.option|:landenlijst, country:selected_country}\n\t\tset entered_data to display pashua dialog config_text dynamic values val_rec\n\t\tset country_to_add to country_to_add of entered_data\n\t\tif length of country_to_add > 0 then\n\t\t\tset landenlijst to landenlijst & country_to_add\n\t\t\tset selected_country to country_to_add\n\t\telse\n\t\t\tset destination to country of entered_data\n\t\t\tdisplay alert \"Hi there!\" message \"You are going to \u00ab\" & destination & \"\u00bb.\"\n\t\t\texit repeat\n\t\tend if\n\tend repeat\non error number -128\n\tdisplay notification \"You did not complete the form, and thus will not share in the advantages of our generous offers.\" with title \"Hi there!\"\nend try\n","avg_line_length":34.5609756098,"max_line_length":143,"alphanum_fraction":0.7699364855} +{"size":102,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"try\n set endMsg to \"world!\"\n set totMsg to \"Hello, \" & endMsg\n display dialog totMsg\nend try\n","avg_line_length":17.0,"max_line_length":36,"alphanum_fraction":0.6470588235} +{"size":31,"ext":"scpt","lang":"AppleScript","max_stars_count":422.0,"content":"display dialog \"Hello, World!\"\n","avg_line_length":15.5,"max_line_length":30,"alphanum_fraction":0.7419354839} +{"size":330,"ext":"applescript","lang":"AppleScript","max_stars_count":9.0,"content":"set the_file to choose file\nset sum to 0\nrepeat with mass in paragraphs of (read the_file)\n\tset sum to sum + (calculate_fuel for mass)\nend repeat\nreturn sum\n\non calculate_fuel for mass\n\tset fuel to mass div 3 - 2\n\tif fuel is greater than 0 then\n\t\treturn fuel + (calculate_fuel for fuel)\n\telse\n\t\treturn 0\n\tend if\nend calculate_fuel","avg_line_length":22.0,"max_line_length":49,"alphanum_fraction":0.7606060606} +{"size":131,"ext":"applescript","lang":"AppleScript","max_stars_count":50.0,"content":"on run argv\n tell application \"Keyboard Maestro Engine\"\n setvariable (item 1 of argv) to (item 2 of argv)\n end tell\nend run\n\n\n","avg_line_length":16.375,"max_line_length":52,"alphanum_fraction":0.7099236641} +{"size":1176,"ext":"scpt","lang":"AppleScript","max_stars_count":null,"content":"(*\n\nExternal Drive Auto Backup\n\nAppleScript for prompting user to run a bash script via OSX dialog GUI\nwhen a watched folder has a new item. Intended use is to prompt for\nbackup script to run when external drive is mounted\n\nWritten and maintained by: Byron Mansfield byron@byronmansfield.com\n\n*)\n\n-- trigger added items to folder\non adding folder items to this_folder after receiving added_items\n\n -- check if it is storage specifically\n if (added_items as string) contains \"Storage\" then\n\n -- prompt user with dialog to run backup or not\n set run_lrbkup to button returned of (display dialog \"External hard drive Storage was mounted. Would you like to run lrbkup script?\" buttons {\"No\", \"Yes\"} default button \"Yes\" with icon note)\n\n -- check if run backup script is yes else do nothing\n if run_lrbkup is \"Yes\" then\n\n -- open a fresh new window in iTerm2 and run lrbkup script\n tell application \"iTerm2\"\n set new_term to (create window with default profile)\n tell new_term\n tell the current session\n write text \"lrbkup\"\n end tell\n end tell\n end tell\n end if\n end if\nend adding folder items to\n","avg_line_length":31.7837837838,"max_line_length":195,"alphanum_fraction":0.7151360544} +{"size":3500,"ext":"applescript","lang":"AppleScript","max_stars_count":6.0,"content":"(*\n * Example : StringModifier's replaceText(\"Let it be known that [company] is responsible for any damage\" & \" any employee causes during [company]'s activity while in the conference.\", \"[company]\", \"Disny inc\") -- this will then replace all instances of [company] with Disny inc\n * Todo: is the original text also edited?\n *)\non replace_text(the_text, match, replacement)\n\tset text item delimiters to match\n\tset temporary_list to text items of the_text\n\tset text item delimiters to replacement\n\tset finished_form to temporary_list as text\n\tset text item delimiters to \"\"\n\treturn finished_form\nend replace_text\n(*\n * Modifies the original array\n * TD you may aswell return the original array for chaining purposes\n *)\non wrap_every_text_item(text_items, wrap)\n\trepeat with i from 1 to (length of text_items)\n\t\tset item i of text_items to wrap_text(item i of text_items, wrap)\n\tend repeat\nend wrap_every_text_item\n(*\n * Does not modify the original string\n *)\non wrap_text(the_text, wrap)\n\treturn wrap & the_text & wrap\nend wrap_text\n(*\n * returns the text in all lower case\n *)\non lower_case(the_text)\n\tset upper to \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\tset lower to \"abcdefghijklmnopqrstuvwxyz\"\n\treturn Util's translate_chars(the_text, upper, lower)\nend lower_case\n(*\n * returns the text in all upper case\n *)\non upper_case(the_text)\n\tset lower to \"abcdefghijklmnopqrstuvwxyz\"\n\tset upper to \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\treturn Util's translate_chars(the_text, lower, upper)\nend upper_case\n(*\n * Capitalize a text, returning only the first letter uppercased\n *)\non capitalize_text(the_text)\n\tset firstChar to upper_case(first character of the_text)\n\tset otherChars to lower_case(characters 2 thru -1 of the_text)\n\treturn firstChar & otherChars\nend capitalize_text\n(*\n * removes trim string from the right side of the text\n * Note: you can also do something like this: text 2 thru (length of the_text) of the_text\n *)\non left_side_strip(the_text, trim_string)\n\tset x to count trim_string\n\ttry\n\t\trepeat while the_text begins with the trim_string\n\t\t\tset the_text to characters (x + 1) thru -1 of the_text as text\n\t\tend repeat\n\ton error\n\t\treturn \"\"\n\tend try\n\treturn the_text\nend left_side_strip\n(*\n * removes trim string from the right side of the text\n * Note: you can also do something like this: text 1 thru ((length of the_text) - 1) of the_text\n *)\non right_side_strip(the_text, trim_string)\n\tset x to count trim_string\n\ttry\n\t\trepeat while the_text ends with the trim_string\n\t\t\tset the_text to characters 1 thru -(x + 1) of the_text as text\n\t\tend repeat\n\ton error\n\t\treturn \"\"\n\tend try\n\treturn the_text\nend right_side_strip\n(*\n * removes trim string from the left and right side of the text\n *)\non left_and_right_side_strip(the_text, trim_string)\n\tset the_text to left_side_strip(the_text, trim_string)\n\tset the_text to right_side_strip(the_text, trim_string)\n\treturn the_text\nend left_and_right_side_strip\n\nscript Util\n\t(*\n\t * Translate characters of a text\n\t * Note: Pass the From and To tables as strings (same lenght!)\n\t *)\n\ton translate_chars(the_text, from_chars, to_chars)\n\t\tset the newText to \"\"\n\t\tif (count from_chars) is not equal to (count to_chars) then\n\t\t\terror \"translate_chars: From\/To strings have different lenght\"\n\t\tend if\n\t\trepeat with char in the_text\n\t\t\tset newChar to char\n\t\t\tset x to offset of char in the from_chars\n\t\t\tif x is not 0 then set newChar to character x of the to_chars\n\t\t\tset newText to newText & newChar\n\t\tend repeat\n\t\treturn the newText\n\tend translate_chars\nend script","avg_line_length":32.1100917431,"max_line_length":277,"alphanum_fraction":0.7657142857} +{"size":2088,"ext":"scpt","lang":"AppleScript","max_stars_count":1.0,"content":"global x1, y1, x2, y2\n\ntell application \"System Events\" to tell process \"Dock\"\n\tset dock_size to size in list 1\n\tset dock_width to (item 1 of dock_size)\n\tset dock_height to (item 2 of dock_size)\n\tset dock_position to position in list 1\n\tset dock_x to (item 1 of dock_position)\n\tset dock_y to (item 2 of dock_position)\nend tell\n\ntell application \"Finder\"\n\tset desktop_bounds to bounds of window of desktop\n\tset x1 to (item 1 of desktop_bounds)\n\tset y1 to (item 2 of desktop_bounds)\n\tset x2 to (item 3 of desktop_bounds)\n\tset y2 to (item 4 of desktop_bounds)\nend tell\n\nif dock_x = 0 then\n\tset x1 to dock_width\nelse if (dock_y + dock_height) = y2 then\n\tset y2 to (y2 - dock_height)\nelse if (dock_x + dock_width) = x2 then\n\tset x2 to (x2 - dock_width)\nend if\n\non set_bounds(bounds)\n\ttell application \"System Events\"\n\t\tset frontApp to first application process whose frontmost is true\n\t\tset frontAppName to name of frontApp\n\t\ttell process frontAppName\n\t\t\ttell (1st window whose value of attribute \"AXMain\" is true)\n\t\t\t\tset position to {item 1 of bounds, item 2 of bounds}\n\t\t\t\tset size to {(item 3 of bounds) - (item 1 of bounds), (item 4 of bounds) - (item 2 of bounds)}\n\t\t\tend tell\n\t\tend tell\n\tend tell\nend set_bounds\n\non maximize()\n\tset_bounds({x1, y1, x2, y2})\nend maximize\n\non left_half()\n\tset_bounds({x1, y1, x1 + (x2 - x1) \/ 2, y2})\nend left_half\n\non right_half()\n\tset_bounds({x1 + (x2 - x1) \/ 2, y1, x2, y2})\nend right_half\n\non top_half()\n\tset_bounds({x1, y1, x2, y1 + (y2 - y1) \/ 2})\nend top_half\n\non bottom_half()\n\tset_bounds({x1, y1 + (y2 - y1) \/ 2, x2, y2})\nend bottom_half\n\non left_top()\n\tset_bounds({x1, y1, x1 + (x2 - x1) \/ 2, y1 + (y2 - y1) \/ 2})\nend left_top\n\non left_bottom()\n\tset_bounds({x1, y1 + (y2 - y1) \/ 2, x1 + (x2 - x1) \/ 2, y2})\nend left_bottom\n\non right_top()\n\tset_bounds({x1 + (x2 - x1) \/ 2, y1, x2, y1 + (y2 - y1) \/ 2})\nend right_top\n\non right_bottom()\n\tset_bounds({x1 + (x2 - x1) \/ 2, y1 + (y2 - y1) \/ 2, x2, y2})\nend right_bottom\n\non central()\n\tset_bounds({x1 + (x2 - x1) \/ 4, y1 + (y2 - y1) \/ 4, x2 - (x2 - x1) \/ 4, y2 - (y2 - y1) \/ 4})\nend central\n\nmaximize()\n","avg_line_length":25.4634146341,"max_line_length":98,"alphanum_fraction":0.6704980843} +{"size":2762,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- fmGUI_ManageSecurity_Cancel({})\n-- Erik Shagdar, NYHTC\n-- Close ( and CANCEL ) Manage Security\n\n\n(*\nHISTORY:\n\t2020-03-04 ( dshockley ): Standardized version. \n\t1.0 - 2017-08-07 ( eshagdar ): copied logic from fmGUI_ManageSecurity_Save\n\n\nREQUIRES:\n\tclickObjectByCoords\n\tfmGUI_AppFrontMost\n\twindowWaitUntil\n*)\n\n\non run\n\tfmGUI_ManageSecurity_Cancel({})\nend run\n\n--------------------\n-- START OF CODE\n--------------------\n\non fmGUI_ManageSecurity_Cancel(prefs)\n\t-- version 2020-03-04-1532\n\t\n\tset defaulPrefs to {}\n\tset prefs to prefs & defaulPrefs\n\t\n\ttry\n\t\tfmGUI_AppFrontMost()\n\t\t\n\t\ttell application \"System Events\"\n\t\t\ttell application process \"FileMaker Pro Advanced\"\n\t\t\t\tif name of window 1 does not contain \"Manage Security for\" then error \"Not in main Manage Security window.\" number 1024\n\t\t\t\tset cancelButton to first button of window 1 whose name is equal to \"Cancel\"\n\t\t\tend tell\n\t\tend tell\n\t\t\n\t\t-- save security changes\n\t\tclickObjectByCoords(cancelButton)\n\t\tdelay 0.5\n\t\t\n\t\t\n\t\t-- confirm discard\n\t\ttry\n\t\t\ttell application \"System Events\"\n\t\t\t\ttell application process \"FileMaker Pro Advanced\"\n\t\t\t\t\tset discardButton to button \"Discard\" of window 1\n\t\t\t\tend tell\n\t\t\tend tell\n\t\t\tclickObjectByCoords(discardButton)\n\t\tend try\n\t\t\n\t\t\n\t\t-- wait until window is gone\n\t\twindowWaitUntil({whichWindow:\"front\", windowNameTest:\"is not\", windowName:\"FileMaker Pro Advanced\"})\n\t\twindowWaitUntil({whichWindow:\"front\", windowNameTest:\"does not start with\", windowName:\"Manage Security\"})\n\t\t\n\t\treturn true\n\ton error errMsg number errNum\n\t\terror \"Couldn't fmGUI_ManageSecurity_Cancel - \" & errMsg number errNum\n\tend try\n\t\nend fmGUI_ManageSecurity_Cancel\n\n--------------------\n-- END OF CODE\n--------------------\n\non clickObjectByCoords(prefs)\n\ttell application \"htcLib\" to clickObjectByCoords(my coerceToString(prefs))\nend clickObjectByCoords\n\non fmGUI_AppFrontMost()\n\ttell application \"htcLib\" to fmGUI_AppFrontMost()\nend fmGUI_AppFrontMost\n\non windowWaitUntil(prefs)\n\ttell application \"htcLib\" to windowWaitUntil(prefs)\nend windowWaitUntil\n\n\n\non coerceToString(incomingObject)\n\t-- 2017-07-12 ( eshagdar ): bootstrap code to bring a coerceToString into this file for the sample to run ( instead of having a copy of the handler locally ).\n\t\n\ttell application \"Finder\" to set coercePath to (container of (container of (path to me)) as text) & \"text parsing:coerceToString.applescript\"\n\tset codeCoerce to read file coercePath as text\n\ttell application \"htcLib\" to set codeCoerce to \"script codeCoerce \" & return & getTextBetween({sourceText:codeCoerce, beforeText:\"-- START OF CODE\", afterText:\"-- END OF CODE\"}) & return & \"end script\" & return & \"return codeCoerce\"\n\tset codeCoerce to run script codeCoerce\n\ttell codeCoerce to coerceToString(incomingObject)\nend coerceToString\n\n","avg_line_length":28.1836734694,"max_line_length":233,"alphanum_fraction":0.735698769} +{"size":1639,"ext":"applescript","lang":"AppleScript","max_stars_count":16.0,"content":"--\n-- AppleScripts for Avid Pro Tools.\n--\n-- Script description:\n-- Sends selection to Revoice Pro.\n--\n-- (C) 2017 Ilya Putilin\n-- http:\/\/github.com\/fantopop\n-- \n\ntell application \"Finder\"\n\ttell application \"System Events\"\n\t\tset PT to the first application process whose creator type is \"PTul\"\n\t\ttell PT\n\t\t\tactivate\n\t\t\tset frontmost to true\n\t\t\t\n\t\t\t-- Check if Revoice APT is open.\n\t\t\tset ReVoiceOpen to count (windows whose name contains \"Audio Suite: Revoice Pro\")\n\t\t\t\n\t\t\t-- Open Revoice APT if needed.\n\t\t\tif ReVoiceOpen is 0 then\n\t\t\t\tclick menu item \"Revoice Pro APT\" of menu \"Other\" of menu item \"Other\" of menu \"AudioSuite\" of menu bar item \"AudioSuite\" of menu bar 1\n\t\t\t\t\n\t\t\t\t-- Wait until the window opens.\n\t\t\t\trepeat while ReVoiceOpen is 0\n\t\t\t\t\tdelay 0.05\n\t\t\t\t\tset ReVoiceOpen to count (windows whose name contains \"Audio Suite: Revoice Pro\")\n\t\t\t\tend repeat\n\t\t\tend if\n\t\t\t\n\t\t\tset Revoice to (1st window whose name contains \"Audio Suite: Revoice Pro\")\n\t\t\t\n\t\t\t-- Click \"Capture\" button\n\t\t\ttell Revoice to click button \"Analyze\"\n\t\t\t\n\t\t\t-- Wait until Capture performs\n\t\t\t\n\t\t\t-- Count windows before processing.\n\t\t\tset numBefore to count windows\n\t\t\t-- Count current number of windows.\n\t\t\tset num to count windows\n\t\t\t\n\t\t\t-- Wait until render completes.\n\t\t\trepeat while num is greater than numBefore\n\t\t\t\tset num to count windows\n\t\t\t\tdelay 0.1\n\t\t\tend repeat\n\t\t\t\n\t\t\t-- Move selection down\n\t\t\tkeystroke \";\"\n\t\t\t\n\t\t\tdelay 0.05\n\t\t\t\n\t\t\t-- Click \"Capture\" button\n\t\t\ttell Revoice to click button \"Analyze\"\n\t\t\t\n\t\tend tell\n\t\t\n\t\t-- Switch to Revoice window\n\t\ttell process \"Revoice Pro\"\n\t\t\tactivate\n\t\t\tset frontmost to true\n\t\tend tell\n\tend tell\nend tell","avg_line_length":24.8333333333,"max_line_length":139,"alphanum_fraction":0.6802928615} +{"size":163,"ext":"scpt","lang":"AppleScript","max_stars_count":4.0,"content":"do shell script \"defaults write \/Library\/Preferences\/com.apple.security.libraryvalidation.plist DisableLibraryValidation -bool true\" with administrator privileges\n","avg_line_length":81.5,"max_line_length":162,"alphanum_fraction":0.8650306748} +{"size":1787,"ext":"applescript","lang":"AppleScript","max_stars_count":7.0,"content":"lowercaseText(\"Hello World!\")\n\non lowercaseText(aText)\n\t\n\t(*\n\t\tConverts text to lower case.\n\t*)\n\t\n\t-- Define character sets\n\tset lowercaseCharacters to \"abcdefghijklmnopqrstuvwxyz\"\n\tset uppercaseCharacters to \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\tset lowercaseSpecialCharacters to {138, 140, 136, 139, 135, 137, 190, 141, 142, 144, 145, 143, 146, 148, 149, 147, 150, 154, 155, 151, 153, 152, 207, 159, 156, 158, 157, 216}\n\tset uppercaseSpecialCharacters to {128, 129, 203, 204, 231, 229, 174, 130, 131, 230, 232, 233, 234, 235, 236, 237, 132, 133, 205, 238, 239, 241, 206, 134, 242, 243, 244, 217}\n\t\n\t-- Convert comma seperated strings into a list\n\tset lowercaseCharacters to characters of lowercaseCharacters\n\tset uppercaseCharacters to characters of uppercaseCharacters\n\t\n\t-- Add special characters to the character lists\n\trepeat with i from 1 to count of lowercaseSpecialCharacters\n\t\tset end of lowercaseCharacters to ASCII character (item i of lowercaseSpecialCharacters)\n\tend repeat\n\trepeat with i from 1 to count of uppercaseSpecialCharacters\n\t\tset end of uppercaseCharacters to ASCII character (item i of uppercaseSpecialCharacters)\n\tend repeat\n\t\n\tset prvDlmt to text item delimiters\n\t\n\t-- Loop through every upper case character\n\trepeat with i from 1 to count of uppercaseCharacters\n\t\t\n\t\tconsidering case\n\t\t\t\n\t\t\tif aText contains (item i of uppercaseCharacters) then\n\t\t\t\t\n\t\t\t\t-- Delimit string by upper case character\n\t\t\t\tset text item delimiters to (item i of uppercaseCharacters)\n\t\t\t\tset tempList to text items of aText\n\t\t\t\t-- Join list by lower case character\n\t\t\t\tset text item delimiters to (item i of lowercaseCharacters)\n\t\t\t\tset aText to tempList as text\n\t\t\t\t\n\t\t\tend if\n\t\t\t\n\t\tend considering\n\t\t\n\tend repeat\n\t\n\tset text item delimiters to prvDlmt\n\t\n\treturn aText\n\t\nend lowercaseText","avg_line_length":33.7169811321,"max_line_length":175,"alphanum_fraction":0.7487409065} +{"size":1151,"ext":"applescript","lang":"AppleScript","max_stars_count":3305.0,"content":"#!\/usr\/bin\/osascript\n\n# Dependency: This script requires Messenger to be installed: https:\/\/www.messenger.com\/desktop\n\n# Required parameters:\n# @raycast.schemaVersion 1\n# @raycast.title Open Conversation\n# @raycast.mode silent\n\n# Optional parameters:\n# @raycast.icon images\/messenger.png\n# @raycast.packageName Messenger\n# @raycast.argument1 { \"type\": \"text\", \"placeholder\": \"Name\" }\n\n# Documentation:\n# @raycast.author Jakub Lanski\n# @raycast.authorURL https:\/\/github.com\/jaklan\n\non run argv\n\n\t### Configuration ###\n\n\t# Delay time before triggering the keystroke for the Search\n\t# (used only when Messenger needs to be initialized)\n\tset keystrokeDelay to 2.5\n\t# Delay time before triggering the \"\u23181\" keystroke\n\tset conversationKeystrokeDelay to 1\n\n\t### End of configuration ###\n\n\tif application \"Messenger\" is running then\n\t\tdo shell script \"open -a Messenger\"\n\telse\n\t\tdo shell script \"open -a Messenger\"\n\t\tdelay keystrokeDelay\n\tend if\n\n\ttell application \"System Events\" to tell process \"Messenger\"\n\t\tkeystroke \"k\" using command down\n\t\tkeystroke item 1 of argv\n\t\tdelay conversationKeystrokeDelay\n\t\tkeystroke \"1\" using command down\n\tend tell\n\nend run\n","avg_line_length":25.0217391304,"max_line_length":95,"alphanum_fraction":0.751520417} +{"size":856,"ext":"applescript","lang":"AppleScript","max_stars_count":null,"content":"set filePaths to get (choose file of type {\"png\"} with multiple selections allowed)\n\nset sizes_width to {750, 1242, 640, 640, 750, 2048}\nset sizes_height to {1334, 2208, 1136, 960, 1024, 2732}\n\nrepeat with filePath in filePaths\n\tset imagePath to get POSIX path of filePath\n\ttell application \"Finder\"\n\t\tset saveDirectory to get (folder of filePath as Unicode text)\n\t\tset fileName to name of filePath as Unicode text\n\tend tell\n\t\n\trepeat with i from 1 to 6\n\t\ttell application \"Image Events\"\n\t\t\tlaunch\n\t\t\tset img to open imagePath\n\t\t\tscale img to size item i of sizes_height\n\t\t\tcrop img to dimensions {item i of sizes_width, item i of sizes_height}\n\t\t\tset imgName to (item i of sizes_width as string) & \"x\" & (item i of sizes_height as string) & \"_\" & fileName\n\t\t\tsave img in file (saveDirectory & imgName) as PNG\n\t\t\tclose img\n\t\tend tell\n\tend repeat\nend repeat","avg_line_length":35.6666666667,"max_line_length":111,"alphanum_fraction":0.7371495327} +{"size":76,"ext":"scpt","lang":"AppleScript","max_stars_count":16.0,"content":"on run argv\n do shell script \"screencapture -iW screenshot.jpg\" \nend run\n","avg_line_length":19.0,"max_line_length":55,"alphanum_fraction":0.7368421053} +{"size":1497,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"-- @description Arm\/Disarm through dialog\n-- @author Ben Smith\n-- @link bensmithsound.uk\n-- @source Rich Walsh (adapted)\n-- @version 1.1\n-- @testedmacos 10.14.6\n-- @testedqlab 4.6.10\n-- @about Set the arm state of cues based on a string in their name\n-- @separateprocess TRUE\n\n-- @changelog\n-- v1.1 + runs as separate process\n\n\n-- USER DEFINED VARIABLES -----------------\n\nset userDefaultSearchString to \"\"\n\n---------- END OF USER DEFINED VARIABLES --\n\n\n-- RUN SCRIPT -----------------------------\n\n-- Define variables\n\nglobal dialogTitle\nset dialogTitle to \"Batch Arm\/Disarm\"\n\n-- Get the search string\n\nset {theText, theButton} to {text returned, button returned} of (display dialog \"Arm\/disarm cues whose name contains (return an empty string to cancel):\" with title dialogTitle with icon 1 default answer userDefaultSearchString buttons {\"Toggle\", \"Arm\", \"Disarm\"} default button \"Disarm\")\n\n-- Check for cancel\n\nif theText is \"\" then\n\terror number -128\nend if\n\n-- Copy the search string to the Clipboard and arm\/disarm the cues\n\nset the clipboard to theText\n\ntell application id \"com.figure53.Qlab.4\" to tell front workspace\n\tset foundCues to every cue whose q name contains theText\n\t--set foundCuesRef to a reference to foundCues\n\trepeat with eachCue in reverse of foundCues\n\t\tif theButton is \"Arm\" then\n\t\t\tset armed of eachCue to true\n\t\telse if theButton is \"Disarm\" then\n\t\t\tset armed of eachCue to false\n\t\telse\n\t\t\tset armed of eachCue to not armed of eachCue\n\t\tend if\n\tend repeat\nend tell","avg_line_length":27.2181818182,"max_line_length":288,"alphanum_fraction":0.7147628591} +{"size":2672,"ext":"applescript","lang":"AppleScript","max_stars_count":38.0,"content":"#!\/usr\/bin\/osacompile -o Patch.app\n\n# This program is licensed under the terms of the MIT License.\n#\n# Copyright 2017-2021 Munehiro Yamamoto \n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy of\n# this software and associated documentation files (the \"Software\"), to deal in\n# the Software without restriction, including without limitation the rights to\n# use, copy, modify, merge, publish, distribute, sublicense, and\/or sell copies\n# of the Software, and to permit persons to whom the Software is furnished to do\n# so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nset n to 330 -- 308 \/tmp\/bibunsho7-patch.log\nset progress total steps to n\nset progress description to \"Patch.app: \u5b9f\u884c\u4e2d...\"\nset progress additional description to \"\u5f85\u6a5f\u4e2d...\"\n\nset patchLog to \"\/tmp\/bibunsho7-patch.log\"\n\ntry\n -- execute shell script on background\n do shell script quoted form of (POSIX path of (path to resource \"Patch.sh\")) & \u00ac\n space & \"&>\" & patchLog & space & \"&\" with administrator privileges\n\n -- activate the progress bar intentionally\n activate\n\n repeat with i from 1 to n\n delay 0.1\n\n -- update progress description and completed steps\n set progrMsg to do shell script \"tail -n 1\" & space & patchLog & space & \"| fold\"\n set progress additional description to progrMsg\n set i to do shell script \"wc -l\" & space & patchLog & space & \"| sed \\\"s, *,,\\\" | cut -f1 -d \\\" \\\"\"\n\n set progress completed steps to i\n\n --\n if progrMsg = \"+ exit\" then\n exit repeat\n else if progrMsg = \"+ exit 1\" then\n error number -128\n end if\n end repeat\n -- quit\n set progress completed steps to n\n set progress additional description to \"\u5b8c\u4e86\"\n activate\n display alert \"\u5b8c\u4e86\"\n return\n\non error\n set progrMsg to do shell script \"tail -n 2\" & space & patchLog & space & \"| fold\"\n set progress additional description to progrMsg\n\n activate\n display alert \"\u5931\u6557\uff1a\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\" & space & patchLog & space & \"\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002\"\nend try\n","avg_line_length":37.6338028169,"max_line_length":107,"alphanum_fraction":0.6994760479} +{"size":4294,"ext":"applescript","lang":"AppleScript","max_stars_count":4.0,"content":"(*\nSave Chrome Tab to Selected Note of Evernote\nVERSION 1.1\n\n\/\/ AUTHORED BY:\n John Xiao (http:\/\/zaishanda.com\/)\n\n\/\/ UPDATE NOTICES\n ** Follow @jfxiao07 on Twitter, Facebook, Google Plus, and ADN for Update Notices! **\n\n\/\/ License\n MIT\n*)\n\n(* \n======================================\n\/\/ MAIN PROGRAM \n======================================\n*)\n\n-- source: http:\/\/alvinalexander.com\/blog\/post\/mac-os-x\/an-applescript-subroutine-that-returns-current-time-as-hours-mi\non getTimeInHoursAndMinutes()\n -- Get the \"hour\"\n set timeStr to time string of (current date)\n set Pos to offset of \":\" in timeStr\n set theHour to characters 1 thru (Pos - 1) of timeStr as string\n set timeStr to characters (Pos + 1) through end of timeStr as string\n \n -- Get the \"minute\"\n set Pos to offset of \":\" in timeStr\n set theMin to characters 1 thru (Pos - 1) of timeStr as string\n set timeStr to characters (Pos + 1) through end of timeStr as string\n \n --Get \"AM or PM\"\n set Pos to offset of \" \" in timeStr\n set theSfx to characters (Pos + 1) through end of timeStr as string\n \n return (theHour & \":\" & theMin & \" \" & theSfx) as string\nend getTimeInHoursAndMinutes\n\n-- source: http:\/\/henrysmac.org\/blog\/2014\/1\/4\/formatting-short-dates-in-applescript.html\non todayISOformat()\n set theDate to current date\n set y to text -4 thru -1 of (\"0000\" & (year of theDate))\n set m to text -2 thru -1 of (\"00\" & ((month of theDate) as integer))\n set d to text -2 thru -1 of (\"00\" & (day of theDate))\n return y & \"-\" & m & \"-\" & d\nend todayISOformat\nset addDateAndTime to (todayISOformat() & \" \" & getTimeInHoursAndMinutes())\n\nset tabUrl to missing value\nset theNote to missing value\nset tabTitle to missing value\nset activeApp to missing value\n\ntell application \"System Events\"\n set activeApp to name of application processes whose frontmost is true\n --Don't execute when active window is not chrome or Evernote\n --TODO: optimize this logic check\n if (activeApp as string) is not equal to \"Evernote\" and (activeApp as string) is not equal to \"Google Chrome\" and (activeApp as string) is not equal to \"Google Chrome Canary\" then\n error number -128\n end if\n --TODO: optimize (activeApp as string)\n tell application process (activeApp as string)\n set tabUrl to value of text field 1 of toolbar 1 of window 1\n if tabUrl = \"\" then\n error number -128\n end if\n -- Make sure start with http or https\n if (characters 4 thru 1 of tabUrl as string) is not equal to \"http\" then\n set tabUrl to \"http:\/\/\" & tabUrl\n end if\n --set tabDescription to the text returned of (display dialog \"\u6dfb\u52a0\u63cf\u8ff0\" default answer \"\")\n set tabTitle to (title of window 1)\n end tell\nend tell\n\n--delay 0.2\n\n--log tabTitle\n--log tabUrl\n--return\n\ntell application \"Evernote\"\n try\n set findUrlInNotes to (find notes tabUrl) -- returns a list of notes\n if not findUrlInNotes = {} then\n display notification \"\u5df2\u5b58\u5728\u4e8e\uff1a\" & (get title of (item 1 of findUrlInNotes))\n error number -128\n end if\n\n set theNotes to selection\n set theNote to first item in theNotes\n set notifyTitle to \"[\" & (get name of (get notebook of theNote)) & \"]\" & (get title of theNote)\n --if tabDescription is not equal to \"\" then\n --set tabTitle to tabDescription & \"\" & tabTitle\n --end if\n set addContent to \"\" & addDateAndTime & \"\" & tabTitle & \"\" & \"\" & tabUrl & \"<\/a>\"\n try\n append theNote html addContent\n on error errMsg\n display notification \"Error with append method.\"\n try\n set noteHTML to (HTML content of item 1 of theNote)\n set editHTML to noteHTML & addContent\n set (HTML content of item 1 of theNote) to editHTML\n on error errMsg\n display notification \"Failed all.\"\n end try\n end try\n -- Only notify when Evernote is not mostfront\n if (activeApp as string) is not equal to \"Evernote\" then\n display notification tabUrl with title notifyTitle subtitle \"\u300a\" & tabTitle & \"\u300b\"\n end if\n end try\nend tell","avg_line_length":37.0172413793,"max_line_length":184,"alphanum_fraction":0.628085701} +{"size":42,"ext":"scpt","lang":"AppleScript","max_stars_count":5.0,"content":"tell application \"System Events\" to sleep\n","avg_line_length":21.0,"max_line_length":41,"alphanum_fraction":0.8095238095} +{"size":1831,"ext":"applescript","lang":"AppleScript","max_stars_count":7.0,"content":"set exampleDate to current date\ncopy {1993, 4, 10, 10 * 60 * 60 + 120 + 42} to {year of exampleDate, day of exampleDate, month of exampleDate, time of exampleDate}\n\n-- 1993-10-04 10:02:42\nlog timestamp(exampleDate, 1)\n\n-- 1993-10-04_10-02-42\nlog timestamp(exampleDate, 2)\n\n-- Oct 4 10:02:42\nlog timestamp(exampleDate, 3)\n\n-- 19931004T100242\nlog timestamp(exampleDate, 4)\n\n-- 19931004100242\nlog timestamp(exampleDate, 5)\n\non timestamp(aDate as date, aFormat)\n\t\n\t(*\n\t\n\t\tWith big thanks to CK (twitter.com\/AppleScriptive) for pointing out \u00abclass isot\u00bb\n\t\t\n\t\tReturns the specified date and time as a string\n\t\t\n\t\tFormats:\n\t\t\n\t\t1: 1993-10-04 10:02:42 -- For log files\n\t\t\n\t\t2: 1993-10-04_10-02-42 -- For file names\n\t\t\n\t\t3: Oct 4 10:02:42 -- For log files (shorter)\n\t\t\n\t\t4: 19931004T100242 -- RFC3339 \/ iCalendar local time\n\t\t\n\t\t5: 19931004100242 -- Digits only\n\t\t\t\n\t*)\n\t\n\ttell aDate as \u00abclass isot\u00bb as string\n\t\t\n\t\ttell contents\n\t\t\t\n\t\t\tif aFormat is 1 then\n\t\t\t\t\n\t\t\t\treturn text 1 thru 10 & \" \" & text 12 thru -1\n\t\t\t\t\n\t\t\telse if aFormat is 2 then\n\t\t\t\t\n\t\t\t\treturn text 1 thru 10 & \"_\" & text 12 thru 13 & \"-\" & text 15 thru 16 & \"-\" & text 18 thru 19\n\t\t\t\t\n\t\t\telse if aFormat is 3 then\n\t\t\t\t\n\t\t\t\tset shortMonths to {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"}\n\t\t\t\t\n\t\t\t\treturn item (month of aDate) of shortMonths & \" \" & (day of aDate as text) & \" \" & text 12 thru -1\n\t\t\t\t\n\t\t\telse if aFormat is 4 then\n\t\t\t\t\n\t\t\t\treturn text 1 thru 4 & text 6 thru 7 & text 9 thru 13 & text 15 thru 16 & text 18 thru 19\n\t\t\t\t\n\t\t\telse if aFormat is 5 then\n\t\t\t\t\n\t\t\t\treturn text 1 thru 4 & text 6 thru 7 & text 9 thru 10 & text 12 thru 13 & text 15 thru 16 & text 18 thru 19\n\t\t\t\t\n\t\t\telse\n\t\t\t\t\n\t\t\t\terror \"timestamp(): Unknown time format: \" & (aFormat as text) number 1\n\t\t\t\t\n\t\t\tend if\n\t\t\t\n\t\tend tell\n\t\t\n\tend tell\n\t\nend timestamp","avg_line_length":23.7792207792,"max_line_length":131,"alphanum_fraction":0.6264336428} +{"size":4972,"ext":"applescript","lang":"AppleScript","max_stars_count":1.0,"content":"on run\n set tree to {1, {2, {4, {7}, {}}, {5}}, {3, {6, {8}, {9}}, {}}}\n\n -- asciiTree :: String\n set asciiTree to \u00ac\n unlines({\u00ac\n \" 1\", \u00ac\n \" \/ \\\\\", \u00ac\n \" \/ \\\\\", \u00ac\n \" \/ \\\\\", \u00ac\n \" 2 3\", \u00ac\n \" \/ \\\\ \/\", \u00ac\n \" 4 5 6\", \u00ac\n \" \/ \/ \\\\\", \u00ac\n \" 7 8 9\"})\n\n script tabulate\n on |\u03bb|(s, xs)\n justifyLeft(14, space, s & \":\") & unwords(xs)\n end |\u03bb|\n end script\n\n set strResult to asciiTree & linefeed & linefeed & \u00ac\n unlines(zipWith(tabulate, \u00ac\n [\"preorder\", \"inorder\", \"postorder\", \"level-order\"], \u00ac\n ap([preorder, inorder, postorder, levelOrder], [tree])))\n\n set the clipboard to strResult\n return strResult\nend run\n\n-- TRAVERSAL FUNCTIONS --------------------------------------------------------\n\n-- preorder :: Tree Int -> [Int]\non preorder(tree)\n set {v, l, r} to nodeParts(tree)\n if l is {} then\n set lstLeft to []\n else\n set lstLeft to preorder(l)\n end if\n\n if r is {} then\n set lstRight to []\n else\n set lstRight to preorder(r)\n end if\n v & lstLeft & lstRight\nend preorder\n\n-- inorder :: Tree Int -> [Int]\non inorder(tree)\n set {v, l, r} to nodeParts(tree)\n if l is {} then\n set lstLeft to []\n else\n set lstLeft to inorder(l)\n end if\n\n if r is {} then\n set lstRight to []\n else\n set lstRight to inorder(r)\n end if\n\n lstLeft & v & lstRight\nend inorder\n\n-- postorder :: Tree Int -> [Int]\non postorder(tree)\n set {v, l, r} to nodeParts(tree)\n if l is {} then\n set lstLeft to []\n else\n set lstLeft to postorder(l)\n end if\n\n if r is {} then\n set lstRight to []\n else\n set lstRight to postorder(r)\n end if\n lstLeft & lstRight & v\nend postorder\n\n-- levelOrder :: Tree Int -> [Int]\non levelOrder(tree)\n if length of tree > 0 then\n set {head, tail} to uncons(tree)\n\n -- Take any value found in the head node\n -- deferring any child nodes to the end of the tail\n -- before recursing\n\n if head is not {} then\n set {v, l, r} to nodeParts(head)\n v & levelOrder(tail & {l, r})\n else\n levelOrder(tail)\n end if\n else\n {}\n end if\nend levelOrder\n\n-- nodeParts :: Tree -> (Int, Tree, Tree)\non nodeParts(tree)\n if class of tree is list and length of tree = 3 then\n tree\n else\n {tree} & {{}, {}}\n end if\nend nodeParts\n\n\n-- GENERIC FUNCTIONS ----------------------------------------------------------\n\n-- A list of functions applied to a list of arguments\n-- (<*> | ap) :: [(a -> b)] -> [a] -> [b]\non ap(fs, xs)\n set lngFs to length of fs\n set lngXs to length of xs\n set lst to {}\n repeat with i from 1 to lngFs\n tell mReturn(contents of item i of fs)\n repeat with j from 1 to lngXs\n set end of lst to |\u03bb|(contents of (item j of xs))\n end repeat\n end tell\n end repeat\n return lst\nend ap\n\n-- intercalate :: Text -> [Text] -> Text\non intercalate(strText, lstText)\n set {dlm, my text item delimiters} to {my text item delimiters, strText}\n set strJoined to lstText as text\n set my text item delimiters to dlm\n return strJoined\nend intercalate\n\n-- justifyLeft :: Int -> Char -> Text -> Text\non justifyLeft(n, cFiller, strText)\n if n > length of strText then\n text 1 thru n of (strText & replicate(n, cFiller))\n else\n strText\n end if\nend justifyLeft\n\n-- min :: Ord a => a -> a -> a\non min(x, y)\n if y < x then\n y\n else\n x\n end if\nend min\n\n-- Lift 2nd class handler function into 1st class script wrapper\n-- mReturn :: Handler -> Script\non mReturn(f)\n if class of f is script then\n f\n else\n script\n property |\u03bb| : f\n end script\n end if\nend mReturn\n\n-- replicate :: Int -> a -> [a]\non replicate(n, a)\n set out to {}\n if n < 1 then return out\n set dbl to {a}\n\n repeat while (n > 1)\n if (n mod 2) > 0 then set out to out & dbl\n set n to (n div 2)\n set dbl to (dbl & dbl)\n end repeat\n return out & dbl\nend replicate\n\n-- uncons :: [a] -> Maybe (a, [a])\non uncons(xs)\n if length of xs > 0 then\n {item 1 of xs, rest of xs}\n else\n missing value\n end if\nend uncons\n\n-- unlines :: [String] -> String\non unlines(xs)\n intercalate(linefeed, xs)\nend unlines\n\n-- unwords :: [String] -> String\non unwords(xs)\n intercalate(space, xs)\nend unwords\n\n-- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]\non zipWith(f, xs, ys)\n set lng to min(length of xs, length of ys)\n set lst to {}\n tell mReturn(f)\n repeat with i from 1 to lng\n set end of lst to |\u03bb|(item i of xs, item i of ys)\n end repeat\n return lst\n end tell\nend zipWith\n","avg_line_length":23.0185185185,"max_line_length":79,"alphanum_fraction":0.5164923572} +{"size":53,"ext":"scpt","lang":"AppleScript","max_stars_count":2.0,"content":"tell application \"iTunes\"\n play next track\nend tell","avg_line_length":17.6666666667,"max_line_length":25,"alphanum_fraction":0.7735849057} +{"size":540,"ext":"applescript","lang":"AppleScript","max_stars_count":2.0,"content":"#!\/usr\/bin\/env osascript\n\n-- see http:\/\/frantic.im\/notify-on-completion\non run argv\n tell application \"System Events\"\n set frontApp to name of first application process whose frontmost is true\n if frontApp is not \"iTerm2\" then\n set notifTitle to item 1 of argv\n set notifBody to \"succeded\"\n set errorCode to item 2 of argv\n if errorCode is not \"0\"\n set notifBody to \"failed with error code \" & errorCode\n end if\n display notification notifBody with title notifTitle\n end if\n end tell\nend run\n","avg_line_length":30.0,"max_line_length":77,"alphanum_fraction":0.6981481481}