import pyautogui
# 保護措施,避免失控
# pyautogui.FAILSAFE = True
# 為所有的PyAutoGUI函數增加延遲。默認延遲時間是0.1秒。
# pyautogui.PAUSE = 0.5
# 屏幕
# 獲取當前屏幕分辨率
# screenWidth, screenHeight = pyautogui.size()
# 截圖並保存
# im1 = pyautogui.screenshot()
# print(im1)
# im1.save('my_screenshot.png')
# im2 = pyautogui.screenshot('my_screenshot2.png')
# 鼠標
# 獲取當前鼠標位置
# currentMouseX, currentMouseY = pyautogui.position()
# 將鼠標光標移動到(200,300)
# pyautogui.moveTo(200,300)
# 將鼠標光標右移100個像素點
# pyautogui.move(100,0)
"""
pyautogui.easeInQuad #開始慢,結束快
pyautogui.easeOutQuad #開始塊,結束慢
pyautogui.easeInOutQuad #開始塊,結束塊,中間慢
pyautogui.easeInBounce #結束時反彈
pyautogui.easeInElastic #結束時是橡皮筋
"""
# 將當前鼠標光標移動到位置(400,500),持續時間是2秒,移動開始慢,結束時快
# pyautogui.moveTo(400,500,2,pyautogui.easeInOutQuad)
# 當前位置點擊鼠標
# pyautogui.click()
# 在100,300的位置點擊鼠標
# pyautogui.click(100,300)
# 在100,300的位置點擊鼠標右鍵
# pyautogui.click(100,300,button='right')
# 用鼠標左鍵點擊2次,間隔時間0.25秒
# pyautogui.click(clicks=2,interval=0.25)
# 將當前光標位置的東西移動到(100,200)處,在拖動的過程中按住鼠標左鍵。
# pyautogui.dragTo(100,200,button='left')
# 將當前光標位置的東西向下移動100個像素點,在拖動的過程中按住鼠標左鍵。
# pyautogui.drag(100,0,button='left')
#鼠標當前位置滾輪滾動
# pyautogui.scroll()
#鼠標水平滾動(Linux)
# pyautogui.hscroll()
#鼠標左右滾動(Linux)
# pyautogui.vscroll()
# 鍵盤
# 輸入字符串
# pyautogui.write("Hello World!")
# 按鍵
# pyautogui.press('f11')
# 按下抬起
# pyautogui.keyDown('shift')
# pyautogui.keyUp('shift')
# 組合鍵
# pyautogui.hotkey('ctrl', 'shift')
# 快捷鍵列表
['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(',
')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`',
'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace',
'browserback', 'browserfavorites', 'browserforward', 'browserhome',
'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear',
'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete',
'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10',
'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20',
'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja',
'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail',
'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack',
'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6',
'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn',
'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn',
'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator',
'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab',
'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen',
'command', 'option', 'optionleft', 'optionright']
# 彈窗
# pyautogui.alert(text='This is an alert box.', title='Test')
# 選擇框
# pyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])
# 輸入框
# pyautogui.prompt('input message')
# 密碼框
# pyautogui.password('Enter password (text will be hidden)')
# 像素匹配
# 方法1
# im = pyautogui.screenshot()
# im.getpixel((100, 200))
# 方法2
# pix = pyautogui.pixel(100, 200)
# print(pix,pix[0],pix.green,pix[2])
# 方法3
# pyautogui.pixelMatchesColor(100, 200, (130, 135, 144))
# 圖像匹配
# pyautogui.locateOnScreen('1.png')
# 中心點
# x, y = pyautogui.locateCenterOnScreen('calc7key.png')
# 查找所有
# pyautogui.locateAllOnScreen('1.png')
# 近似匹配(需要opencv)
# pyautogui.locateOnScreen('1.png', confidence=0.9)
# 灰度匹配
# pyautogui.locateOnScreen('1.png', grayscale=True)
if __name__ == "__main__":
pyautogui.FAILSAFE = True
pyautogui.move(100,100,1,pyautogui.easeInOutQuad)