我想写一个程序可以:
打开应用程序。(我使用subprocess
模块成功地执行了应用程序)
使用应用程序。(如何自动执行特定软件上的任务?有可能吗?例如,该软件需要我登录和python,并使用我的凭据自动登录,然后继续自动执行我的典型用法,如打开项目)
关闭应用程序。在
from datetime import datetime
import time
import os
import subprocess
os.chdir("../../Desktop/Sublime/Sublime Text 2") #Directory need to adjust to find teamviewer
print "Starting python..."
switch = True
activator1 = True
activator2 = True
startBoolean = True
exitBoolean = True
container = None
def startTimer(startTime , exitTime):
global dateTime
global startBoolean
global exitBoolean
dateTime = datetime.now().strftime('%H%M%S')
print "Current Time: " +dateTime+ "| Start Time: " +startTime +"| Exit Time: "+exitTime
if dateTime >= startTime:
startBoolean = False
print "start boolean: "+ str(startBoolean)
if dateTime >= exitTime:
exitBoolean = False
print "exit boolean: "+ str(exitBoolean)
return [startBoolean,exitBoolean]
def startApplication(startTime):
if dateTime >= startTime:
print "Launching Application..."
process = subprocess.Popen(["./sublime_text"],shell=True) #This is using ubuntu terminal command. Might need to change the command to fits other OS.
def stopApplication(exitTime):
if dateTime >= exitTime:
print "Exiting Application..."
process = subprocess.Popen(["killall sublime_text"],shell=True)
startTime = raw_input("Project Launch Time: ")
exitTime = raw_input("Project Exit time: ")
while switch:
startTimer(startTime , exitTime)
global container
container = startTimer(startTime , exitTime)
if container!=None:
if activator1==True:
if container[0] == False:
print "clear1"
activator1 = False #Cannot activate < 1.
startApplication(startTime)
if activator2==True:
if container[1] == False:
print "clear2"
activator2 = False #Cannot activate < 1.
stopApplication(exitTime)
嗨,你可以用pyAutoIt
我给出了记事本的示例代码,以将其保存在所需的位置和路径中。在
pywinauto也是Python上很棒的GUI自动化解决方案。在
示例:
还有GUI助手SWAPY、pywinauto对象检查器和代码生成器。在
相关问题 更多 >
编程相关推荐