⬆️ ⬇️

Save Yota Internet Costs

Prologue



A couple of months ago, in my city, my wireless carrier, Yota, launched its LTE network. After some hesitation, I decided it was worth a try - in the hope that things are better with LTE Yota than with 3G from the Big Three operators. And I must say that I have not yet given up on my decision.



And it's not just that the speed is higher, and the coverage of the city is just as good. Using the internet from Yota I spend less money than before. After all, there is such a wonderful speed regulator in your personal account, which can be set to a minimum, and increase speed only when it is really necessary.



Yes, doing it through the browser is not very convenient. So we got to the point of the post.

')

Automation



So, it was decided to write a client to control the speed of the modem. C # was used as a programming language. I repent, I went the easiest way - I used the WebBrowser component. The first version was on Windows Forms, but I recently rewrote the project on WPF. The program itself and the project in Visual Studio - at the end of the post. And now I would like to focus on some aspects.



The first thing I encountered was to use the old version of Internet Explorer to display the pages in WebBrowser, and in order to use, for example, version 8, you need to add the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION to the registry HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION key with the name corresponding to the name of the program containing the DWORD value of 8000. I have allocated for this a small class:



 using Microsoft.Win32; using System; class BrowserEmulation { private BrowserEmulation() { } /// <summary> ///     /// </summary> /// <param name="appName">  </param> public static void Enable(string appName = null) { if (appName == null) appName = AppDomain.CurrentDomain.FriendlyName; RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true); if (regKey != null) { try { regKey.GetValue(appName).ToString(); } catch { regKey.SetValue(appName, 8000, RegistryValueKind.DWord); } } } /// <summary> ///     /// </summary> /// <param name="appName">  </param> public static void Disable(string appName = null) { if (appName == null) appName = AppDomain.CurrentDomain.FriendlyName; RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true); if (regKey != null) { try { regKey.DeleteValue(appName); } catch { } } } } 


How to add a program to autoload is written on almost any fence, so it makes no sense to describe it.



Regarding restarting a WPF application, for this I have a very tiny class:



 using System.Windows.Forms; class Restart { private Restart() { } public static void Go() { Application.Restart(); System.Windows.Application.Current.Shutdown(); } } 


We have to admit that, in general, there is nothing interesting in the program code.



Result



Login window:





Loading:





Speed ​​control:





Settings window:





You can download: Always up-to-date version of the program or Project Visual Studio 2012

Source: https://habr.com/ru/post/166285/



All Articles