Operation Steps:
1. Open QQ Software
2. Move the mouse to the QQ input place
3. At the input, click the mouse, enter the account number
4. Simulate Press TAB key, enter password, simulate point enter login
#coding =utf-8 import OS import Win32gui import win32api import win32con import SendKeys import time from Ctyp ES import * #多次登录qq, incoming account password def qqload (qq,pwd): #使用系统模块os, open QQ #必须是单引号 + double quotes to run Os.system (' "C:\Program Fi Les (x86) \tencent\qq\bin\qqsclauncher.exe "') #留给qq界面点响应时间 Time.sleep (0.2) # Gets the handle of the window, Parameter 1: class name, Parameter 2: Title hand Le = Win32gui. FindWindow (None, ' QQ ') #返回指定窗口的显示状态以及被恢复的, maximized and minimized window position logid = Win32gui. GetWindowPlacement (handle) Print Logid #设置鼠标位置, the horizontal axis is equal to the left upper corner number plus the input box from the left edge of the difference, the ordinate is equal to the number of upper left and the input box from the upper boundary of the difference #差值可用工具, measured pixel difference Windll.user32.SetCursorPos (logid[4][0]+310,logid[4][1]+280) #模拟鼠标点击操作, left-click First, then release Win32api.mouse_event (Win32con. mouseeventf_leftdown,0,0,0,0) win32api.mouse_event (Win32con. mouseeventf_leftup,0,0,0,0) #!! Note that it must be delayed to enter correctly, otherwise the input error time.sleep (0.2) #安装SendKeys库, you can automatically enter the content Sendkeys.sendkeys (QQ) Time.sleep (0.2) #按下tab键, switch to the input password #模拟键盘操作, check the keyboard corresponding ASC code, the tab corresponds to the ASC code is 9 #先按下, and then released Win32api.keybd_event (9,0,0,0) win32api.keybd_event (9,0,win32con. keyeventf_keyup,0) Time.sleep (0.2) #输入密码, click Enter to sign in to Sendkeys.sendkeys (PWD) time.sleep (0.2) Win32API. keybd_event (13,0,0,0) win32api.keybd_event (13,0,win32con. keyeventf_keyup,0) If __name__ = = ' __main__ ': #在文件中读取帐号密码信息 fn = ' D:\info.txt ' FR = open (FN, ' R '). Readlin ES () #循环打开每一行, use split to divide the list for i in fr:info = I.split ('----') qqload (str (info[0]), str (info[1]) )
Python Development QQ Batch Login