开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from zeno/python-tool
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
python-tool
/
fpc.py
python-tool
/
fpc.py
fpc.py 8.02 KB
一键复制 编辑 原始数据 按行查看 历史
zeno 提交于 2021年04月28日 16:17 +08:00 . first
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
import win32con
import win32api
import win32gui
import time
import xlrd
import xlwt
import win32clipboard
import pandas as pd
#点击键盘的f键,其中70是f虚拟键码
def key(key):
win32api.keybd_event(key,0,0,0) #代表按下f键
time.sleep(0.02)
win32api.keybd_event(key, 0, win32con.KEYEVENTF_KEYUP, 0) #释放f键
def ctrlA():
#按下ctrl+a,全选
#17为ctrl键码值,65为a的键码值
win32api.keybd_event(17,0,0,0)
win32api.keybd_event(65,0,0,0)
win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(65, 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(1)
def ctrlC():
#按下ctrl+c,67键码值为c
win32api.keybd_event(17,0,0,0)
win32api.keybd_event(67,0,0,0)
win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(67, 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(1)
def ctrlV():
#按下ctrl+v
win32api.keybd_event(17,0,0,0)
win32api.keybd_event(86,0,0,0)
win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(86, 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(1)
#鼠标现在屏幕上方的位置
def getMouse():
pos = win32gui.GetCursorPos()
print(pos)
#鼠标移动
def move(x,y):
win32api.SetCursorPos((x,y))
#鼠标左点击
def leftClick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
#鼠标右点击
def rightClick():
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN | win32con.MOUSEEVENTF_RIGHTUP,0,0,0,0)
#保存excel
def export_excel(export):
#将字典列表转换为DataFrame
pf = pd.DataFrame(list(export))
# #指定字段顺序
# order = ['road_name','bus_plate','timeline','road_type','site']
# pf = pf[order]
# #将列名替换为中文
# columns_map = {
# 'road_name':'路线',
# 'bus_plate':'车牌',
# 'timeline':'时间',
# 'road_type':'方向',
# 'site':'站点'
# }
# pf.rename(columns = columns_map,inplace = True)
#指定生成的Excel表格名称
file_path = pd.ExcelWriter('手机号搜不到用户.xlsx')
#替换空单元格
pf.fillna(' ',inplace = True)
#输出
pf.to_excel(file_path,encoding = 'utf-8',index = False)
#保存表格
file_path.save()
def read_excel(src):
# 打开文件
workBook = xlrd.open_workbook(src)
# 1.获取sheet的名字
# 1.1 获取所有sheet的名字(list类型)
# allSheetNames = workBook.sheet_names()
# print(allSheetNames)
# 1.2 按索引号获取sheet的名字(string类型)
# sheet1Name = workBook.sheet_names()[0]
# print(sheet1Name)
# 2. 获取sheet内容
## 2.1 法1:按索引号获取sheet内容
sheet1_content1 = workBook.sheet_by_index(0); # sheet索引从0开始
## 2.2 法2:按sheet名字获取sheet内容
# sheet1_content2 = workBook.sheet_by_name('Sheet1')
# 3. sheet的名称,行数,列数
# print(sheet1_content1.name,sheet1_content1.nrows,sheet1_content1.ncols)
# 4. 获取整行和整列的值(数组)
# rows = sheet1_content1.row_values(3); # 获取第四行内容
cols1 = sheet1_content1.col_values(0); # 获取第1列内容
cols2 = sheet1_content1.col_values(1)
cols = dict(zip(cols1, cols2))
return cols
# 5. 获取单元格内容(三种方式)
# print(sheet1_content1.cell(1, 0).value)
# print(sheet1_content1.cell_value(2, 2))
# print(sheet1_content1.row(2)[2].value)
# 6. 获取单元格内容的数据类型
# Tips: python读取excel中单元格的内容返回的有5种类型 [0 empty,1 string, 2 number, 3 date, 4 boolean, 5 error]
# print(sheet1_content1.cell(1, 0).ctype)
#把文本读取到win10的paste缓冲区
def setPaste(paste):
# set clipboard data
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(paste)
win32clipboard.CloseClipboard()
#获取paste内容
def getPaste():
# get clipboard data
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return data
def timeSleep(s):
time.sleep(s)
hwnd_title= dict()
def get_all_hwnd(hwnd,mouse):
if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
hwnd_title.update({hwnd:win32gui.GetWindowText(hwnd)})
notFound={}
wxNotFound="该用户不存在"
def isExist(userPhone):
global hwnd_title
win32gui.EnumWindows(get_all_hwnd, 0)
for h,t in hwnd_title.items():
if t is not "":
# print(userPhone,t)
if(wxNotFound in t):
notFound.update({userPhone:t})
hwnd_title= dict()
if __name__ == '__main__':
if(win32api.GetSystemMetrics(win32con.SM_CXSCREEN)==1920):
print("请输入excle路径地址")
src=input()
print("请设置邀请语")
invite=input()
cols=read_excel(src)
for f, col in cols.items():
#1.取出第一个手机号
print("读取姓名"+f+"读取手机号--"+str(int(col)))
setPaste(str(int(col)))
#2.移动鼠标
move(821,436)
timeSleep(1)
#3.鼠标左击
leftClick()
#4.粘贴
ctrlV()
#移动到查找
move(1116,430)
timeSleep(1)
leftClick()
#睡眠三秒防止网络缓慢
timeSleep(1)
#获取句柄信息判断企业微信用户是否存在
isExist(str(int(col)))
timeSleep(3)
#如果搜不到用户
move(1090,575)
leftClick()
#移动到添加
move(1071,535)
timeSleep(1)
leftClick()
#去掉邀请语
move(1092,497)
timeSleep(1)
leftClick()
leftClick()
#设置邀请语
setPaste(f+":"+invite)
timeSleep(3)
leftClick()
ctrlV()
#移动到发送
move(967,578)
timeSleep(2)
leftClick()
#移动到搜索框
move(916,428)
timeSleep(1)
leftClick()
ctrlA()
key(8)
timeSleep(2)
print(notFound)
export_excel(notFound)
input('未搜到用户已保存到桌面,\n回车退出程序')
else:
print("请输入excle路径地址")
src=input()
print("请设置邀请语")
invite=input()
cols=read_excel(src)
for f, col in cols.items():
#1.取出第一个手机号
print("姓名"+f+"读取手机号--"+str(int(col)))
setPaste(str(int(col)))
#2.移动鼠标
move(650,343)
timeSleep(1)
#3.鼠标左击
leftClick()
#4.粘贴
ctrlV()
#移动到查找
move(876,341)
timeSleep(1)
leftClick()
#睡眠三秒防止网络缓慢
timeSleep(1)
#如果搜不到用户
#获取句柄信息判断企业微信用户是否存在
isExist(str(int(col)))
move(848,484)
leftClick()
#移动到添加
move(847,450)
timeSleep(1)
leftClick()
#去掉邀请语
move(853,409)
timeSleep(1)
leftClick()
leftClick()
#设置邀请语
setPaste(f+":"+invite)
timeSleep(3)
leftClick()
ctrlV()
#移动到发送
move(700,479)
timeSleep(2)
leftClick()
#移动到搜索框
move(675,343)
timeSleep(1)
leftClick()
ctrlA()
key(8)
timeSleep(2)
print(notFound)
export_excel(notFound)
input('未搜到用户已保存到桌面,\n回车退出程序')
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/amaz1/python-tool.git
git@gitee.com:amaz1/python-tool.git
amaz1
python-tool
python-tool
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /