#-*- coding: utf-8 -*-

importdatetimeimportosimportrandomimporttimeimportschedule#引入uiautomator库

from pip._vendor importrequestsfrom uiautomator importdevice as d#法定节假日准确日期,不进行打卡

holiday = ['2020-06-25','2020-06-26','2020-06-27','2020-10-01','2020-10-02','2020-10-03','2020-10-04','2020-10-05','2020-10-06','2020-10-07','2020-10-08',

]#调整工作日准确日期,进行打卡

ajustWorking = ['2020-05-09', '2020-06-28', '2020-09-27', '2020-10-10']#调休日期,不进行打卡

compensatoryLeave = ['2020-05-16']definit():#初始化信息

print(d.info)#点亮屏幕

#d.screen.on()

os.popen("adb shell input keyevent 224")

time.sleep(1)#滑动屏幕

os.popen("adb shell input swipe 300 2000 300 500")

time.sleep(1)#输入密码

os.popen("adb shell input text 密码") #你的手机密码

time.sleep(1)defopenwework():"""企业微信打卡

clock in out 上班 下班

:return:"""init()

msg=0#先结束再开启

os.popen("adb shell am force-stop com.tencent.wework")

time.sleep(1)

os.popen("adb shell am start com.tencent.wework/com.tencent.wework.launch.LaunchSplashActivity")

time.sleep(5)print("启动企业微信成功")

d(text=u"工作台").click()

time.sleep(1)

d(text=u"打卡").click()

time.sleep(3)print("打开打卡界面成功")print("当前小时:", datetime.datetime.now().hour)if datetime.datetime.now().hour < 11:#早晨卡

if d(text=u"你已在打卡范围内").info['text'] == "你已在打卡范围内":print("现在是上午")

d(text=u"上班打卡").click()

time.sleep(2)if d(text=u"上班·正常").info['text'] == "上班·正常":

in_time= d(className="android.widget.TextView", resourceId="com.tencent.wework:id/mp").info['text']print("打卡时间:", in_time)

msg= "上班打卡成功: 时间:" + in_time + "日志时间:" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())else:

msg= "打卡失败:" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())else:#下班卡

if d(text=u"你已在打卡范围内").info['text'] == "你已在打卡范围内":print("现在是下午")

d(text=u"下班打卡").click()

time.sleep(2)if d(text=u"下班·正常").info['text'] == "下班·正常":

in_time= d(className="android.widget.TextView", resourceId="com.tencent.wework:id/mp").info['text']print("打卡时间:", in_time)

msg= "下班打卡成功: 时间:" + in_time + "日志时间:" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())else:

msg= "打卡失败:" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())#返回桌面

time.sleep(1)

os.popen("adb shell input keyevent 3")

time.sleep(1)

os.popen("adb shell am force-stop com.tencent.wework")

time.sleep(1)returnmsg#启动微信

defwexin():#按home键

os.popen("adb shell input keyevent 3")

time.sleep(1)

os.popen("adb shell am start com.tencent.mm/com.tencent.mm.ui.LauncherUI")

time.sleep(3)print("启动微信成功")

d(text=u"通讯录").click()

time.sleep(1)

d(text=u"你自己的微信名字").click() #你自己的微信名字

time.sleep(2)

d(text=u"音视频通话").click()

time.sleep(1)

d(text=u"语音通话").click()#振铃五秒钟

time.sleep(5)#d(text=u"取消").click()

os.popen("adb shell input tap 540 1850")

time.sleep(3)#按返回键

os.popen("adb shell input keyevent 4")

time.sleep(2)

os.popen("adb shell input keyevent 4")

time.sleep(1)#按home键

os.popen("adb shell input keyevent 3")

time.sleep(1)

os.popen("adb shell am force-stop com.tencent.mm")print("结束微信成功")

time.sleep(1)#锁屏

os.popen("adb shell input keyevent 26")defpushmsg(msg):"""推送消息给微信

:return:"""

try:

url= 'http://wxpusher.zjiecode.com/api/send/message/?appToken=你自己的token&content=' + msg + '&uid=你自己的uid'requests.get(url)exceptException:print("推送消息异常")deffuckCard():#设置增加的随机分钟数

clocknum = 3

#获取当前时间,2020-05-05 07:45

nowtime =datetime.datetime.now()print("当前时间:", nowtime)#加上随机数(0-3分钟),2020-05-05 07:46

doworktime = (nowtime + datetime.timedelta(minutes=random.randint(0, clocknum))).strftime("%Y-%m-%d %H:%M")print("执行任务时间:", doworktime)

a=0#如果当前时间小于执行时间,执行while循环

while time.strftime("%Y-%m-%d %H:%M", time.localtime())

a+= 1time.sleep(1)#到时间执行任务

#如果当前时间大于执行时间,执行任务

