This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyXA | |
reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml") | |
links = reader.items().links() | |
m4as = filter(lambda x: "m4a" in x.url, links) | |
for index, song in enumerate(m4as): | |
print("Now playing: " + reader.items()[index].title) | |
sound = PyXA.XASound(song) | |
sound.play() | |
sleep(sound.duration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Test with PyXA 0.1.0 | |
import PyXA | |
safari = PyXA.Application("Safari") | |
notes = PyXA.Application("Notes") | |
# Get info for current Safari tab | |
current_tab = safari.front_window.current_tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Test with PyXA 0.1.0 | |
import PyXA | |
messages = PyXA.Application("Messages") | |
person = messages.participants().by_name("Example Person") | |
PyXA.XAURL("sms://" + person.handle).open() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyXA, math | |
from PIL import Image | |
# Execute Automator workflow and receive list of image paths | |
automator = PyXA.Application("Automator") | |
workflow = automator.open("/Users/exampleuser/Library/Mobile Documents/com~apple~Automator/Documents/Ask For Photos.workflow") | |
image_paths = workflow.execute() | |
# Set base dimensions of mosaic images | |
base_width = 400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyXA | |
# Open URL in new tab | |
safari = PyXA.application("Safari") | |
# Get open windows, documents, and tabs | |
window1 = safari.front_window() | |
window2 = safari.windows()[1] | |
documents = safari.documents() | |
current_doc = safari.current_document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pprint import pprint | |
import PyXA | |
import random | |
from time import sleep | |
textedit = PyXA.application("TextEdit") | |
# Open a URL and wait for it to load | |
safari = PyXA.application("Safari") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested with PyXA 0.1.0 | |
import PyXA | |
app = PyXA.Application("Safari") | |
new_tab = app.make("tab", {"URL": "http://google.com"}) | |
app.front_window().tabs().push(new_tab) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested with PyXA 0.1.0 | |
import PyXA | |
app = PyXA.Application("Messages") | |
chat = app.chats().by_id("SMS;-;+11234567891") | |
chat.send("Hello!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested with PyXA 0.1.0 | |
import PyXA | |
app = PyXA.Application("TextEdit") | |
documents = app.documents() | |
date = datetime.now() | |
documents.prepend(str(date) + "\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test with PyXA 0.1.0 | |
import PyXA | |
app = PyXA.Application("TextEdit") | |
documents = app.documents() | |
print("Paragraphs:", documents.paragraphs()) | |
print("Words:", documents.words()) | |
print("Characters:", documents.characters()) |