Skip to content

Instantly share code, notes, and snippets.

@SKaplanOfficial
Last active January 18, 2023 21:54
Show Gist options
  • Save SKaplanOfficial/b6d5d4a95aa13f645c77d62e5868d1b1 to your computer and use it in GitHub Desktop.
Save SKaplanOfficial/b6d5d4a95aa13f645c77d62e5868d1b1 to your computer and use it in GitHub Desktop.
PyXA script to run a Flow session only when a specific application (Notes) is open. Session stops when Notes is closed and restarts if the app is opened again.
import PyXA # Version 0.2.0
from time import sleep
flow = PyXA.Application("Flow")
in_session = False
while True:
apps = PyXA.running_applications().localized_name()
if "Notes" in apps and not in_session:
flow.start()
in_session = True
elif "Notes" not in apps:
flow.stop()
in_session = False
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment