网易云-python自动化脚本

终版,增加计划任何bat

pyrpa_music163.zip

music-163.zip

opencv对中文路径支持不好,解决中文路径问题!!!

requirements.txt

V2

  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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
#功能:随机播放网易云音乐
#1.在指定时间段启动网易云音乐(支持多个)
#2.第一次启动网易云音乐会随机等待60-1200秒,来个时差
#3.图片目录在脚本同级目录image,用于图片点击
#4.歌曲列表在脚本同级目录src,随机搜索歌曲
#5.每个动作作为后就随机等待170-1200
#测试环境:win2019、python3.10


import subprocess
import os
import random
import pyautogui
import cv2
import numpy as np
from time import sleep
import pyperclip
import time


#获取随机数
def random_num(x, y):
    '''
    获取随机数,若输入参数都是整数,则返回是整数;否则返回浮点数
    x:开始值
    y:结束值
    '''
    # 首先判断x和y是否都为整数类型
    if isinstance(x, int) and isinstance(y, int):
        num = random.randint(x, y)
    else:
        # 将参数转换为浮点数
        x = float(x)
        y = float(y)
        num = random.uniform(x, y)
        # 浮点数保留两位小数
        num = round(num, 2)
    return num




#读取文件,并随机一行内容,必须是utf-8字符集!!!
def random_lines(file_path):
    """
    读取指定文件的内容,并将随机选择的一行复制到剪切板。
    :file_path (str): 要读取的文件路径。
    :return 被复制到剪切板的
    """
    with open(file_path, 'r', encoding='utf-8') as file:
        lines = file.readlines()
    # 随机选择一个元素,也就一行内容
    random_line = random.choice(lines).strip()

    return random_line




#输入框使用,将字符串一个一个输出
def input_every_str(input_str):
    '''
    将字符串一个一个到剪切板,模拟人工输入
    str:字符串
    '''
    for i in input_str:
        print(i)
        pyperclip.copy(i)
        pyautogui.hotkey("ctrl","v")
        num=random_num(0.5,2.0)
        sleep(num)
    #回车确认
    pyautogui.press('enter')




#获取当前时间
def datetime_now():
    current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print("当前时间:", current_time)
    return current_time






#判断当前时间是否在两个时间之间
def work_time(time_range):
    '''
    判断当前时间是否在2个时间之间
    :time_start:开始时间,如08:30
    :time_end:结束时间,如20:00
    :return true或flase
    '''
    init_num=0
    for i in time_range:
        #h获取开始时间
        time_start,time_end=i.split("-")
        time_start = time_start.strip()
        time_end = time_end.strip()

        #获取当前时间戳
        timestamp = time.time()
        #保留整数时间戳
        tamp_now = round(timestamp)
        # 将时间戳转换为时间元组
        local_time = time.localtime(tamp_now)
        # 格式化日期为 xxxx-xx-xx 的形式
        today_date = time.strftime("%Y-%m-%d", local_time)
        #拼接日期+时间
        date_f_start=(f"{today_date} {time_start}")
        date_f_end=(f"{today_date} {time_end}")

        #开始时间戳
        # 将日期时间字符串解析为时间元组对象
        time_obj_start = time.strptime(date_f_start, "%Y-%m-%d %H:%M:%S")
        # 将时间元组对象转换为时间戳
        tamp_start = time.mktime(time_obj_start)

        #结束时间戳
        # 将日期时间字符串解析为时间元组对象
        time_obj_end = time.strptime(date_f_end, "%Y-%m-%d %H:%M:%S")
        # 将时间元组对象转换为时间戳
        tamp_end = time.mktime(time_obj_end)


        #判断当前时间是否在工作时间呢
        if tamp_start <= tamp_now <= tamp_end:
            init_num +=1
        else:
            init_num +=0
    #若初始值大于0,则有在工作时段
    if init_num >0:
         print(f"Running,工作时段:\t\t{time_range}")
         return True
    else:
        print(f"Warning,非工时段:\t\t{time_range}")
        return False