if time.strftime("%Y-%m-%d %H:%M", time.localtime()) >=doworktime:print("到时间执行任务")

msg=openwework()

pushmsg(msg)

wexin()return

deffuckRest():"""# 搞定随机时间

:return:"""

if time.strftime("%Y-%m-%d", time.localtime()) inholiday:print("今天是法定假日")returnTrueif time.strftime("%Y-%m-%d", time.localtime()) incompensatoryLeave:print("今天是调休日期,不进行打卡~~")returnTrueif time.strftime("%Y-%m-%d", time.localtime()) inajustWorking:print("今天是调整工作日,需要进行打卡")#周六启动计划任务问题,需要进行时间判断修复 schedule.every().saturday.at('12:09').do(fuckRest)

#也就是是避免 12点问题

if datetime.datetime.now().hour != 12:print("调整工作日,早8八点,晚6点,正常打卡")

fuckCard()returnTrue#判断是否为周一到周六上午

#1.判断当前日期是否为周日

if datetime.datetime.now().weekday() != 6:if datetime.datetime.now().weekday() != 5:print("周一至周五")

fuckCard()else:print("今天是周六")if (datetime.datetime.now().hour >= 8) and (datetime.datetime.now().hour < 13):print("周六半天打卡")

fuckCard()#企业微信自动打卡

if __name__ == "__main__":'''主函数

linux 后台运行

nohup python3 -u main.py > main.log 2>&1 &

Windows

start /b python3 main.py

# 我司工作日:周一至周五,早8晚6。周六早8点半,中午12点。'''

#每天执行打卡

#第一个卡

schedule.every().day.at('07:45').do(fuckRest)## 周六执行此任务

#正常工作日周六早晨卡

schedule.every().saturday.at('08:13').do(fuckRest)#正常工作日周六中午卡

schedule.every().saturday.at('12:09').do(fuckRest)## 第二个卡

schedule.every().day.at('18:11').do(fuckRest)whileTrue:

schedule.run_pending()

time.sleep(3)

[python][企业微信]企业微信自动打卡Python脚本 价值一万元的自动打卡脚本

这个Python脚本还是有bug的,暂时不在维护和修复了,如果按照既定规划的执行不会出现错误。

当然,断网,断电,手机异常升级,重启等等错误,仍然需要人工进行搞定。

不过嘛,当没有收到提醒通知的时候,人工看看吧,也就早晨和下班那么一哆嗦,这要保证这一哆嗦不错误就好了。

反正我暂时没有遇见错误呢,遇见的时候再说吧,欢迎大家把错误信息发给我。

价值一万元的自动打卡脚本,表问我为毛价值一万元,你懂得,哇哈哈哈。

# 笔记相关

