用goagent+ie翻"墙的时候,需要点击多次鼠标,现在做个小工具简化操作步骤.
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Text; 7 using System.Windows.Forms; 8 using Microsoft.Win32; 9 using System.Diagnostics; 10 11 namespace IE 12 { 13 public partial class Form1 : Form 14 { 15 public Form1() 16 { 17 InitializeComponent(); 18 } 19 20 private void mycheck()//通过读取注册表内"ProxyEnable"的值,确定程序启动时button1.text的值. 21 { 22 RegistryKey mykey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); 23 string myget = mykey.GetValue("ProxyEnable").ToString(); 24 if (myget == "0")//确定当前状态是启用还是禁用. 25 { 26 button1.Text = "已关闭"; 27 } 28 else 29 { 30 button1.Text = "已打开"; 31 } 32 } 33 34 private void button1_Click(object sender, EventArgs e) 35 { 36 RegistryKey mykey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); 37 38 if (button1.Text == "已打开")// 关闭 39 { 40 mykey.SetValue("ProxyEnable", 0x0); 41 mykey.SetValue("ProxyServer", ""); 42 button1.Text = "已关闭";//关闭goagent按钮不可用,防止程序出错. 43 } 44 else//打开 45 { 46 mykey.SetValue("ProxyEnable", 0x1); 47 mykey.SetValue("ProxyServer", "127.0.0.1:8087"); 48 button1.Text = "已打开"; 49 } 50 } 51 52 private void Form1_Load(object sender, EventArgs e) 53 { 54 mycheck(); 55 button3.Enabled = false; 56 } 57 58 private void button2_Click(object sender, EventArgs e)//打开goagent 59 { 60 Process.Start("D:\\Program Files\\goagent-goagent-f0fabf7\\local\\goagent.exe"); 61 button2.Enabled = false; 62 button3.Enabled = true; 63 } 64 65 private void button3_Click(object sender, EventArgs e)//关闭goagent 66 { 67 Process.GetProcessesByName("goagent")[0].Kill(); 68 Process.GetProcessesByName("python27")[0].Kill(); 69 button2.Enabled = true; 70 button3.Enabled = false; 71 } 72 } 73 }