8000 py3+mac系统提示 by bugman8688 · Pull Request #1 · tqcenglish/weread-auto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

py3+mac系统提示 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
79 changes: 59 additions & 20 deletions android.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,69 @@
#coding:utf-8
# coding:utf-8
import os
import random
import subprocess
import sys

from uiautomator import device as d
import time
import datetime
#点亮屏幕
def lightScreen():


# 点亮屏幕
def light_screen():
d.screen.on()

#滑动页面
def autoSwipe():

title = os.path.basename(sys.argv[0])


# 滑动页面
def auto_swipe():
d.swipe(1000, 500, 200, 500)
time.sleep(30)
sleep_time = random.randint(30, 60)
time.sleep(sleep_time)
pass


def notify(content="测试"):
# 执行AppleScripts命令, osascript -e 'display notification "内容" with title "标题"'
cmd = 'display notification "%s" with title "%s"' % (content, title)
subprocess.call(["osascript", "-e", cmd])
pass


def check():
# title = os.path.basename(sys.argv[0])
# 执行AppleScripts命令, osascript -e 'display notification "内容" with title "标题"'
cmd = 'display dialog "请确认读书环境是否就绪" buttons {"就绪", "取消"} default button 1 with title "%s"' % title
return subprocess.call(["osascript", "-e", cmd])


# 执行5小时
if __name__ == '__main__':
# 获取当前时间
startTime = datetime.datetime.now();
while 1:
nowTime = datetime.datetime.now();
mkt_last = time.mktime(startTime.timetuple());
mkt_now = time.mktime(nowTime.timetuple());
delt_time = (mkt_now-mkt_last)/60 #转成分钟
# 5小时 === 300分钟
leftTime = 300 - delt_time ;
if leftTime > 0 :
print "剩余" + str(int(leftTime)) + '分钟';
autoSwipe();
else:
print "自动读书完毕";
break;
fileName = os.path.basename(sys.argv[0])

if check() != 0:
exit()

notify("开始读书")

startTime = datetime.datetime.now()
planTime = 300
leftTime = planTime
while leftTime > 0:
nowTime = datetime.datetime.now()
mkt_last = time.mktime(startTime.timetuple())
mkt_now = time.mktime(nowTime.timetuple())
delt_time = (mkt_now - mkt_last) / 60 # 转成分钟
leftTime = planTime - delt_time

intLeft = int(leftTime)
if (planTime - intLeft) % 60 == 0 and planTime != intLeft:
notify("一个小时用眼辛苦了")
print("剩余%d分钟" % intLeft)
auto_swipe()

notify("自动读书完毕")
pass
14 changes: 14 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# coding:utf-8
import os
import subprocess
import sys

if __name__ == '__main__':
title = os.path.basename(sys.argv[0])
content = "这个是内容"

# 执行AppleScripts命令, osascript -e 'display notification "内容" with title "标题"'
cmd = 'display dialog "这是两位爸爸送给儿子的生日礼物" buttons {"OK", "取消"} default button 1 with title "test"'
res = subprocess.call(["osascript", "-e", cmd])
print(res)
pass
0