Use Python to quickly log in to multiple qqs, this program is a bit interesting(25)

Hello children, hello big friends!

I'm Cat Girl, a primary school student who fell in love with Python programming.

Welcome to learn Python with cat girl.

today's topic

Have you ever used WeChat?

I believe that many friends, like the cat girl, must have used it!

In the past three years, we have taken a lot of online classes at home. We often need to contact teachers on WeChat for online classes!

Have you ever used qq?

What is qq? The cat sister has not used it, but the cat dad has used it.

He said that when he first went to college, QQ was very popular.

At that time, it was possible to apply for a 7-digit QQ number for free (depending on luck), and he even bought an 8-digit QQ number. At that time, it was easy to apply for a 9-digit number.

At that time, the network speed was poor, QQ had to log in to the server, and the 9-digit number often failed to log in, but the 8-digit number was fine, so this is the reason why he bought an 8-digit QQ number.

Since the rise of smartphones, the limelight of qq has been robbed by WeChat, but many people's previous qq has not been abandoned, but the frequency of use has been greatly reduced. After all, many people's youth is recorded there.

For example, the qq mailbox uses the qq number, and the mailbox is still used occasionally.

It is a bit cumbersome to log in to qq on the computer. After all, if you do not log in often, sometimes you need to scan the code on your mobile phone, and it is impossible to log in to multiple qq numbers at the same time on your mobile phone, right?

Either you need to bind your mobile phone to send a verification code to assist in verification, which is also a bit cumbersome.

It would be great if there is a program that can automatically log in from the pc.

If you log in frequently, you probably don't need a mobile phone for verification.

principle

After searching on the Internet, some big guys have shared the program. The principle is to use Python to simulate the operation of the mouse and keyboard, and enter the user name and password into the qq login box to make the login successful.

Related programs, cat sisters are placed in the next article, friends who need it can read it.

The key code, Maomei will learn with you:

Line 13:

The system() function in the os module can easily run other programs or scripts.

The syntax is as follows: os.system(command), the meaning of its parameters is as follows:

command The command to be executed is equivalent to the command entered in the cmd window of Windows.

If you want to pass parameters to a program or script, you can use a space to separate the program and multiple parameters.

Line 17:

When using Python, sometimes you need to manipulate something in the system window.

The win32gui.Findwindow(param1, param2) method finds window handle parameters and corresponding parameter values. Param1 needs to pass in the class name of the window, and param2 needs to pass in the title of the window.

20 lines:

The position of the window.

Line 26:

Define a keyboard object for inputting related information.

Lines 34~35:

In the qq input box, simulate a mouse click and prepare to input information.

Line 40:

Enter the qq number.

Lines 43~44:

Simulate pressing the TAB key to switch to the input password box.

Line 46:

Simulate entering a password.

Lines 48~49:

Simulate the Enter key to log in.

pywin32 library 

If Python does not have a built-in library for accessing the windows system API, you need to download pywin32, which is a third-party module library. Its main function is to facilitate python developers to quickly call a module library of the windows API.

It directly wraps almost all Windows APIs and can be easily called directly from Python. Another major function of this module is COM programming through Python.

win32api: Some commonly used API functions are defined in the module, for example: MessageBox

win32gui: Some APIs related to graphics operations are defined in the module, such as: FindWindow

win32con: The module defines the macros in the windows API, that is, macro constants.

There is a PyWin32.chm help file under the installation directory Python38\Lib\site-packages, which contains a lot of information.

More detailed information can be found online at:

keybd_event(bVk, bScan, dwFlags, dwExtraInfo)

The first parameter: virtual key code (see the appendix for the keyboard key code comparison table);

The second parameter: hardware scan code, generally set to 0;

The third parameter: a flag bit of the function operation. If the value is KEYEVENTF_EXTENDEDKEY, the key is pressed, or it can be set to 0. If the value is KEYEVENTF_KEYUP, the key is released;

The fourth parameter: defines an additional 32-bit value related to the keystroke, generally set to 0.

final effect

Cat dad created a new notepad file my_qq.txt, and after reading the information from this my_qq.txt with the above screenshot program, log in one by one.

  • The first line is the executable file path of qq

  • The second line is the delay after qq login

  • From the third line to the Nth line, the qq number and password are separated by the TAB key

Every time you run the script, you can automatically log in to these qq numbers.

The above programs, interested friends, can discuss and study together!

Use Python to simulate mouse and keyboard operations, which is very useful in many occasions.

What do you think?

Well, let's learn this today!

If you encounter any problems, let's communicate and solve them together.

Guess you like

Origin blog.csdn.net/parasoft/article/details/130021726