#点击图片
def find_and_click(image_path, tip=5,x_move=0,y_move=0,confidence_threshold=0.8):

    '''
    查找图片并点击
    :param image_path: 图片路径
    :param tip: 点击位置,1-9代表九个方向(1左上),2-4代表上下左右,5-8代表四个角
    :x_move: 偏移量
    :y_move: 偏移量
    :param confidence_threshold:  置信度阈值,默认为0.8
    :return: 返回True表示找到并点击成功,False表示未找到
    '''



    # 获取屏幕截图
    screenshot = pyautogui.screenshot()
    screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR)



    #中文转二进制
    img_data = np.fromfile(image_path, dtype=np.uint8)
    # 加载目标图片
    target_image = cv2.imdecode(img_data, cv2.IMREAD_COLOR)
    target_h, target_w = target_image.shape[:2]

    # 匹配图片
    result = cv2.matchTemplate(screenshot, target_image, cv2.TM_CCOEFF_NORMED)

    # 找到匹配结果中大于置信度阈值的位置
    locations = np.where(result >= confidence_threshold)
    locations = list(zip(*locations[::-1]))
    #初始化单击点
    center_x=1
    center_y=1
    if locations:
        #点击位置
        if tip==1:
            # 计算点击位置(取第一个匹配位置的中心点)
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + 1
        elif tip==2:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + 1
        elif tip==3:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + 1
        elif tip==4:
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + target_h / 2
        elif tip==5:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + target_h / 2
        elif tip==6:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + target_h / 2
        elif tip==7:
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + target_h -1
        elif tip==8:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + target_h -1
        elif tip==9:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + target_h -1
        # 偏移量
        center_x = center_x + x_move
        center_y = center_y + y_move

        # 点击操作        
        pyautogui.click(center_x, center_y)

        print(f"点击坐标:({center_x}, {center_y}) \t\t图片:{image_path}")
        return center_x, center_y
    else:
        print(f"未找到目标图片:{image_path}")
        return False






#程序状态
def stat_file(file_path):
    '''
    查看程序是否允许
    file_path: 程序路径
    '''
    exec_name=os.path.basename(file_path)
    print(f"查看进程:{exec_name}")
    # 正确的 tasklist 命令格式
    run_stat = subprocess.run(
        ['tasklist','|', 'findstr', '/i', exec_name ],
        capture_output=True,
        text=True,
        shell=True
    )

    # 根据 taskkill 的返回码判断是否成功
    if run_stat.returncode == 0:
        print("程序已存在。")
        return True
    else:
        print("进程不存在!")
        return False

    sleep(5) 




#启动程序
def run_file(file_path):
  '''
  启动程序
  file_path:路径
  '''

  #判断是否第一次启动
  #若进程不存在就是第一次启动,随机等待秒后再启动
  stat=stat_file(file_path)
  if not stat:
      wait=random_num(60,1200)
      print(f"第一次启动,随机等待{wait}秒")
      sleep(wait)

  #启动
  if os.path.exists(file_path):
      start_status=subprocess.Popen(file_path)
      print("程序启动!")
  else:
      print("文件不存在,退出!")
      exit()





#结束程序名
def stop_file(file_path):
    '''
    结束程序
    exec_name: 程序名称
    '''
    exec_name=os.path.basename(file_path)
    print(f"开始结束进程:{exec_name}")
    # 正确的 taskkill 命令格式
    run_stat = subprocess.run(
        ['taskkill', '/IM', exec_name, '/F'],
        capture_output=True,
        text=True,
        shell=True
    )

    # 根据 taskkill 的返回码判断是否成功
    if run_stat.returncode == 0:
        print("程序结束!")
    else:
        print("进程不存在!")

    sleep(5)  