``` text

# Android sdk tools

/home/landv/Android/Sdk/tools/bin/uiautomatorviewer

# 启动微信

adb shell am start com.tencent.mm/com.tencent.mm.ui.LauncherUI

# 杀死微信进程

adb shell am force-stop com.tencent.mm

# 启动企业微信

adb shell am start com.tencent.wework/com.tencent.wework.launch.LaunchSplashActivity

# 杀死企业微信进程

adb shell am force-stop com.tencent.wework

# 加班休息扣除方式test

adb shell am start com.tencent.wework/com.tencent.wework.enterprise.attendance.rule.TestExportActivity

# 人脸信息

adb shell am start com.tencent.wework/com.tencent.wework.enterprise.attendance.controller.AttendanceFaceDetailActivity

#adb shell uiautomator 命令

uiautomator dump dump出当前窗口的UI布局信息

uiautomator dump --compressed dump出当前窗口的UI布局简化信息

uiautomator dump file 指定输出文件,默认文件是在/sdcard/window_dump.xml

adb pull /sdcard/window_dump.xml

###分析

分析安装包中的AndroidManifest.xml

获取包名并且启动Activity名

com.tencent.wework.enterprise.attendance 打卡包

#adb命令获取当前界面Activity

adb shell dumpsys activity activities

adb shell dumpsys activity activities | grep 'cmp'

## 动态获取当前Activity 可以实时 查看当前正在运行的Activity;

adb shell logcat | grep ActivityManager

##

然后输入 am start -n 应用的主包名/要打开的activity所在的包.要打开的activity的名称 , 如下(注:如果对应的Activity打不开则需要在清单文件的对应的Activity标签中添加 android:exported="true" 属性即可):

adb shell am start com.tencent.wework/com.tencent.wework.enterprise.attendance.controller.AttendanceActivity2

com.tencent.wework/.launch.WwMainActivity

## 获取xml按钮的中心坐标 python uiautomator xml 解析

# -*- coding: utf-8 -*-

import tempfile

import os

import re

import time

import xml.etree.ElementTree as ET

name ='发消息'

tree = ET.ElementTree(file="./window_dump.xml")

pattern = re.compile(r"\d+")

treeIter = tree.iter(tag="node")

for elem in treeIter:

if elem.attrib['text'] == name:

bounds = elem.attrib["bounds"]

coord = pattern.findall(bounds)

Xpoint = (int(coord[2]) - int(coord[0])) / 2.0 + int(coord[0])

Ypoint = (int(coord[3]) - int(coord[1])) / 2.0 + int(coord[1])

print (Xpoint)

print (Ypoint)

os.popen("adb shell input tap " + str(Xpoint) + " " + str(Ypoint))

#*采用框架库,使用这个第一版,第二版也比较蛋疼https://github.com/xiaocong/uiautomator

#pip3 install uiautomator

× 使用方法

https://www.cnblogs.com/wanghzh/p/9372021.html

#Appium自动化测试,这是封装好的,比自己撸简单。这种搭建环境比较蛋疼,重量级

Appium移动自动化测试

https://www.cnblogs.com/fnng/p/4540731.html

pip install Appium-Python-Client

################################

#adb 命令大全

https://www.cnblogs.com/zhuminghui/p/10457316.html

1、查询已连接设备/模拟器

adb devices

2、指定设备获取屏幕分辨率

adb -s 设备号 shell wm size

3、给指定设备安装应用

adb -s 设备号 install test.apk

4、启动 adb server 命令

adb start-server

5、停止 adb server 命令

adb kill-server

6、查看adb版本

adb version

7、指定 adb server 的网络端口

adb -P start-server

8、通过 IP 地址连接设备

adb connect

9、断开无线连接

adb disconnect

10、查看所有应用

adb shell pm list packages

11、查看系统应用

adb shell pm list packages -s

12、查看第三方应用

adb shell pm list packages -3

13、卸载应用( 表示应用的包名,-k 参数可选,表示卸载应用但保留数据和缓存目录。)

adb uninstall [-k]

14、清除应用数据与缓存

adb shell pm clear

15、复制设备里的文件到电脑

adb pull [电脑上的目录]

16、复制电脑里的文件到设备

adb push

17、电源键

adb shell input keyevent 26

18、菜单键

adb shell input keyevent 82

19、HOME 键

adb shell input keyevent 3

20、返回键

adb shell input keyevent 4

21、增加音量

adb shell input keyevent 24

22、降低音量

adb shell input keyevent 25

23、静音

adb shell input keyevent 164

24、播放/暂停

adb shell input keyevent 85

25、停止播放

adb shell input keyevent 86

26、播放下一首

adb shell input keyevent 87

27、播放上一首

adb shell input keyevent 88

28、恢复播放

adb shell input keyevent 126

29、暂停播放

adb shell input keyevent 127

30、滑动解锁(参数 300 1000 300 500 分别表示起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标。)

adb shell input swipe 300 1000 300 500

31、输入文本

adb shell input text hello

32、清空日志

adb logcat -c

33、查看设备型号

adb shell getprop ro.product.model

34、电池状况

adb shell dumpsys battery

35、屏幕分辨率

adb shell wm size

36、屏幕密度

adb shell wm density

37、显示屏参数

adb shell dumpsys window displays

38、查看Android 系统版本

adb shell getprop ro.build.version.release

39、查看IP 地址

adb shell ifconfig | grep Mask

40、Mac 地址

adb shell cat /sys/class/net/wlan0/address

41、CPU 信息

adb shell cat /proc/cpuinfo

42、内存信息

adb shell cat /proc/meminfo

43、使用 Monkey 进行压力测试(表示向 指定的应用程序发送 500 个伪随机事件。)

adb shell monkey -p -v 500

44、查看进程

adb shell ps

45、查看实时资源占用情况

adb shell top

#无root 开启网络调试

使用usb连接手机,adb shell 进入终端执行

setprop service.adb.tcp.port 5555

设置好后,手动重启usb调试,在开发者模式,usb调试开关,关闭打开一次就好

退出adb shell

exit

执行adb tcpip 5555

出现如下提示说明切换成功

restarting in TCP mode port:5555

然后输入

adb connect 192.168.1.102:5555

出现如下提示说明连接成功

connected to 192.168.1.102:5555

执行 adb devices

会出现两个设备,然后断开usb线路。

adb shell 就可以连接上了

×关闭wifi adb

断开和手机的链接

adb disconnect

切换到usb调试

adb usb

×连接指定设备

adb -s 设备号 shell

*adb 重启

adb kill-server

```

AirtestIDE

AirtestIDE:跨平台的UI自动化测试编辑器,适用于游戏和App

注意,这个玩意儿是个神器,但是我感觉有点重了,毕竟人家可以自动化测试游戏滴~~~

