C # Use webbrowser to create key technical analysis of web game Auxiliary Tools

Source: Internet
Author: User
Using the webbrowser control is really convenient to implement, but it is less flexible than sending packets in a direct group. For a web game of the Three Kingdoms, webbrowser can theoretically achieve the desired function if it is used well (I only achieve automatic "referral" on the whole point, and others will not be interested in it, ). You can use the packet capture tool to check which packages are available during the game. Some web games are flash interfaces, such as happy farm in the school. webbrowser is not suitable for auxiliary tools for this game .. Net also has the flash control, but this control function is very weak, a lot of Flash is not available. Now, only the original group package is used for sending packets. Webbrowser has a disadvantage that it can only exist in the main thread. In the process of processing data in webbrowser, the entire Program In the busy state, click the program will not respond (not responding ). When running the program, try to reduce the time required for webbrowser to process data. In addition to updating data in webbrowser, all other operations are implemented in other threads. Webbrowser. navigate (strurl); you can obtain the string content through webbrowser: webbrowser. document. body. innerhtml; "game guide" is actually a link: <a class = topbutton-guide Title = game guide href = \ "javascript: mm_iframepost ('Guide. nation '); \ "> game guide </a> Code Execute the "javascript: mm_iframepost ('Guide. nation');" script, which is equivalent to clicking the "game guide" in the game ". Execute the script using htmlelement. invokemember .... Htmlelementcollection ahtml = webbrowser. document. getelementsbytagname ("A"); doclick ("game guide"); Private void doclick (string name) {foreach (htmlelement h in ahtml) {If (H. innertext! = NULL & H. innertext. contains (name) {H. invokemember ("click"); // wait until the webbrowser refresh completes waitforeventcompleted (1000); break;} else {continue ;}} private void waitforeventcompleted (INT time) {autoresetevent. reset (); While (autoresetevent. waitone (time, false) = false) {application. doevents () ;}} after clicking the corresponding link, the webbrowser must refresh the data accordingly. Therefore, wait until the webbrowser updates the data. Each time the data is updated, the webbrowser_documentcompleted event is not executed once. It seems to be three times, but the cause is found and forgotten. The code is not stable yet. You can capture packets to find out the cause. Regularly run the "" command, and use docallback, invoke: Private void timerdofamous () {While (true) {If (datetime. now. second = 10 & datetime. now. minute = 2) {If (webbrowser. invokerequired) {docallback d = new docallback (dofamousgeneral); this. invoke (d); D = new docallback (wait); this. invoke (d); D = new docallback (doanothergeneral); this. invoke (d);} else {docallback d = new docallback (dofamousgeneral); thi S. invoke (d); D = new docallback (wait); this. invoke (d); D = new docallback (doanothergeneral); this. how to Get invoke (d) ;}}} from webbrowser. document. body. in innerhtml, you can obtain the desired HTML element using a regular expression. The regular expression can also be used to obtain all the data of the current town, such as the number of resources and the building level. Obtain the regular expression of the number of iron ore: // ironpublic const string ironnowpat = @ "<span id = iron_now> \ D * </span> "; public const string ironnowheader = @ "<span id = iron_now>"; Public const string ironincreasepat = @ "id = iron_increase> \ D * </span> "; public const string ironincreaseheader = @ "id = iron_increase>"; the account I tested has an escrow account. The result of running the program is to click "button1" and then immediately execute "submitter". After your account is completed, it is automatically transferred to the managed account as the "submitter" of the managed account ". Two accounts used for my test, one of which is the managed account. Therefore, the current program only supports one managed account, and the same principle is changed to two. Click "button2". When the computer time is 10 seconds, execute "submitter" (timed unlimited ). When you go to the managed account, a dialog box containing "OK" is displayed. You must click "OK" to go to the managed account page. The "OK" button is an HTML element containing the "input" tag, which is the same as the "game guide" is an HTML element containing the "A" tag. The key points mentioned above seem to be able to complete most of the functions in the Three Kingdoms game, as long as you can think of anything. Compared with group packages, it is much easier to send packets, but the efficiency is much lower.

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.