예제 #1
2
        /// <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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 //
 // 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;
     }
 }
예제 #5
0
 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;
     }
 }
예제 #6
0
 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);
         }
     }
 }
예제 #7
0
 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);
         }
     }
 }
예제 #8
0
 public void Test_Disconnect_Before_Connect()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Disconnect();
         }
     }
 }
예제 #9
0
 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);
         }
     }
 }
예제 #10
0
 private void button3_Click(object sender, EventArgs e)
 {
     client.Disconnect();
 }
예제 #11
0
 public static string GetFirefoxUrl()
 {
     var dde = new DdeClient("Firefox", "WWW_GetWindowInfo");
     dde.Connect();
     string url = dde.Request("URL", int.MaxValue);
     dde.Disconnect();
     return url;
 }