Preface
At the beginning of April, a friend came to me and said that he wanted to develop a simulation click Software. After the final software is done, the results are not satisfactory. The only development I think the best is to give up, do the operation of him, insisted that this is no problem, said to change the way of cooperation. Eventually it was gone.
However, in the middle of a rewrite, three times the core method of change, countless search data, find solutions to the early morning. The middle of the discussion was punctuated by countless discussions and revisions. Although the function is very simple, but also spent three months of painstaking efforts. Thought, or want to sum up a bit. The final software interface is as follows:
Implementing Ideas & Using Controls
First, open the Web page in the built-in browser, get the coordinates of the desired click through JavaScript, calculate the coordinates in the Web page, coordinate the position in the screen, simulate the mouse operation (rolling pulley, move, click), and randomly two clicks. Finally, clear the cache, replace the IP, replace the resolution, and user-agent. To achieve the purpose of deceiving the site and thinking that it is different for people to click.
The specific method to use is as follows:
- Built-in browser, Cefsharp 49.0 in order to be compatible with. NET 4.0, most Win7 can be used directly;
- Mouse, keyboard analog input, Inputsimulator, the earliest before is directly called Windows API, no this easy to use;
- Switch IP, two ADSL switching and IP daemon software (ADSL this is not currently used, DotRas.dll);
- Switching the resolution is directly with GitHub above the code directly. Screenresolutionchanger;
- License use Easylicense;
- Local database SQLite;
- The code confuses. NET Reactor;
little record.
anti-virus software pit : when using analog input, always prompt user Interface Privilege Isolation (user interface privilege isolation) problem, insufficient authority. Try to shut down Windows UAC, start with a super administrator, add digital certificates to the software, put them in the C-disk system directory, and so on. All sorts of methods are tried, and the operation cannot be simulated. There is no way, then the pig above the task, put on the demo. Never thought, a college student to solve for me, is because of 360 and other anti-virus software caused by ....
IP Wizard dll version of the pit : the first use of their official website to provide the DLL, found that their DLL is basically not used up, as if it is not updated for a long time. In addition, the status code is changed at will and no update notification is issued. Cause also the result is, obviously before good, how today suddenly can't use up.
ADSL test pits: The code is written well and cannot be tested, or it is cumbersome to test. Now in this era with ADSL dial-up internet less and fewer, also want to test also trouble. Finally found a remote ADSL host, the results of a test on the network, embarrassed ...
Get Network Time : In order to avoid the user directly modify the system time, to achieve breakthrough license. Gets the date in the HTTP header of the large portal site to verify that the local time is accurate. In the middle, I found that the mainland blocked a lot of time synchronization of the site, only one or two can be used, and extremely unstable, and the Chinese Academy of Sciences is not used. PIT Cargo!!
SQLite dapper : Before the first version with plain text to store the configuration file, logging information. Extremely inconvenient, prone to the array out of bounds such a bug. Later the adoption of SQLite, only to discover the beautiful development. SQLite has a complete SQL that set of things, and small size, do not install, it is very suitable for local small amount of information storage.
Screen resolution : The first is to manually implement the Windows API to get the list, change the resolution, the bug is many and imperfect. One day a flash of light, on GitHub to find a bit real and this code, save a lot of things. In addition, I found that on the wiki, the display resolution list is only dozens of, the size of the visible resolution, not random writing. But the list you get through the Windows API is a whole bunch of hundreds of. I analyze it because of resolution, color depth, and hertz. These three parameter permutations result in a combination.
importance of Cefsharp documents : Clear Cache, clear cookie,storage. Set the popup, rewrite the HTTP header, execute JavaScript, and so on. A series of built-in browser operations, are looking at the wiki above GitHub, as well as Google to read English documents ( Baidu is the pit Daddy, the same article, round and round; General first page 80% ads, the top three pages are the same content, the remaining irrelevant ). No one else to help, only to bite the bullet to see a little bit, and then write code try. If you can't find the implementation method, go and see why it can't be implemented. Record something that I think is more important:
- ilifespanhandler Control cefsharp popup window events. (Doclose,onaftercreated,onbeforeclose,onbeforepopup)
- irequesthandler Control Cefsharp Send the requested event, too many not listed.
- cef.initialize can only be initialized once, If you want to clear the cache completely, you must close the host program. If within the main program, the call Cef.shutdown after the initialization will be an error. Version 49.0 has this problem, and the subsequent version fixes the problem.
-
- re-translated part of the Cefsharp document on GitHub.
WinForm Development : First write WinForm program, think is small program, all kinds of shoddy. Especially to the late, the main form code to reach one thousand or two thousand lines, logical call confusion, really can't see, the changes are very laborious. Simply re-write it. Redesign the document catalog, form splitting, code classification, left to engage in the right, finally barely able to see, but today the code turned out to see, always feel what is wrong, and can not say what is wrong ...
- Threads are so important that they are accustomed to the web and rarely consider threading issues. However, in a desktop application, threading is a very important issue, especially when the UI interface is not the main thread.
- The use of events, similarly, in the desktop program, the event is very comfortable. Prior to the agent, the event also only knows the concept. After practice, we know how good this design is.
- VS WYSIWYG Form Design interface, because the CEFSHARP runtime loading control, that is, the development of the design interface will not open. It's a little bit of a hassle.
- Operation through the handle. Mainly obtains the main interface handle, obtains the button handle, then SendMessage, to trigger the button event. There is, Win7 before and after the SendMessage very different, to pay attention to.
worker Process Start : The cache can be cleared completely because CEF must completely shut down the host process. As a result, the worker process was used to restart the main process. This is relatively simple, involving some of the process of operation, for ease of use, but also designed a hotkey function.
License Registration : This is relatively simple, refer to demo. I get the CPU serial number of the machine, the motherboard serial number, the ID of the hard disk (why not the serial number, because the hard disk market is uneven, there are no manufacturers there is no serial number). In order to avoid being guessed, I casually added some material (the real feeling at that time). Finally, the MD5 is encrypted and the hash value is extracted. Such as:
Summarize
- After such a toss, deeply feel that the main role of the programmer is to assemble the code: The irrelevant code is assembled organically together to form a software that can be used.
- Good use of google,github,stack overflow, basic can solve 99% of technical problems.
- English is very very important, Baidu is very very pit.
- When it's really toutengnaore, it's better to take a rest when it's uncomfortable.
- The need for confirmation, which is very important thing.
Remember "Analog click", WinForm small software development process