4. set urls to {"https://www.google.co.jp","http://www.yahoo.co.jp","https://www.apple.com"}
set countOfUrls to count urls
tell application "Safari"
activate
tell window 1
set firstTab to current tab
repeat with i from 1 to countOfUrls
set URL of document 1 to (item i of urls)
if i = countOfUrls then exit repeat
set current tab to (make new tab)
end repeat
set current tab to firstTab
end tell
end tell
5.
6.
7. var urls = [
"https://www.google.co.jp",
"http://www.yahoo.co.jp",
"https://www.apple.com"
]
var safari = Application("Safari")
safari.activate()
var w = safari.windows[0]
var firstTab = w.currentTab()
for (var i in urls) {
w.tabs[0].url = urls[i]
if (i == urls.length - 1) { break }
var _tab = new safari.Tab()
w.tabs.push(_tab)
w.currentTab = _tab
}
w.currentTab = firstTab
8.
9.
10.
11.
12.
13. var safari = Application("Safari")
safari.activate()
var w = safari.windows[0]
console.log(w.tabs[0].url())
w.tabs[0].url = "https://www.google.co.jp"
40. var app = Application.currentApplication()
app.includeStandardAdditions = true
var stdout = app.doShellScript("whoami")
console.log(stdout)
try {
stdout = app.doShellScript("ls NOT_EXIST")
} catch (e) {
var stderr = e.message
console.log(stderr)
}
41.
42.
43. var safari = Application("Safari")
safari.activate()
delay(2)
var se = Application("System Events")
se.keystroke("l", {using:"command down"})
delay(2)
se.keystroke("http://www.google.com")
delay(2)
se.keyCode(76)
44. var se = Application("System Events")
var safari = Application("Safari")
safari.activate()
delay(1)
var toolbar = se.uiElements["Safari"].uiElements[0].uiElements[4]
toolbar.uiElements[1].click()
delay(1)
toolbar.uiElements[5].click()
delay(1)
se.keyCode(125) // down arrow
delay(1)
se.keyCode(76) // enter
45.
46.
47.
48.
49.
50. var se = Application("System Events")
if(se.uiElementsEnabled()) {
console.log(" OK")
} else {
console.log(" NG")
//
var pref = Application("System Preferences");
var pane = pref.panes.byId("com.apple.preference.security")
pane.anchors["Privacy_accessibility"].reveal();
pref.activate()
}
51.
52. var se = Application("System Events")
var app = se.uiElements[TARGET_APP_NAME].uiElements[TARGET_APP_NAME]
var main_area = app.uiElements[5].uiElements["Box"].uiElements[0]
var table1 = main_area.uiElements[0].uiElements[0]
var tab = main_area.uiElements["Peers"]
var table2 = main_area.uiElements[7].uiElements[0].uiElements[0]
53.
54. var se = Application("System Events")
se.uiElements[TARGET_APP_NAME].entireContents().forEach(function(v, i, a){
console.log(`${Automation.getDisplayString(v)}`);
console.log(`${v.name()} / ${v.description()}`);
})
55. var se = Application("System Events")
se.uiElements[TARGET_APP_NAME].entireContents().forEach(function(v, i, a){
console.log(`${Automation.getDisplayString(v)}`);
console.log(`${v.name()} / ${v.description()}`);
})
56.
57.
58.
59.
60.
61.
62.
63.
64.
65. var run = function(argv) {
console.log(`${argv[0]}`)
}