Record the [simulate click], WinForm small software development process,

Source: Internet
Author: User

Record the [simulate click], WinForm small software development process,
Preface

A friend found me early in May April and said he wanted to develop a simulated click Software. After the software is completed, it is found that the effect is not satisfactory. I think it is best to give up and operate the only developer. I insist that this is okay and that it is a change in the way of cooperation. Eventually, it is gone.

However, during this process, we experienced a rewrite, three core method changes, countless data queries, and found a solution until early morning. The discussion was interspersed with numerous discussions and modifications. Although the function is simple, it took three months. I thought, I 'd like to make a summary. The software interface is as follows:

 

How to implement and use controls

First, open the webpage in the built-in browser, and use Javascript to obtain the coordinates of the desired clicks; Calculate the coordinates of the webpage, And the coordinates on the screen; simulate the mouse operation (scroll pulley, move, click), and random secondary clicks. Finally, clear the cache, change the IP address, change the resolution, and change the User-Agent. In order to deceive the website, think it is different people to click.

The specific method is as follows:

Small record

Anti-Virus Software pitfalls: When simulated input is used, the User Interface Privilege Isolation (User Interface Privilege Isolation) is always prompted, and the permissions are insufficient. I tried to shut down Windows UAC, started it with a super administrator, added a digital certificate to the software, and put it in the C drive system directory. If you try all the methods, you cannot simulate the operation. There is no way to do it. Then, release the task on the pigs and put the Demo on it. Unexpectedly, a college student solved the problem for me because of anti-virus software such as 360 ....

IP genie DLL version pitfalls: The dll provided by their official website was initially used and found that their dll was basically unavailable, as if it had not been updated for a long time. In addition, the status code will also change at will, and no update notification will be sent. The result is that we can't use it today.

ADSL test pitfalls: The Code cannot be tested after it is written, or it is difficult to test. Now, there are fewer and fewer dial-up Internet access using ADSL in this age, and it is also troublesome to test. It was hard to find a remote ADSL host. As a result, the network was disconnected after the test...

Get Network Time: To prevent users from directly modifying the system time to break through the License. Obtain the date in the http header of a large portal website to check whether the local time is accurate. In the middle, I found that the Chinese mainland blocked a lot of time synchronization websites. Only one or two websites were usable, extremely unstable, and the Chinese Emy of sciences could not afford them. Poor goods !!

SQLite is small and exquisite: The first version used plain text to store configuration files and record log information. It is extremely inconvenient and prone to a bug such as array out-of-bounds. Later, sqlite was used to discover the beauty of development. Sqlite has a complete set of SQL, which is small in size and does not need to be installed. It is very suitable for storing a small amount of local information.

Screen Resolution: At the beginning, you can manually implement the windows api to obtain the list and change the resolution. There are many bugs that are not perfect. A few days later, I found this code on github, saving a lot of trouble. In addition, I also found that there are only dozens of resolution lists displayed on the wiki, and the size of the resolution is visible, which is not random. However, there are hundreds of lists obtained through the windows api. I analyzed it because of resolution, color depth, Hz. These three parameters are arranged and combined.

Cefsharp document importance: Clear cache, clear cookie, and store. Set the pop-up mode, rewrite the http header, and execute javascript. For a series of built-in browser operations, refer to the wiki on github and the English documentation on google (Baidu is a fool, the same article, turn around; generally, the first page of 80% ads, the first three pages are the same content, the rest of the wind and horse). Without the help of others, you only need to translate a little bit and try to write code. If you cannot find the implementation method, you can also see why it cannot be implemented. Record some important points I think:

  • ILifeSpanHandler controls the window events popped up by Cefsharp. (DoClose, OnAfterCreated, OnBeforeClose, OnBeforePopup)
  • IRequestHandler controls the events in which Cefsharp sends requests. Too many events are not listed one by one.
  • Cef. Initialize can only be initialized once. To completely clear the cache, you must close the Host Program. If Cef. Shutdown is called in the main program and then initialized again, an error is returned. This problem exists in version 49.0 and is fixed in later versions.
  • When executing js, pay attention to the lock issue and use Monitor for more precise control.
  • I have re-translated some Cefsharp documents on github.

WinForm Development: The first time I wrote a winform program, I thought it was a small program and it was a variety of shoddy programs. Especially in the later stages, when the code of the main form reached 1000 or 2000 lines, the logic call was messy, and it was hard to modify the code. Try again. Re-design the document directory, form splitting, code classification, left and right, and finally barely saw it. But today I turned out the code and looked at it again. I always felt something wrong, I can't tell where it is wrong...

  • The importance of the thread, used to write web, rarely consider the thread issue. However, in a desktop program, threads are very important, especially when a non-main thread operates the UI.
  • The use of events is also very comfortable in the desktop program. Previously, we only knew the concept of proxy and event. After practice, we can see how good the design is.
  • Vs wysiwyg is the form design interface, because the Cefsharp runtime loads the control, that is, the development design interface cannot be opened. This is also a little troublesome.
  • Handle operations. Obtain the main interface handle, obtain the button handle, and then SendMessage to trigger the button event. In addition, before and after Windows 7, SendMessage is quite different.

Auxiliary process startup: Because Cef must completely shut down the host process to completely clear the cache. Therefore, it was then used to restart the main process. This is relatively simple and involves some Process operations. For ease of use, a hotkey function is also designed.

License registration: This is relatively simple. Refer to the demo. I got the CPU serial number of the local machine, the motherboard serial number, and the hard disk ID (why not the serial number, because the hard disk market is uneven, there are manufacturers that do not have the serial number ). To prevent being guessed, I randomly added some materials (real feelings at the time ). Finally, MD5 encryption is used to extract the hash value. For example:

 

Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.