#首页
def wait_index():
    wait=random_num(1.0,5)
    sleep(wait)
    for i in  range(1,30):
        img_path=os.path.join(img_dir,'网易云1.png')
        result_stat=find_and_click(img_path,5)
        if result_stat:
            break
        else:
            sleep(1)
    wait=random_num(2,5)
    sleep(wait)

    #更新提示
    img_path=os.path.join(img_dir,'暂不升级.png')
    find_and_click(img_path,5)








class select_cmd():
    #1.上一曲
    def run1():
        print(r"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 执行操作:上一曲 /////////////////////////////")
        #1.启动文件
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        run_file(file_path)
        wait_index()
        #2.等待3-5秒
        num=random_num(3.0,5.0)
        sleep(num)
        #3.点击上一曲
        img_path=os.path.join(img_dir,'上一曲.png')
        find_and_click(img_path,5)
        #4.等待
        num=random_num(0.8,5.0)
        sleep(num)
        #5.关闭网易云
        img_path=os.path.join(img_dir,'关闭.png')
        find_and_click(img_path,6)



    #2.播放/暂停
    def run2():
        print(r"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 执行操作:播暂 /////////////////////////////")
        #1.启动文件
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        run_file(file_path)
        wait_index()
        #2.等待3-5秒
        num=random_num(3.0,5.0)
        sleep(num)
        #3.点击播暂
        img_path=os.path.join(img_dir,'play.png')
        find_and_click(img_path,6)
        #4.等待
        num=random_num(0.8,5.0)
        sleep(num)
        #5.关闭网易云
        img_path=os.path.join(img_dir,'关闭.png')
        find_and_click(img_path,6)



    #3.下一曲
    def run3():
        print(r"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 执行操作:下一曲 /////////////////////////////")
        #1.启动文件
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        run_file(file_path)
        wait_index()
        #2.等待3-5秒
        num=random_num(3.0,5.0)
        sleep(num)
        #3.点击播暂
        img_path=os.path.join(img_dir,'下一曲.png')
        find_and_click(img_path,5)
        #4.等待
        num=random_num(0.8,5.0)
        sleep(num)
        #5.关闭网易云
        img_path=os.path.join(img_dir,'关闭.png')
        find_and_click(img_path,6)


    #4.列表歌曲
    def run4():
        print(r"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 执行操作:歌曲列表 /////////////////////////////")
        #1.启动文件
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        run_file(file_path)
        wait_index()
        #2.等待3-5秒
        num=random_num(3.0,5.0)
        sleep(num)
        #3.点击歌曲列表
        img_path=os.path.join(img_dir,'列表-当前播放.png')
        result=find_and_click(img_path,6)
        #若没有找到图片,则需要点击列表按钮
        if not result:
            #点击歌曲列表按钮
            img_path=os.path.join(img_dir,'歌曲列表.png')
            find_and_click(img_path,5)

        #等待1-2秒
        num=random_num(0.8,2.0)
        sleep(num)

        #4.滑轮滚动
        #再次点击
        num=random_num(100,200)
        img_path=os.path.join(img_dir,'列表-当前播放.png')
        x,y=find_and_click(img_path,6,0,num)
        #滑轮滚动方向,1上/2下
        up_down_status=random_num(1,2)
        #滑轮滚动次数
        scroll_num=random_num(0,5)
        #
        if  up_down_status == 1:
            #上
            for i in range(scroll_num):
                wait=random_num(0.5,1)
                sleep(wait)
                pyautogui.scroll(40)
                print(f"上:{scroll_num}次")
        else:
            #下
            for i in range(scroll_num):
                wait=random_num(0.5,1)
                sleep(wait)
                pyautogui.scroll(-40)
                print(f"下:{scroll_num}次")


        #5.双击播放歌曲
        num=random_num(50,320)
        img_path=os.path.join(img_dir,'列表-当前播放.png')
        x,y=find_and_click(img_path,6,0,num)
        pyautogui.click(x,y)
        pyautogui.click(x,y)
        #4.等待
        num=random_num(3.8,5.0)
        sleep(num)
        #5.关闭网易云
        img_path=os.path.join(img_dir,'关闭.png')
        find_and_click(img_path,6)


    #5.搜索歌曲
    def run5():
        print(r"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 执行操作:搜索歌曲 /////////////////////////////")
        #1.启动文件
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        run_file(file_path)
        wait_index()
        #2.等待3-5秒
        num=random_num(3.0,5.0)
        sleep(num)
        #3.点击搜索
        img_path=os.path.join(img_dir,'网易云1.png')
        x,y=find_and_click(img_path,5,300)
        #三连击
        pyautogui.click(x,y)
        pyautogui.click(x,y)
        pyautogui.click(x,y)
        #等待
        wait=random_num(0.8,2.5)
        sleep(wait)
        #清空旧歌曲名称
        pyautogui.press('del')

        #4.随机读取歌曲名称
        file_path=os.path.join(src_dir,'list.txt')
        result_str=random_lines(file_path)

        #5.歌曲名按字符粘贴输入
        input_every_str(result_str)
        #6.等待
        num=random_num(0.8,5.0)
        sleep(num)
        #6.搜索页点击歌手对应的歌曲
        num=random_num(10,100)
        img_path=os.path.join(img_dir,'搜索页-歌手名.png')
        x,y=find_and_click(img_path,4,-(num))        
        pyautogui.click(x,y)
        pyautogui.click(x,y)

        #6.等待
        num=random_num(0.8,5.0)
        sleep(num)
        #7.关闭网易云
        img_path=os.path.join(img_dir,'关闭.png')
        find_and_click(img_path,6)
















