SlideShare une entreprise Scribd logo
1  sur  75
Télécharger pour lire hors ligne


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






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






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"








var hoge = function() {
debugger
console.log("hoge")
}
debugger
console.log("fuga")
hoge()
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:" "})
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)
}
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


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()
}
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]
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()}`);
})








var run = function(argv) {
console.log(`${argv[0]}`)
}






JavaScript で OS X を自動操作

Contenu connexe

Plus de Tomokazu Kiyohara

Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部Google Cloud Platform を支える技術 …のごく一部
Google Cloud Platform を支える技術 …のごく一部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 functionTomokazu Kiyohara
 
LiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startLiveStyle for Vim - Quick start
LiveStyle for Vim - Quick startTomokazu 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
 
USTREAMの視聴率を上げよう!
USTREAMの視聴率を上げよう!USTREAMの視聴率を上げよう!
USTREAMの視聴率を上げよう!Tomokazu Kiyohara
 

Plus de Tomokazu Kiyohara (15)

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

Dernier

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

JavaScript で OS X を自動操作

  • 1.
  • 2.
  • 3.
  • 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" 
 

  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. var hoge = function() { debugger console.log("hoge") } debugger console.log("fuga") hoge()
  • 33.
  • 34.
  • 35.
  • 36.
  • 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:" "})
  • 38.
  • 39.
  • 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.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65. var run = function(argv) { console.log(`${argv[0]}`) }
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 73.
  • 74.