In the last few days of the examination, I had no mood at all, and I was bored to start watching and connecting. Unfortunately, I lost too much and was very upset. So I made a plug-in to watch the plug-in myself. There are a lot of plug-ins on the Internet that can be downloaded for continuous viewing. However, it is naturally different to use them by yourself. After all, I still want to learn about computers ~~ Here is a brief description of the process. If you are interested in writing, refer ~~~
I useMFCDone ~ Development Environment: XP SP2, Visual Studio. NET 2003
I. How to watch QQ games.
The gameplay is very simple. You can click two identical grids with the mouse. If two grids can be connected by a line, the two grids can be deleted. The key is that this line can have at most two inflection points !~
2. Plug-in functional requirements.
Simple functions: a single key enables the game to automatically remove a pair of grids ········
Iii. Plug-in principle.
1. Get game data:
First, you need to obtain the grid data of the game to determine which two grids can be deleted. For QQ games, you can use a common online practice to read screen pixels and determine the lattice (red ball or blue ball or black peach or) based on the pixels ······).
In order to obtain the pixel data of the game, you must first obtain the pointer to the game window. Program I have registered several global hotkeys. My mechanism is to activate the game window and press the global hotkeys for plug-in registration (for example, I am using the F1 key ). In this case, a window pointer is obtained using an API.
// Cwnd * m_pgamewindow; // game window
M_pgamewindow = getforegroundwindow (); // retrieve the "TOP" Window
Then we can read the pixel value of the game window. The basic idea is to write a loop.
For (INT I = 0; I <11; I ++) // 11 rows
{
For (Int J = 0; j <19; j ++) // 19 columns all over the world know that QQ's check box is 11 rows and 19 columns.
// Specific pixel read Operations
}
Details Code Don't post it ~ Too many .. The final result is to save the grid data of the screen to a two-dimensional array of 11x19. The array coordinates (I, j) represent the rows and columns in the game. If the value of array [I] [J] is 0, it indicates that there is no space, and 1, 2, 3 · represents different grids. The image above should be encoded as follows:
1 0 0 2 3 0 4 5 0 6 7 0 0 8 3 0 0 the first line of the encoding results .. Other rows will not be pasted.
2. Calculate a pair of squares that can be eliminated:
I have saved the game data to a two-dimensional array. The next step is how to calculate which two grids can be deleted. My approach is to regard this two-dimensional array as a graph and use the improved width Graph Search for the link.Algorithm .
3. Simulate Mouse clicking to remove the grid:
After the algorithm calculates the coordinates of two arrays of the deletable grids, it needs to convert them to the actual screen coordinates, and then simulate the mouse clicking.
Void cllkcheatdlg: Imitate (INT beginx, int beginy, int endx, int Endy)
{
// Two coordinates relative to the game window
Cpoint begin = getpoint (beginx, beginy );
Cpoint end = getpoint (endx, Endy );
// Convert to screen coordinates
M_pgamewindow-> clienttoscreen (& begin );
M_pgamewindow-> clienttoscreen (& End );
// Move the mouse to the first point
: Setcursorpos (begin. X, begin. y );
Mouse_event (mouseeventf_leftdown, 0, 0, 0 );
Mouse_event (mouseeventf_leftup, 0, 0, 0 );
: Setcursorpos (end. X, end. y );
Mouse_event (mouseeventf_leftdown, 0, 0, 0 );
Mouse_event (mouseeventf_leftup, 0, 0, 0 );
}
// Getpoint is written by myself. It is used to calculate the transformation from logical coordinates to game window coordinates.
Iv. Test
Let's see if I used this tool for seckilling. Provides the function of deleting all buttons.