有没有一种方法可以使用python在应用程序中执行特定的操作?

2024-06-16 11:19:45 发布

您现在位置:Python中文网/ 问答频道 /正文

比如说第一次开放狩猎

os.system("open /Applications/Safari.app")

然后去一个用户输入其他的东西,它将被输入到搜索栏和搜索。你知道吗

同样对于这个例子

os.system("open /Applications/Messages.app")

然后给某人发个信息。你知道吗

如果可能的话,这个例子:

os.system("open /Applications/Dictionary.app")

找个词?你知道吗

非常感谢:D


Tags: 用户信息appdictionaryosopensystemsafari
3条回答

这些都是苹果操作系统的应用程序,所以我要跳一跳,假设你使用的是Mac。Automator应用程序可能更适合此任务,因为它基本上可以帮助您轻松编写AppleScript应用程序。你知道吗

如果您想自动化web任务,请查看selenium

Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium Python API you can access all functionalities of Selenium WebDriver in an intuitive way.

seleniumpython绑定提供了一个方便的API来访问seleniumwebdrivers,如Firefox、Ie、Chrome、Remote等

这里有一个链接到什么是selenium and webdrivers

看你能不能做到:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

here for a breakdown of the code

对于消息示例,可以使用Skype4Py API

不是这样的。在您的示例中,您只是使用python来执行shell命令。一旦程序打开,它就不会仅仅给出正在发生的事情的信息,除非它是专门为此设计的或支持某种api。你知道吗

相关问题 更多 >