Python 類比鼠鍵

來源:互聯網
上載者:User

標籤:pytho   返回   列印   imp   bsp   try   print   點擊   UI   

讓python 自動操作案頭或應用視窗,點擊,滑動滑鼠,輸入文字等

# coding=utf-8from pymouse import PyMousefrom pykeyboard import PyKeyboardimport time, randomimport pyautogui as pagm = PyMouse()k = PyKeyboard()x_dim, y_dim = m.screen_size()# 開啟瀏覽器,點擊百度搜尋方塊m.click(282, 183)time.sleep(0.3)# 輸入關鍵字k.type_string(‘cnblog‘)# 斷行符號k.tap_key(k.enter_key)# 在頁面內瞎點while True:    i = random.uniform(-10, 10)    m.scroll(2 * i, None, None)    time.sleep(2)    m.click(500 + 50 * i, 400 + 20 * i)# 擷取滑鼠座標def getM_xy():    try:        while True:            print "Press Ctrl-C to end"            x, y = pag.position()  # 返回滑鼠的座標            posStr = "Position:" + str(x).rjust(4) + ‘,‘ + str(y).rjust(4)            print posStr  # 列印座標            time.sleep(1)            # os.system(‘cls‘)  # 清楚螢幕    except  KeyboardInterrupt:        print ‘end....‘

 寫出來也不覺得有什麼用,純粹是閑的蛋疼吧。

Python 類比鼠鍵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.