狠狠撸

狠狠撸Share a Scribd company logo
?
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
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
?
?
?
JavaScript で OS X を自動操作
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
?
?
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
?
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"
?
?
?
?
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
var hoge = function() {
debugger
console.log("hoge")
}
debugger
console.log("fuga")
hoge()
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
var app = Application.currentApplication()
app.includeStandardAdditions = true
app.displayAlert(" ")
var Hello = function() {
try {
app.displayDialog(" ")
console.log(" ")
} catch(e) {
console.log(" ")
}
}
Hello()
Hello()
app.displayNotification(" ",{withTitle:" ",subtitle:" "})
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
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)
}
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
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)
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
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
?
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
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()
}
JavaScript で OS X を自動操作
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]
JavaScript で OS X を自動操作
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()}`);
})
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()}`);
})
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
?
?
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
?
?
JavaScript で OS X を自動操作
var run = function(argv) {
console.log(`${argv[0]}`)
}
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
JavaScript で OS X を自動操作
?
?
JavaScript で OS X を自動操作
?
JavaScript で OS X を自動操作

More Related Content

More from Tomokazu Kiyohara (15)

Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部
Tomokazu Kiyohara
?
イベント継続のコツイベント継続のコツ
イベント継続のコツ
Tomokazu Kiyohara
?
Web API をデバックするときに必要なたったひとつのこと
Web API をデバックするときに必要なたったひとつのことWeb API をデバックするときに必要なたったひとつのこと
Web API をデバックするときに必要なたったひとつのこと
Tomokazu Kiyohara
?
明日から使えるコーディングツール
明日から使えるコーディングツール明日から使えるコーディングツール
明日から使えるコーディングツール
Tomokazu Kiyohara
?
Atom.io Quick Scripting
Atom.io Quick ScriptingAtom.io Quick Scripting
Atom.io Quick Scripting
Tomokazu Kiyohara
?
Text-Objects - vim's elegant function
Text-Objects - vim's elegant functionText-Objects - vim's elegant function
Text-Objects - vim's elegant function
Tomokazu Kiyohara
?
LiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startLiveStyle for Vim - Quick start
LiveStyle for Vim - Quick start
Tomokazu Kiyohara
?
こわくないプルリク
こわくないプルリクこわくないプルリク
こわくないプルリク
Tomokazu Kiyohara
?
Github's HUB
Github's HUBGithub's HUB
Github's HUB
Tomokazu Kiyohara
?
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
Tomokazu Kiyohara
?
Beginner's Sinatra
Beginner's SinatraBeginner's Sinatra
Beginner's Sinatra
Tomokazu Kiyohara
?
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
?
Zen coding15min
Zen coding15minZen coding15min
Zen coding15min
Tomokazu Kiyohara
?
鲍厂罢搁贰础惭の视聴率を上げよう!
鲍厂罢搁贰础惭の视聴率を上げよう!鲍厂罢搁贰础惭の视聴率を上げよう!
鲍厂罢搁贰础惭の视聴率を上げよう!
Tomokazu Kiyohara
?
Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部
Tomokazu Kiyohara
?
イベント継続のコツイベント継続のコツ
イベント継続のコツ
Tomokazu Kiyohara
?
Web API をデバックするときに必要なたったひとつのこと
Web API をデバックするときに必要なたったひとつのことWeb API をデバックするときに必要なたったひとつのこと
Web API をデバックするときに必要なたったひとつのこと
Tomokazu Kiyohara
?
明日から使えるコーディングツール
明日から使えるコーディングツール明日から使えるコーディングツール
明日から使えるコーディングツール
Tomokazu Kiyohara
?
Text-Objects - vim's elegant function
Text-Objects - vim's elegant functionText-Objects - vim's elegant function
Text-Objects - vim's elegant function
Tomokazu Kiyohara
?
LiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startLiveStyle for Vim - Quick start
LiveStyle for Vim - Quick start
Tomokazu Kiyohara
?
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
対サイバー攻撃アラートシステム “DAEDALUS”(ダイダロス)の紹介
Tomokazu Kiyohara
?
Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -Compact Web - Remind "web compression" -
Compact Web - Remind "web compression" -
Tomokazu Kiyohara
?
鲍厂罢搁贰础惭の视聴率を上げよう!
鲍厂罢搁贰础惭の视聴率を上げよう!鲍厂罢搁贰础惭の视聴率を上げよう!
鲍厂罢搁贰础惭の视聴率を上げよう!
Tomokazu Kiyohara
?

Recently uploaded (20)

