# -*- coding: UTF-8 -*-
import pyautogui
import pyperclip
import time
name = input('请输入想听的音乐:')
def click_wyy():
wyy = pyautogui.locateOnScreen('img/wyy.png')
if wyy:
wyy_cent = pyautogui.center(wyy)
pyautogui.moveTo(wyy_cent, duration=2)
pyautogui.click(clicks=2)
return True
else:
return False
def search(n):
if pyautogui.locateOnScreen('img/search.png'):
search_img = pyautogui.locateOnScreen('img/search.png')
search_img_cent = pyautogui.center(search_img)
pyautogui.moveTo(search_img_cent)
pyautogui.click()
pyautogui.hotkey('enter')
time.sleep(2)
pyperclip.copy(n)
pyautogui.hotkey('ctrl', 'v')
pyautogui.hotkey('enter')
time.sleep(2)
pyautogui.moveRel(0, 280, duration=2)
pyautogui.click(clicks=2)
return True
else:
return False
if click_wyy():
click_wyy()
else:
print('监听wyy!')
while True:
if search(name):
search(name)
else:
print('监听搜索框!')