import pyautogui as dm
dm.FAILSAFE = True
dm.PAUSE = 0.1
screenWidth, screenHeight = dm.size()
x, y = dm.position()
print(x, y)
dm.moveTo()
dm.scroll(200)
dm.press("a")
dm.hotkey('ctrl', 'c')
dm.hotkey('altleft', 'f4')
dm.typewrite(message='Hello world!', interval=0.5)
dm.pixel(100, 200)
dm.pixelMatchesColor(100, 200, (255, 255, 255))
dm.pixelMatchesColor(100, 200, (248, 250, 245), tolerance=10)
x, y = dm.locateCenterOnScreen(r'C:\Users\ZDH\Desktop\PY\region_screenshot.png')
print(x, y)
def findpic_dlclick(pic,x1=0,y1=0,x2=1920,y2=1080):
img_location = dm.locateOnScreen(pic,region=(x1,y1,x2,y2))
if img_location:
dm.doubleClick(dm.center(img_location))
return True
def findpic_lclick(pic, x1=0, y1=0, x2=1920, y2=1080):
img_location = dm.locateOnScreen(pic, region=(x1, y1, x2, y2))
if img_location:
dm.click(dm.center(img_location))
return True
def findpic_rclick(pic,x1=0,y1=0,x2=1920,y2=1080):
img_location = dm.locateOnScreen(pic,region=(x1,y1,x2,y2))
if img_location:
dm.click(dm.center(img_location),button="right")
return True
dm.alert(text='This is an alert box.', title='Test')
ret= dm.confirm('Enter option.', buttons=['A', 'B', 'C'])
print(ret)
a = dm.password('Enter password (text will be hidden)')
print(a)
a = dm.prompt('input message')
print(a)
print(findpic_lclick("开始菜单.png",0,1011,72,1080))
exit()
x, y = dm.locateCenterOnScreen(r'C:\Users\ZDH\Desktop\PY\region_screenshot.png')
print(x, y)
im = dm.screenshot()
im.save('屏幕截图.png')