2
2
# -*- coding:utf-8 -*-
3
3
4
4
"""
5
- @author: valor
5
+ @author: libuda
6
6
@file: main.py
7
- @time: 2018/11 /5 15:59
7
+ @time: 2019/12 /5 15:59
8
8
"""
9
9
10
10
import traceback
@@ -106,6 +106,52 @@ def __init__(self, port=None, device=None):
106
106
self ._x = None
107
107
self ._y = None
108
108
109
+ def get_phone_resolution (self ):
110
+ """
111
+ 获取设备分辨率
112
+ :return:
113
+ """
114
+ displayPowerState = os .popen (
115
+ "adb shell wm size" ).read ().strip () # Physical size: 1080x2244
116
+ state = str (displayPowerState ).split (" " )[- 1 ]
117
+ width , heidht = state .strip ().split ("x" )
118
+ return int (width ), int (heidht )
119
+
120
+ def get_center (self ):
121
+ """
122
+ 获取设备中心点
123
+ :return:
124
+ """
125
+ width , height = self .get_phone_resolution ()
126
+ return width / 2 , height / 2
127
+
128
+ def swipe (self , start = None , end = None ):
129
+ """
130
+ 滑动屏幕 默认从屏幕底部往上滑
131
+ :param start:
132
+ :param end:
133
+ :return:
134
+ """
135
+ if start is None :
136
+ start = self .get_center ()
137
+ x1 , y1 = start
138
+ if end is None :
139
+ end = x1 , y1 - int (y1 / 2 )
140
+ x2 , y2 = end
141
+ cmd = self ._baseShell + "shell input swipe " + str (x1 ) + " " + str (y1 ) + " " + str (x2 ) + " " + str (y2 )
142
+ print (cmd )
143
+ os .system (cmd )
144
+
145
+ def show_current_pk (self ):
146
+ """
147
+ 展示当前所在app的包名
148
+ :return:
149
+ """
150
+ displayPowerState = os .popen (
151
+ "adb shell dumpsys window windows |findstr -i current" ).read ().strip () # 读出来这种 mAwake=truemScreenOnEarly=true mScreenOnFully=true 字节类型
152
+ state = str (displayPowerState ).split (" " )[- 1 ]
153
+ return state
154
+
109
155
def adb_keyboard (self , event ):
110
156
"""
111
157
不同event对应不同指令
@@ -555,6 +601,7 @@ def clean_phone(self):
555
601
556
602
def add_friends (self , phone ):
557
603
# 输入号码
604
+ phone = str (int (phone ))
558
605
self ._adb .adb_input (phone )
559
606
# 点击搜索
560
607
@@ -607,6 +654,33 @@ def add_friends(self, phone):
607
654
# 清空已输入的字符
608
655
self .clean_phone ()
609
656
657
+ def fuck (self ):
658
+ """
659
+ 发99乘法表 点进输入框 随便输入一个字符 出现“发送”两个字就可以用此函数了
660
+ :return:
661
+ """
662
+ bounds = self ._adb .find_node_by_text ("发送" )
663
+ while 1 :
664
+ for i in range (1 , 9 ):
665
+ for j in range (1 , i ):
666
+ tem = str (i ) + "*" + str (j ) + "=" + str (i * j )
667
+ print (tem )
668
+ self ._adb .adb_input (tem )
669
+ self ._adb .click_use_bounds (bounds )
670
+
671
+ def Imsorry (self ):
672
+ """
673
+ 道歉 使用同上
674
+ :return:
675
+ """
676
+ bounds = self ._adb .find_node_by_text ("发送" )
677
+ i = 1
678
+ tem = "Im.Sorry.DuDu"
679
+ while 1 :
680
+ self ._adb .adb_input (tem )
681
+ self ._adb .click_use_bounds (bounds )
682
+ i += 1
683
+
610
684
611
685
def main (self ):
612
686
#读取手机号数据
@@ -616,15 +690,15 @@ def main(self):
616
690
self .add_friends (phone )
617
691
618
692
def test (self ):
619
-
620
- # 唤醒屏幕
621
- self ._adb .wake_up_the_screen ()
622
- # 解锁 此处只能滑动解锁
623
- self ._adb .unlock ()
624
- # 启动微信
625
- self ._adb .start_wechat ()
626
- # 判断微信是否启动
627
- self ._adb .check_wechat_is_start ()
693
+ global phone_can_write_index
694
+ # # 唤醒屏幕
695
+ # self._adb.wake_up_the_screen()
696
+ # # 解锁 此处只能滑动解锁
697
+ # self._adb.unlock()
698
+ # # 启动微信
699
+ # self._adb.start_wechat()
700
+ # # 判断微信是否启动
701
+ # self._adb.check_wechat_is_start()
628
702
# 添加好友
629
703
self ._adb .click_add_friend ()
630
704
# 点击那两个 微信号/手机号
@@ -633,10 +707,11 @@ def test(self):
633
707
phone_datas = [get_keywords_data (phoe_tables , i , phone_get_col ) for i in
634
708
range (1 , phoe_tables .nrows )]
635
709
for phone in phone_datas :
710
+
636
711
self .add_friends (phone )
712
+ phone_can_write_index += 1
637
713
638
714
639
715
if __name__ == '__main__' :
640
716
fun = Main ()
641
- # fun.main()
642
717
fun .test ()
0 commit comments