text
stringlengths
0
15.7k
source
stringlengths
6
112
end newSafariWindow
dock.applescript
on assignToDesktop(appName, desktopIndex)
dock.applescript
if class of desktopIndex is integer then
dock.applescript
set subMenuName to "Desktop on Display " & desktopIndex
dock.applescript
else if desktopIndex is "all" then
dock.applescript
set subMenuName to "All Desktops"
dock.applescript
else if desktopIndex is "none" then
dock.applescript
set subMenuName to "None"
dock.applescript
if not (exists UI element appName of list 1) then return false
dock.applescript
delay 0.2 -- Intermittently fails without this.
dock.applescript
click menu item subMenuName of menu 1 of menu item "Options" of first menu of UI element appName of list 1
dock.applescript
kb's pressKey("esc")
dock.applescript
end assignToDesktop
dock.applescript
set logger to std's import("logger")'s new("dock")
dock.applescript
set retryLib to std's import("retry")
dock.applescript
get the name of the front window
Test copy 2.applescript
set the current view of the front window to list view
Test copy 2.applescript
tell list view options of window 1
Test copy 2.applescript
set icon size to small
Test copy 2.applescript
set text size to 14
Test copy 2.applescript
set sort direction of sort column to normal
Test copy 2.applescript
set sort column to the kind column
Test copy 2.applescript
set width of sort column to 100
Test copy 2.applescript
set sort column to the size column
Test copy 2.applescript
set sort column to the modification date column
Test copy 2.applescript
set sort column to the name column
Test copy 2.applescript
tell front Finder window
Test copy 2.applescript
set oldTarget to target
Test copy 2.applescript
set target to path to home folder
Test copy 2.applescript
set target to oldTarget
Test copy 2.applescript
set the current view to list view
Test copy 2.applescript
set Basedir to "/Users/saji/Desktop/yourDirectory/" as text
split.scpt
set result to do shell script "ls -1 " & Basedir & " | tr '
split.scpt
' ','"
split.scpt
set resultSplited to splitText(",", result)
split.scpt
length of resultSplited -- 最後の改行が、空文字の要素としてカウントされることに留意
split.scpt
on splitText(delimiter, someText)
split.scpt
set output to text items of someText
split.scpt
tell application "System Events" to tell process "NeteaseMusic"
netease-music_pause.scpt
click menu item "Pause" of menu 1 of menu bar item "controls" of menu bar 1
netease-music_pause.scpt
set wrap_script to "/Users/yourusername/Scripts/wrap.pl"
Hard-Wrap%20Selected%20Text.scpt
if input's class is not list then
Hard-Wrap%20Selected%20Text.scpt
set input to getHighlight(debug)
Hard-Wrap%20Selected%20Text.scpt
set stdin to quoted form of first item of input as text
Hard-Wrap%20Selected%20Text.scpt
set curProc to (name of first process whose frontmost is true)
Hard-Wrap%20Selected%20Text.scpt
set {n, leader_str, prepend_leader} to my displayMultiDialog("Hard-wrap Selected Text", "Set the desired line length, leader string, and whether to prepend the leader string below.", {"• Line Length", "• Leader string (E.g. comment character '#')", "• Whether to prepend the leader on the first line (0=no, 1=yes)"}, {"80", "", "1"})
Hard-Wrap%20Selected%20Text.scpt
do shell script "open -a '" & (curProc as string) & "'"
Hard-Wrap%20Selected%20Text.scpt
set cmd_leader to quoted form of leader_str
Hard-Wrap%20Selected%20Text.scpt
set wrapped_str to (do shell script "echo " & stdin & " | " & wrap_script & " " & n & " " & cmd_leader & " " & prepend_leader)
Hard-Wrap%20Selected%20Text.scpt
set isTerminal to ((name of first process where it is frontmost) as string) is equal to "Terminal"
Hard-Wrap%20Selected%20Text.scpt
if isTerminal is true then
Hard-Wrap%20Selected%20Text.scpt
display dialog wrapped_str
Hard-Wrap%20Selected%20Text.scpt
keystroke wrapped_str
Hard-Wrap%20Selected%20Text.scpt
on error errstr
Hard-Wrap%20Selected%20Text.scpt
display dialog errstr
Hard-Wrap%20Selected%20Text.scpt
return wrapped_str
Hard-Wrap%20Selected%20Text.scpt
on getHighlight(debug)
Hard-Wrap%20Selected%20Text.scpt
set theSpare to the clipboard --as text
Hard-Wrap%20Selected%20Text.scpt
set response to (display dialog "Warning: The contents of the clipboard will be lost." buttons {"Cancel", "OK"})
Hard-Wrap%20Selected%20Text.scpt
if button returned of response is "OK" then
Hard-Wrap%20Selected%20Text.scpt
set theSpare to ""
Hard-Wrap%20Selected%20Text.scpt
set selecTxt to ""
Hard-Wrap%20Selected%20Text.scpt
set done to "no"
Hard-Wrap%20Selected%20Text.scpt
set waitnum to 0
Hard-Wrap%20Selected%20Text.scpt
set waitInterval to 0.02
Hard-Wrap%20Selected%20Text.scpt
set maxwaits to 100
Hard-Wrap%20Selected%20Text.scpt
repeat while done = "no"
Hard-Wrap%20Selected%20Text.scpt
set selecTxt to the clipboard as text
Hard-Wrap%20Selected%20Text.scpt
if waitnum is equal to maxwaits then
Hard-Wrap%20Selected%20Text.scpt
set done to "yes"
Hard-Wrap%20Selected%20Text.scpt
else if selecTxt is equal to "" then
Hard-Wrap%20Selected%20Text.scpt
delay waitInterval
Hard-Wrap%20Selected%20Text.scpt
set waitnum to waitnum + 1
Hard-Wrap%20Selected%20Text.scpt
if debug is true then
Hard-Wrap%20Selected%20Text.scpt
display dialog "Copied text: " & (the clipboard as text)
Hard-Wrap%20Selected%20Text.scpt
set the clipboard to theSpare --as record
Hard-Wrap%20Selected%20Text.scpt
display dialog "The clipboard contents have been restored to " & (the clipboard as text)
Hard-Wrap%20Selected%20Text.scpt
return selecTxt
Hard-Wrap%20Selected%20Text.scpt
end getHighlight
Hard-Wrap%20Selected%20Text.scpt
on displayMultiDialog(mytitle, myPrompt, valuePrompts, default_vals)
Hard-Wrap%20Selected%20Text.scpt
return (inputItems for valuePrompts given title:mytitle, prompt:myPrompt, defaults:default_vals)
Hard-Wrap%20Selected%20Text.scpt
end displayMultiDialog
Hard-Wrap%20Selected%20Text.scpt
to inputItems for someItems given title:theTitle, prompt:thePrompt, defaults:theDefaults
Hard-Wrap%20Selected%20Text.scpt
if thePrompt is in {true, false} then -- "with" or "without" prompt
Hard-Wrap%20Selected%20Text.scpt
if thePrompt then
Hard-Wrap%20Selected%20Text.scpt
set thePrompt to "Input the following items:" & return & return -- default
Hard-Wrap%20Selected%20Text.scpt
set thePrompt to ""
Hard-Wrap%20Selected%20Text.scpt
else -- fix up the prompt a bit
Hard-Wrap%20Selected%20Text.scpt
set thePrompt to thePrompt & return & return
Hard-Wrap%20Selected%20Text.scpt
if theTitle is in {true, false} then if theTitle then -- "with" or "without" title
Hard-Wrap%20Selected%20Text.scpt
set theTitle to "Multiple Input Dialog" -- default
Hard-Wrap%20Selected%20Text.scpt
set theTitle to ""
Hard-Wrap%20Selected%20Text.scpt
if theDefaults is in {false} then -- "with" or "without" prompt
Hard-Wrap%20Selected%20Text.scpt
set theDefaults to {}
Hard-Wrap%20Selected%20Text.scpt
set theDefaultCount to (count theDefaults)
Hard-Wrap%20Selected%20Text.scpt
if class of someItems is integer then -- no item list
Hard-Wrap%20Selected%20Text.scpt
set {theCount, someItems} to {someItems, ""}
Hard-Wrap%20Selected%20Text.scpt
if thePrompt is not "" then set thePrompt to text 1 thru -2 of thePrompt
Hard-Wrap%20Selected%20Text.scpt
set theCount to (count someItems)
Hard-Wrap%20Selected%20Text.scpt
if theCount is less than 1 then error "inputItems handler: empty input list"
Hard-Wrap%20Selected%20Text.scpt