######################################################################
#当前脚本所在路径
py_path=os.path.abspath(__file__)
#当前脚本所在目录
py_dir=os.path.dirname(py_path)
#图片所在目录
img_dir=os.path.join(py_dir,'image')
#源文件所在目录
src_dir=os.path.join(py_dir,'src')
#日志
log_file =os.path.join(py_dir,"run.log")





#判断工作时间
time_range=['08:30:00-12:00:00','13:30:00-19:00:00']


#
while True:

    #判断是否工作时段
    run_stat=work_time(time_range)
    if not run_stat:
        file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe'
        stop_file(file_path)
        print("="*80)
        sleep(60)
        continue



    #当前时间
    current_time=datetime_now
    ###随机1-5
    #1.上一曲
    #2.暂停/播放
    #3.下一曲
    #4.播放列表
    #5.随机歌曲
    print('-'*80)
    select_num=random_num(1,5)
    current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print(f"[{current_time}] 执行动作:{select_num}\n")
    # select_num=4
    if select_num == 1:
        select_cmd.run1()
        log_message='1.上一曲'
    elif select_num == 2:
        select_cmd.run2()
        log_message='2.播暂'
    elif select_num == 3:
        select_cmd.run3()
        log_message='3.下一曲'
    elif select_num == 4:
        select_cmd.run4()
        log_message='4.播放列表'
    elif select_num == 5:
        select_cmd.run5()
        log_message='5.搜索歌曲'

    #写入日志
    with open (log_file,"a", encoding="utf-8") as f:    
        # 写入日志内容
        log_write = f"[{current_time}] 执行动作:{log_message}\n"
        f.write(log_write)

    #等待
    wait=random_num(170,1800)
    print(f"等待{wait}秒")
    sleep(wait)

V1

  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
import subprocess
import os
import random
import pyautogui
import cv2
import numpy as np
from time import sleep


#当前脚本所在路径
py_path=os.path.abspath(__file__)
#当前脚本所在目录
py_dir=os.path.dirname(py_path)
#图片所在目录
img_dir=os.path.join(py_dir,'image')