Data-Driven Public Safety: Reliable Data When Every Second Counts
Data-Driven Public Safety: Reliable Data When Every Second CountsData-Driven Public Safety: Reliable Data When Every Second Counts
Data-Driven Public Safety: Reliable Data When Every Second Counts
Safe Software
?
Kickstart Your QA: An Introduction to Automated Regression Testing Tools
Kickstart Your QA: An Introduction to Automated Regression Testing ToolsKickstart Your QA: An Introduction to Automated Regression Testing Tools
Kickstart Your QA: An Introduction to Automated Regression Testing Tools
Shubham Joshi
?
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Earley Information Science
?
Bedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Bedrock Data Automation (Preview): Simplifying Unstructured Data ProcessingBedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Bedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Zilliz
?
Dev Dives: Unlock the future of automation with UiPath Agent Builder
Dev Dives: Unlock the future of automation with UiPath Agent BuilderDev Dives: Unlock the future of automation with UiPath Agent Builder
Dev Dives: Unlock the future of automation with UiPath Agent Builder
UiPathCommunity
?
5 Must-Use AI Tools to Supercharge Your Productivity
5 Must-Use AI Tools to Supercharge Your Productivity5 Must-Use AI Tools to Supercharge Your Productivity
5 Must-Use AI Tools to Supercharge Your Productivity
cryptouniversityoffi
?
What is Blockchain and How Can Blockchain Consulting Help Businesses.pdf
What is Blockchain and How Can Blockchain Consulting Help Businesses.pdfWhat is Blockchain and How Can Blockchain Consulting Help Businesses.pdf
What is Blockchain and How Can Blockchain Consulting Help Businesses.pdf
Yodaplus Technologies Private Limited
?
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdfSECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
spub1985
?
Caching for Performance Masterclass: Caching at Scale
Caching for Performance Masterclass: Caching at ScaleCaching for Performance Masterclass: Caching at Scale
Caching for Performance Masterclass: Caching at Scale
ScyllaDB
?
ISOIEC 42001 AI Management System 狠狠撸s
ISOIEC 42001 AI Management System 狠狠撸sISOIEC 42001 AI Management System 狠狠撸s
ISOIEC 42001 AI Management System 狠狠撸s
GilangRamadhan884333
?
What's New? ThousandEyes Product Features and Highlights
What's New? ThousandEyes Product Features and HighlightsWhat's New? ThousandEyes Product Features and Highlights
What's New? ThousandEyes Product Features and Highlights
ThousandEyes
?
Combining Lexical and Semantic Search with Milvus 2.5
Combining Lexical and Semantic Search with Milvus 2.5Combining Lexical and Semantic Search with Milvus 2.5
Combining Lexical and Semantic Search with Milvus 2.5
Zilliz
?
TrustArc Webinar: State of State Privacy Laws
TrustArc Webinar: State of State Privacy LawsTrustArc Webinar: State of State Privacy Laws
TrustArc Webinar: State of State Privacy Laws
TrustArc
?
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes Webinar
ThousandEyes
?
William Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae - A Seasoned Professional RenownedWilliam Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae
?
Deno ...................................
Deno ...................................Deno ...................................
Deno ...................................
Robert MacLean
?
SB7 Mobile Ltd: Simplified & Secure Services
SB7 Mobile Ltd: Simplified & Secure ServicesSB7 Mobile Ltd: Simplified & Secure Services
SB7 Mobile Ltd: Simplified & Secure Services
Reuben Jasper
?
Webinar: LF Energy GEISA: Addressing edge interoperability at the meter
Webinar: LF Energy GEISA: Addressing edge interoperability at the meterWebinar: LF Energy GEISA: Addressing edge interoperability at the meter
Webinar: LF Energy GEISA: Addressing edge interoperability at the meter
DanBrown980551
?
Artificial Intelligence Quick Research Guide by Arthur Morgan
Artificial Intelligence Quick Research Guide by Arthur MorganArtificial Intelligence Quick Research Guide by Arthur Morgan
Artificial Intelligence Quick Research Guide by Arthur Morgan
Arthur Morgan
?
Temporary Compound microscope slide .pptx
Temporary Compound microscope slide .pptxTemporary Compound microscope slide .pptx
Temporary Compound microscope slide .pptx
Samir Sharma
?
Data-Driven Public Safety: Reliable Data When Every Second Counts
Data-Driven Public Safety: Reliable Data When Every Second CountsData-Driven Public Safety: Reliable Data When Every Second Counts
Data-Driven Public Safety: Reliable Data When Every Second Counts
Safe Software
?
Kickstart Your QA: An Introduction to Automated Regression Testing Tools
Kickstart Your QA: An Introduction to Automated Regression Testing ToolsKickstart Your QA: An Introduction to Automated Regression Testing Tools
Kickstart Your QA: An Introduction to Automated Regression Testing Tools
Shubham Joshi
?
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Revolutionizing Field Service: How LLMs Are Powering Smarter Knowledge Access...
Earley Information Science
?
Bedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Bedrock Data Automation (Preview): Simplifying Unstructured Data ProcessingBedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Bedrock Data Automation (Preview): Simplifying Unstructured Data Processing
Zilliz
?
Dev Dives: Unlock the future of automation with UiPath Agent Builder
Dev Dives: Unlock the future of automation with UiPath Agent BuilderDev Dives: Unlock the future of automation with UiPath Agent Builder
Dev Dives: Unlock the future of automation with UiPath Agent Builder
UiPathCommunity
?
5 Must-Use AI Tools to Supercharge Your Productivity
5 Must-Use AI Tools to Supercharge Your Productivity5 Must-Use AI Tools to Supercharge Your Productivity
5 Must-Use AI Tools to Supercharge Your Productivity
cryptouniversityoffi
?
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdfSECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
SECURE BLOCKCHAIN FOR ADMISSION PROCESSING IN EDUCATIONAL INSTITUTIONS.pdf
spub1985
?
Caching for Performance Masterclass: Caching at Scale
Caching for Performance Masterclass: Caching at ScaleCaching for Performance Masterclass: Caching at Scale
Caching for Performance Masterclass: Caching at Scale
ScyllaDB
?
ISOIEC 42001 AI Management System 狠狠撸s
ISOIEC 42001 AI Management System 狠狠撸sISOIEC 42001 AI Management System 狠狠撸s
ISOIEC 42001 AI Management System 狠狠撸s
GilangRamadhan884333
?
What's New? ThousandEyes Product Features and Highlights
What's New? ThousandEyes Product Features and HighlightsWhat's New? ThousandEyes Product Features and Highlights
What's New? ThousandEyes Product Features and Highlights
ThousandEyes
?
Combining Lexical and Semantic Search with Milvus 2.5
Combining Lexical and Semantic Search with Milvus 2.5Combining Lexical and Semantic Search with Milvus 2.5
Combining Lexical and Semantic Search with Milvus 2.5
Zilliz
?
TrustArc Webinar: State of State Privacy Laws
TrustArc Webinar: State of State Privacy LawsTrustArc Webinar: State of State Privacy Laws
TrustArc Webinar: State of State Privacy Laws
TrustArc
?
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes Webinar
ThousandEyes
?
William Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae - A Seasoned Professional RenownedWilliam Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae - A Seasoned Professional Renowned
William Maclyn Murphy McRae
?
Deno ...................................
Deno ...................................Deno ...................................
Deno ...................................
Robert MacLean
?
SB7 Mobile Ltd: Simplified & Secure Services
SB7 Mobile Ltd: Simplified & Secure ServicesSB7 Mobile Ltd: Simplified & Secure Services
SB7 Mobile Ltd: Simplified & Secure Services
Reuben Jasper
?
Webinar: LF Energy GEISA: Addressing edge interoperability at the meter
Webinar: LF Energy GEISA: Addressing edge interoperability at the meterWebinar: LF Energy GEISA: Addressing edge interoperability at the meter
Webinar: LF Energy GEISA: Addressing edge interoperability at the meter
DanBrown980551
?
Artificial Intelligence Quick Research Guide by Arthur Morgan
Artificial Intelligence Quick Research Guide by Arthur MorganArtificial Intelligence Quick Research Guide by Arthur Morgan
Artificial Intelligence Quick Research Guide by Arthur Morgan
Arthur Morgan
?
Temporary Compound microscope slide .pptx
Temporary Compound microscope slide .pptxTemporary Compound microscope slide .pptx
Temporary Compound microscope slide .pptx
Samir Sharma
?

JavaScript で OS X を自動操作

  • 1. ?
  • 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. ?
  • 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 ? ?
  • 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" ? ?
  • 14. ?
  • 15. ?
  • 32. var hoge = function() { debugger console.log("hoge") } debugger console.log("fuga") hoge()
  • 37. var app = Application.currentApplication() app.includeStandardAdditions = true app.displayAlert(" ") var Hello = function() { try { app.displayDialog(" ") console.log(" ") } catch(e) { console.log(" ") } } Hello() Hello() app.displayNotification(" ",{withTitle:" ",subtitle:" "})
  • 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) }
  • 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
  • 47. ?
  • 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() }
  • 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]
  • 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()}`); })
  • 59. ? ?
  • 62. ?
  • 63. ?
  • 65. var run = function(argv) { console.log(`${argv[0]}`) }
  • 72. ? ?
  • 74. ?