Text/figure gray fox (Bink & E.S. T)
==========================================
As the saying goes, hackers who do not program are not good hackers (I will program, but I am not a hacker, because I am a programmer, haha ). Today, we will create our own gadgets.
What we need to do is a QQ bomb. In fact, this tool is not very powerful, and it can only be harassed when chatting with friends. The idea is very simple, that is, the program constantly simulates the press Ctrl + Enter to automatically send messages, but when we make it, we naturally have such a satisfaction and joy.
The selection of programming tools is very important. If such a small Dongdong uses VC, it is not a common problem. What? You said Delphi is very fast? That is, but Pascal certainly won't have many C people. As far as our school is concerned, C language is a required course for all science and technology majors. For rapid visual development, BCB is of course the first choice, because the first powerful weapon of martial arts, which has both the advantages of VC and Delphi, is coming soon. Let's welcome it with a warm round of applause: borland C ++ Builder 6.0 (BCB ).
Program details: First open the chat window with friends, the program searches for the window handle through the window name, the next step is to automatically copy the statement to be sent to the clipboard, then, activate the chat window to get the keyboard input focus. Finally, press Ctrl + V and Ctrl + Enter repeatedly.
When BCB 6.0 is started, an Application is automatically created by default, a PageControl control is placed on the form (on the Win32 page), and its Align attribute is set to alClient, create a New TabSheet (many people say that this control cannot be found. In fact, the method for creating a TabSheet is to right-click PageControl and then create a New Page ), set the Caption attribute to "bomb friends", and set the remaining controls as shown in Figure 1. The Name attributes of the Edit control are NcikNameEdit, FrequentEdit, and TimesEdit. The bottom is a Memo control, and the Name attribute is set to WordMemo. Now let's talk about it with code (the Code focuses on the principle of program implementation and has been removed, and the complete project and code file have been packaged and provided ).
Figure 1
First, we need to find the chat window. The implementation code is as follows.
Char WindowBuffer [MAX_PATH];
// Buffer for storing the window name
Sprintf (WindowBuffer, "chatting with % s", NickNameEdit-> Text );
HANDLE hWindow = FindWindow (NULL, WindowBuffer );
// Find the window
If (hWindow = NULL)
{
ShowMessage ("sorry, this chat window is not found! ");
Return;
}
In this way, we get the hWindows handle of the chat window, and then we can start writing the bombing code.
This-> Hide (); // Hide the window, no need to show
For (int I = 1; I <= StrToInt (TimesEdit-> Text); I ++)
{// Because the edit box contains the String type by default, we need to convert the number of bombing times to the int type through StrToInt to use it in the loop.
WordMemo-> SelectAll (); // select all statements
WordMemo-> CopyToClipboard; // copy it to the clipboard
SetForegroundWindow (hWindow );
// Activate the chat window to get the keyboard focus
StartBomb (); // call the bomb function to start bombing
Sleep (StrToInt (FrequentEdit-> Text ));
// Pause for a period of time and continue the next loop
}
This-> Show (); // The window is displayed after execution.
The code of the StartBomb () function is as follows.
Void _ fastcall TMainForm: StartBomb (void)
{
Keybd_event (VK_CONTROL, 0, 0); // press Ctrl
Keybd_event (V, V,); // press the V Key in uppercase.
Keybd_event (V, V, KEYEVENTF_KEYUP, 0); // simulate releasing the V Key
Keybd_event (VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // simulate the release of the Ctrl key
Keybd_event (VK_CONTROL, 0, 0 );
Keybd_event (VK_RETURN, 0, 0); // press Enter
Keybd_event (VK_RETURN, 0, KEYEVENTF_KEYUP, 0 );
Keybd_event (VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 );
}
This QQ bomb model has been released. Remember, it is just a model. If you want to build a software program, you can use it. We also need to consider user friendliness, program perfection, and so on. Due to time constraints, I did not optimize this test bomb more. The function of "blow up QQ Group" is the same as the above principle, you only need to find the window. For the tray icon, we can use the TrayIcon control that comes with BCB (on the Samples page). Then we can simply set the attributes to use it, which is very convenient.
This program has a BUG in encoding. If the character to be sent is Chinese, it turns into garbled characters when sent to the chat window. Due to time constraints, I cannot find a real solution. However, I learned how to operate the clipboard when trying to solve it, Because CopyToClipboard () is only a member function in BCB and cannot be used directly elsewhere, we can implement this function through a series of functions. The following is an example code.
AnsiString buffer; // Save the characters to be copied
OpenClipboard (NULL); // open the system clipboard
EmptyClipboard (); // You must clear the clipboard before using it.
HGLOBAL hClipData; // allocate a memory segment. The size is equal to the size of the string to be copied.
HClipData = GlobalAlloc (GMEM_DDESHARE, buffer. Length () + 1 );
Char * pchData; // lock the memory control handle
PchData = (char *) GlobalLock (hClipData );
Strcpy (pchData, buffer. c_str (); // assign the variable value to the global memory.
GlobalUnlock (hClipData); // unlock the memory control handle
SetClipboardData (CF_TEXT, hClipData); // put the data to the clipboard in the corresponding format through the global memory handle
CloseClipboard (); // close the clipboard after use
This code is usually used to complete inter-process communication and other functions. Because it is simple to use and easy to understand, it is still widely used.
Finally, I would like to explain some tips about BCB.
1) by default, you will find that the executable program generated by it is very small, but it cannot be run on a machine without BCB or Delphi installed. At this time, we need to set it, in "project-> Options-> Compiler", click "Release". In "project-> Options-> Packages", cancel the "Builder with runtime packages" check, in "project-> Options-> Linker", cancel the check before "Use dynamic RTL.
2) Change the built-in BCB icon and click "Project-> Options-> Application-> LoadIcon". The target image must be in ico format.
3) if you are a beginner of BCB, we recommend the C ++ Builder Q & A series of articles, which provide a detailed description of all common controls in BCB and are very useful.