#点击图片
def find_and_click(target_image_path, tip=5,confidence_threshold=0.8):

    '''
    查找图片并点击
    :param target_image_path: 图片路径 
    :param tip: 点击位置,1-9代表九个方向,2-4代表上下左右,5-8代表四个角
    :param confidence_threshold:  置信度阈值,默认为0.8
    :return: 返回True表示找到并点击成功,False表示未找到
    '''



    # 获取屏幕截图
    screenshot = pyautogui.screenshot()
    screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR)



    #中文转二进制
    img_data = np.fromfile(target_image_path, dtype=np.uint8)
    # 加载目标图片
    target_image = cv2.imdecode(img_data, cv2.IMREAD_COLOR)
    target_h, target_w = target_image.shape[:2]

    # 匹配图片
    result = cv2.matchTemplate(screenshot, target_image, cv2.TM_CCOEFF_NORMED)

    # 找到匹配结果中大于置信度阈值的位置
    locations = np.where(result >= confidence_threshold)
    locations = list(zip(*locations[::-1]))
    #初始化单击点
    center_x=1
    center_y=1
    if locations:
        #点击位置
        if tip==1:
            # 计算点击位置(取第一个匹配位置的中心点)
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + 1
        elif tip==2:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + 1
        elif tip==3:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + 1
        elif tip==4:
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + target_h / 2
        elif tip==5:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + target_h / 2
        elif tip==6:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + target_h / 2
        elif tip==7:
            click_x, click_y = locations[0]
            center_x = click_x + 1
            center_y = click_y + target_h -1
        elif tip==8:
            click_x, click_y = locations[0]
            center_x = click_x + target_w / 2
            center_y = click_y + target_h -1
        elif tip==9:
            click_x, click_y = locations[0]
            center_x = click_x + target_w -1
            center_y = click_y + target_h -1
        # 点击操作
        pyautogui.click(center_x, center_y)

        print(f"坐标:({center_x}, {center_y}) \t\t图片:{target_image_path}")
        return True
    else:
        print("未找到目标图片")
        return False

    # if locations:
    #     # 计算点击位置(取第一个匹配位置的中心点)
    #     click_x, click_y = locations[0]
    #     center_x = click_x + target_w / 2
    #     center_y = click_y + target_h / 2
    #
    #     # 点击操作
    #     pyautogui.click(center_x, center_y)
    #     print(f"点击位置:({center_x}, {center_y})")
    #     return True
    # else:
    #     print("未找到目标图片")
    #     return False



# #获取随机数
# def random_num(x, y):
#     '''
#     获取随机数,若输入参数都是整数,则返回是整数;否则返回浮点数
#     x:开始值
#     y:结束值
#     '''
#     # 首先判断x和y是否都为整数类型
#     if isinstance(x, int) and isinstance(y, int):
#         num = random.randint(x, y)
#     else:
#         # 将参数转换为浮点数
#         x = float(x)
#         y = float(y)
#         num = random.uniform(x, y)
#         # 浮点数保留两位小数
#         num = round(num, 2)
#     return num

# #运行文件
# def run_file(file_path):
#   '''
#   启动程序
#   file_path:路径
#   '''
#   if os.path.exists(file_path):
#       start_status=subprocess.Popen(file_path,shell=True,capture_output=true)
#       print("文件启动中")
#   else:
#       print("文件不存在,退出!")
#       exit()
#
# #












######################################################################
# file_path=r'C:\Program Files (x86)\NetEase\CloudMusic\cloudmusic.exe1'
# run_file(file_path)

# num=random_num(10,20)
# print(num)

#图片路径
#播放
img_path=os.path.join(img_dir,'play.png')
find_and_click(img_path,6)

sleep(0.5)
img_path=os.path.join(img_dir,'网易云1.png')
find_and_click(img_path,6)
sleep(0.5)
#
img_path=os.path.join(img_dir,'歌曲列表.png')
find_and_click(img_path,5)