我用python写了一个小脚本,它基本上是打开一个VPN程序,然后在firefox中打开一个新窗口,登录一个网站。我现在希望避免从终端启动它,并且能够双击它(它是否称为可执行文件?)。我怎样才能做到这一点?我在mac10.11.1上使用python2.7。你知道吗
我很抱歉,最终的错误,但编程仍然是相当新的我!你知道吗
import webbrowser
from Quartz.CoreGraphics import *
import subprocess as sp
import time
import pyautogui
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy),
kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
# opening strong VPN
xfoil = sp.Popen(['open', '-a', '/Applications/StrongVPN Client.app'], stdin=sp.PIPE, stdout=sp.PIPE)
time.sleep(5)
mouseclick(900,360);
time.sleep(1)
#open firefox and going to skygo
b = webbrowser.get('firefox')
b.open('http://skygo.sky.it/index.shtml')
time.sleep( 5 )
mouseclick(1010,225);
#clicking on login;
mouseclick(1074,123);
time.sleep( 5 )
mouseclick(830,225);
time.sleep(2)
pyautogui.typewrite('myusername')
time.sleep(1)
#inserting password
mouseclick(830,290);
time.sleep(2)
pyautogui.typewrite('mypassword')
time.sleep(1)
#pressing enter
mouseclick(920,400);
time.sleep(2)
#mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
您可以使用Automator将Python脚本包装到可以从osxgui打开的普通Mac应用程序包中。你知道吗
更好的是,您试图实现的目标可以更好地在Automator中实现为一组操作,而无需编写任何Python脚本。你知道吗
相关问题 更多 >
编程相关推荐