自动打卡python脚本_[python][企业微信]企业微信自动打卡Python脚本,价值一万元的自动打卡脚本...相关推荐

  1. [python][企业微信]企业微信自动打卡Python脚本,价值一万元的自动打卡脚本

    # -*- coding: utf-8 -*- import datetime import os import random import time import schedule # 引入uiau ...

  2. java执行python脚本_使用Runtime.getRuntime().exec()在java中调用python脚本

    举例有一个Python脚本叫test.py,现在想要在Java里调用这个脚本.假定这个test.py里面使用了拓展的包,使得pythoninterpreter之类内嵌的编译器无法使用,那么只能采用ja ...

  3. 转行学python后悔_月薪13k的我为什么要转行学Python?

    在职业规划包括人生方向上,选择很重要. 一句很经典的话做总结"方向不对,努力白费". 选择自己感兴趣的工作,全力以赴投入其中,"唯有爱的深,才能做的好" 当你付 ...

  4. excel python插件_再见 VBA!神器工具统一 Excel 和 Python

    大家好,我是东哥. 经常给大家推荐好用的数据分析工具,也收到了铁子们的各种好评.这次也不例外,我要再推荐一个,而且是个爆款神器. Excel和Jupyter Notebok都是我每天必用的工具,而且两 ...

  5. python调试工具_您需要在2020年了解的所有python调试工具

    python调试工具 Debugging is an inevitable and often painful process when any programmer developing their ...

  6. python老外_再也不怕和老外交流了,用python实现一个微信聊天翻译助手!

    码农公社  210.net.cn  210是何含义?10月24日是程序员节,1024 =210.210既 210 之意. 当你遇到一些外国小哥哥小姐姐很心动.想结识交流,但英语水平或其他水平还在提升阶 ...

  7. 如何在mac终端运行python程序_如何在mac上的终端上运行python?

    First, the lesson said to simply type, python, into terminal to start coding in python (I don't know ...

  8. python速度_只需一行代码,让你的Python运算速度更加流畅!

    python一直被病垢运行速度太慢,但是实际上python的执行效率并不慢,慢的是python用的解释器Cpython运行效率太差. "一行代码让python的运行速度提高100倍" ...

  9. 不会数学可以学python吗_数学和英语都很差,学习Python难吗?看完我相信你会坚定你的选择...

    前言 首先!我想说:python 不需要很高的数学水平,英语也是很初级就可以入门,因为它的语法很简单,若你的英语不是很好,可以看很多中文的书,比如python基础教程,廖雪峰的python教程,或者看 ...

  10. 帆软报表调用python脚本_直连数据库实时更新数据,比python强大,可视化报表这么做简直牛...

    会数据库,会python,会做报表,到底有多吃香?我趁着周五没事,打开了某招聘,不到10分钟,竟然有好多HR让我换工作,不是说现在基本上不招人吗?是我太优秀了吗? 甚至还有不止一个跟我说报表+决策分析 ...

最新文章

  1. Android_Sqlbrite入门使用
  2. 从各方面数据来看《猎场》为什么收官后热度依旧
  3. linux 安装 nslookup
  4. python难嘛-为什么说python入门很简单,但是在你这很难?
  5. (65)如何根据句柄从二级、三级结构句柄表中找到内核对象
  6. 统计学习方法例2.1实现(转)
  7. js(Dom+Bom)第六天(1)
  8. Android之webview长按超链接类型获取链接文字及url、长按图片链接类型分别获取图片和链接的url
  9. 沃尔什哈达玛变换Matlab,哈达玛变换矩阵-数字图像处理.ppt
  10. Java NIO操作Socket的用法
  11. 计算机系统-电路设计04-全加器的内部电路实现
  12. 蓝桥杯 ADV-209 算法提高 c++_ch02_04
  13. W801单片机学习笔记——内部结构,总线架构篇
  14. html5图标用什么格式转换,ico转png 怎么把ico格式转换成png格式
  15. 11个LOGO设计灵感网站推荐,帮你提高LOGO设计工作效率
  16. 语音压缩:压缩率和比特率
  17. APP闪退有哪些原因造成的?
  18. angular中布局文件中的#是什么意思?
  19. Ubuntu下flash运行方法(2020.12后可用)
  20. 【Web技术】1348- 聊聊水印实现的几种方式

热门文章

  1. 如何从chrome获取你需要的缓存视频
  2. java 爬楼梯算法_9.1 爬楼梯
  3. 无所不在的嵌入式系统
  4. 图像处理--bicubic(双三次插值)
  5. 老式计算机如何设置u盘启动,有谁清楚老式电脑怎么用u盘启动
  6. 选择中医 - 养肾补肾方法
  7. python全栈工程师薪资待遇_java,python和全栈工程师学那个在未来更有前途?
  8. 大图书馆 #5 纳瓦尔宝典
  9. 计算机访问周期,访问周期最短的存储器是
  10. IPv6/IPv4是什么?IPv4和IPv6有什么区别?