/// <summary> /// 开始监控火狐浏览器 /// </summary> public List<WebSiteModel> MnitorFireFox() { try { string sUrl = string.Empty; DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo"); dde.Connect(); // 取得 URL 資訊 string sUrlInfo = dde.Request("URL", int.MaxValue); // DDE Client 進行連結 dde.Disconnect(); List<WebSiteModel> urls = new List<WebSiteModel>(); // 取得的 sUrlInfo 內容為 "網址","標題","" // 取出網址部分 if (sUrlInfo.Length > 0) { //sUrlInfo.Split(',').ToList<>(); sUrl = sUrlInfo.Split(',')[0].Trim(new char[] { '"' }); } return urls; } catch { return null; } }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("Opera", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("URL", 1000); dde.Disconnect(); // Result string is in the format "url", "Opera - [title]", ... var parts = result.Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = Regex.Match(parts[1], @"Opera - \[(.*?)\]").Groups[1].Value.Replace("\\\"", "\""); return PluginResult.FromUrl(url, name); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("IExplore", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("0xFFFFFFFF,sURL,sTitle", 1000); dde.Disconnect(); // Result string is in the format "uri", "title"\0 var parts = result.Trim('\0').Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = parts[1].Replace("\\\"", "\""); return PluginResult.FromUrl(url, name); }
// // usage: GetBrowserURL("opera") or GetBrowserURL("firefox") // public static string GetBrowserURL(string browser) { try { DdeClient dde = new DdeClient(browser, "WWW_GetWindowInfo"); dde.Connect(); string url = dde.Request("URL", int.MaxValue); string[] text = url.Split(new string[] { "\",\"" }, StringSplitOptions.RemoveEmptyEntries); dde.Disconnect(); return text[0].Substring(1); } catch { return null; } }
public static string GetUrl(string browser) { try { DdeClient dde = new DdeClient(browser, "WWW_GetWindowInfo"); // Using DDE-lib to connect and get information from the firefox browser dde.Connect(); string url = dde.Request("URL", int.MaxValue); string[] text = url.Split(new string[] { "\",\"" }, StringSplitOptions.RemoveEmptyEntries); dde.Disconnect(); return text[0].Substring(1); } catch { MessageBox.Show("Is your firefox open?", "Error"); // If firefox isnt open return null; } }
public void Test_IsConnected_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Disconnect(); Assert.IsFalse(client.IsConnected); } } }
public void Test_Handle_Variation_3() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Connect(); client.Disconnect(); Assert.AreEqual(IntPtr.Zero, client.Handle); } } }
public void Test_Disconnect_Before_Connect() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { client.Disconnect(); } } }
public void Test_Disconnected_Variation_1() { using (TestServer server = new TestServer(ServiceName)) { server.Register(); using (DdeClient client = new DdeClient(ServiceName, TopicName)) { EventListener listener = new EventListener(); client.Disconnected += listener.OnEvent; client.Connect(); client.Disconnect(); Assert.IsTrue(listener.Received.WaitOne(Timeout, false)); DdeDisconnectedEventArgs args = (DdeDisconnectedEventArgs)listener.Events[0]; Assert.IsFalse(args.IsServerInitiated); Assert.IsFalse(args.IsDisposed); } } }
private void button3_Click(object sender, EventArgs e) { client.Disconnect(); }
public static string GetFirefoxUrl() { var dde = new DdeClient("Firefox", "WWW_GetWindowInfo"); dde.Connect(); string url = dde.Request("URL", int.MaxValue); dde.Disconnect(); return url; }