Skip to content

Instantly share code, notes, and snippets.

@crazyboycjr
Created July 17, 2017 14:04
Show Gist options
  • Save crazyboycjr/a621476acd7f98a3b2bf2fada962eded to your computer and use it in GitHub Desktop.
Save crazyboycjr/a621476acd7f98a3b2bf2fada962eded to your computer and use it in GitHub Desktop.
钉钉自动添加表情脚本
import os
import time
import autopy
from autopy import mouse
basepath = '/home/cjr/Downloads/Telegram Desktop/stickers/shrink22222/'
mouse_path = [(928, 1637), (1197, 1551), (919, 1278), (1408, 1768), (928, 1663)]
def comp(x, y):
xs = os.stat(basepath + x).st_size
ys = os.stat(basepath + y).st_size
if xs > ys:
return 1
else:
return -1
def fetch_one(basepath):
filelist = os.listdir(basepath)
if len(filelist) == 0:
return None
filelist.sort(comp)
#print filelist
#print '\n'.join(map(lambda x: str(os.stat(basepath + x).st_size), filelist))
return filelist[0]
def main():
while True:
target = fetch_one(basepath)
if target is None:
print 'finish'
break
print target
for pos in mouse_path:
mouse.move(pos[0], pos[1])
time.sleep(0.1)
mouse.click()
time.sleep(0.3)
time.sleep(3)
os.remove(basepath + target)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment