pythonはコンピュータのマウスとキーボードを制御することを実現して、QQに登録する方法の例
この実例はパソコンのマウスとキーボードを制御してQQに登録する方法を実現することを述べている。皆さんに参考にしてあげます。具体的には以下の通りです。
ここで述べたように、皆様のPythonプログラムの設計に役に立ちます。
import os
from pynput.mouse import Button,Controller
from pynput.keyboard import Key
from pynput.keyboard import Controller as W
from time import sleep
mouse = Controller()
keyboard = W()
#
mouse.position = (1433, 884)
mouse.press(Button.left)
mouse.release(Button.left)
sleep(2)
# QQ( QQ )
os.startfile("C:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe")
mouse = Controller()
#
# sleep(5)
# print(' {}'.format(mouse.position))
sleep(2)
mouse.position = (654, 340)
mouse.press(Button.left)
mouse.release(Button.left)
sleep(1)
mouse.position = (729, 489)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.press(Key.tab)
keyboard.release(Key.tab)
# QQ
keyboard.type("QQ ")
sleep(1)
#
keyboard.press(Key.tab)
keyboard.release(Key.tab)
keyboard.type("QQ ")
#QQ (765, 551)
keyboard.press(Key.enter)
keyboard.release(Key.enter)
もっとPythonに関する内容に興味がある読者は、当駅のテーマを調べてもいいです。「Pythonプロセスとスレッド操作テクニックのまとめ」、「Python Socketプログラミング技術のまとめ」、「Pythonデータ構造とアルゴリズム教程」、「Python関数使用テクニックのまとめ」、「Python文字列操作テクニックのまとめ」、「Python入門と階段の経典教程」および「Pythonファイルとディレクトリ操作の概要」ここで述べたように、皆様のPythonプログラムの設計に役に立ちます。