applescript
Applescript vanaf de Terminal-opdrachtregel
Zoeken…
Invoering
Applescript is een krachtige scripttaal die direct vanaf de Terminal-opdrachtregel kan worden gebruikt om een groot aantal taken uit te voeren.
Alle voorbeelden in deze sectie zijn bedoeld om te worden gebruikt vanuit de Terminal-toepassing.
Download de huidige URL in Safari of Google Chrome
Vanaf de Terminal- opdrachtregel
Download de huidige URL van Safari
osascript -e 'tell app "safari" to get the url of the current tab of window 1'
Download de actieve URL in Google Chrome
osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'
Download de titel van de huidige pagina in Safari of Google Chrome
Zoek de naam van de webpagina in Safari
osascript -e 'tell app "safari" to get the name of the current tab of window 1'
Verkrijg de titel van de webpagina in Google Chrome
osascript -e 'tell app "google chrome" to get the title of the active tab of window 1'
Gebruik een Applescript als shell-functie
U bent niet beperkt tot Applescript-code met één regel. Hier nemen we de vorige twee voorbeelden en combineren ze in een enkele functie.
#!/bin/bash
pageinfo() {
osascript -e \
'tell app "safari"
tell the current tab of window 1
return {url & "\n" & name}
end tell
end tell'
}
Modified text is an extract of the original Stack Overflow Documentation
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow