Exemplo n.º 1
0
 public void StopQuotes()
 {
     if (client.IsConnected == true)
     {
         client.Disconnect();
         client.Dispose();
     }
 }
Exemplo n.º 2
0
 ///<summary>Sends data for pat to the Dexis Integrator program using a DDE Execute command.  Shows a message box if pat is null instructing user
 ///to first select a pat.  Sends SET command with the following format: SET 17 LN="LName" FN="FName" MI="MiddleI" BD=19760205.  The first
 ///parameter of the command is the patient ID defined by the program property as either PatNum or ChartNumber.  The BD portion will only be added
 ///if the pat has a valid bday and adding it to the commmand won't increase the length of the command to >255 characters.</summary>
 public static void SendData(Program progCur, Patient pat)
 {
     if (pat == null)
     {
         MsgBox.Show("DexisIntegrator", "Please select a patient first.");
         return;
     }
     try {
         if (_client == null || _client.Context == null)
         {
             DdeContext context = new DdeContext(Application.OpenForms.OfType <FormOpenDental>().FirstOrDefault() ?? Application.OpenForms[0]);
             _client = new DdeClient("Dexis", "Patient", context);
         }
         if (!_client.IsConnected)
         {
             _client.Connect();
         }
         string patId = pat.PatNum.ToString();
         if (ProgramProperties.GetPropVal(progCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "1")
         {
             patId = pat.ChartNumber;
         }
         string ddeCommand = "SET " + patId + " LN=\"" + pat.LName + "\" FN=\"" + pat.FName + "\" MI=\"" + pat.MiddleI + "\"";
         if (pat.Birthdate.Year > 1880 && ddeCommand.Length < 244)             //add optional bday only if valid and it won't increase the length to >255 characters
         {
             ddeCommand += " BD=" + pat.Birthdate.ToString("yyyyMMdd");
         }
         _client.Execute(ddeCommand, 30000);               //timeout 30 seconds
         //if execute was successfully sent, subscribe the PatientChangedEvent_Fired handler to the PatientChangedEvent.Fired event
         PatientChangedEvent.Fired -= PatientChangedEvent_Fired;
         PatientChangedEvent.Fired += PatientChangedEvent_Fired;
         UserodChangedEvent.Fired  -= UserodChangedEvent_Fired;
         UserodChangedEvent.Fired  += UserodChangedEvent_Fired;
     }
     catch (ObjectDisposedException ode) {
         if (_isRetry)
         {
             FriendlyException.Show(Lans.g("DexisIntegrator", "There was an error trying to launch Dexis with the selected patient."), ode);
             return;
         }
         _isRetry = true;
         if (_client != null && _client.IsConnected)
         {
             ODException.SwallowAnyException(new Action(() => _client.Disconnect()));                    //disconnect if necessary
         }
         ODException.SwallowAnyException(new Action(() => _client.Dispose()));
         _client = null;              //will cause a new _client to be made with a new context
         SendData(progCur, pat);
     }
     catch (Exception ex) {
         FriendlyException.Show(Lans.g("DexisIntegrator", "There was an error trying to launch Dexis with the selected patient."), ex);
         return;
     }
     finally {
         _isRetry = false;
     }
 }
Exemplo n.º 3
0
 public void Test_Disconnect_Before_Connect()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     Assert.Throws<InvalidOperationException>(() => client.Disconnect());
 }
Exemplo n.º 4
0
 public void Disconnect()
 {
     if (client.IsConnected)
     {
         client.Disconnect();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 开始监控火狐浏览器
        /// </summary>
        public List <WebSiteModel> MnitorFireFox()
        {
            try
            {
                string    sUrl   = string.Empty;
                string    sTitle = 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[] { '"' });
                    sTitle = sUrlInfo.Split(',')[1].ToString();
                    urls.Add(new WebSiteModel()
                    {
                        url = sUrl, title = sTitle
                    });
                }
                return(urls);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 public void Test_Disconnect()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     client.Connect();
     client.Disconnect();
 }
Exemplo n.º 7
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     client.Disconnect();
     btnStart.Enabled = true;
     btnStop.Enabled  = false;
     timer1.Enabled   = false;
     _connection.Close();
 }
Exemplo n.º 8
0
 public void Test_Handle_Variation_3()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     client.Connect();
     client.Disconnect();
     Assert.AreEqual(IntPtr.Zero, client.Handle);
 }
Exemplo n.º 9
0
 public void Test_Disconnect_After_Dispose()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     client.Connect();
     client.Dispose();
     Assert.Throws<ObjectDisposedException>(() => client.Disconnect());
 }
Exemplo n.º 10
0
 public void Test_IsConnected_Variation_3()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     client.Connect();
     client.Disconnect();
     Assert.IsFalse(client.IsConnected);
 }
Exemplo n.º 11
0
    public static string GetFirefoxURL()
    {
        DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo");

        dde.Connect();
        string url = dde.Request("URL", int.MaxValue);

        dde.Disconnect();
        return(url);
    }
Exemplo n.º 12
0
 public void Test_Disconnect_Before_Connect()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Disconnect();
         }
     }
 }
Exemplo n.º 13
0
        public void Stop()
        {
            if (ddeClient != null && ddeClient.IsConnected)
            {
                ddeClient.Disconnect();
            }

            if (Stopped != null)
            {
                Stopped(this, EventArgs.Empty);
            }

            status = DataProviderStatus.Stopped;
        }
Exemplo n.º 14
0
 override public void disconnect()
 {
     if (connected)
     {
         try
         {
             ps.Disconnect();
         }
         catch (Exception ex)
         {
         }
     }
     connected = false;
 }
Exemplo n.º 15
0
 public void Test_Disconnected_Variation_1()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     var listener = new EventListener();
     client.Disconnected += listener.OnEvent;
     client.Connect();
     client.Disconnect();
     Assert.IsTrue(listener.Received.WaitOne(Timeout, false));
     var args = (DdeDisconnectedEventArgs) listener.Events[0];
     Assert.IsFalse(args.IsServerInitiated);
     Assert.IsFalse(args.IsDisposed);
 }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
0
 private 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);
     }
 }
Exemplo n.º 18
0
        public PluginResult OnTriggered(PluginTriggerEventArgs e)
        {
            DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo");

            dde.Connect();
            string result = dde.Request("URL", 1000);

            dde.Disconnect();

            // Result string is in the format "uri", "title", ...
            var    parts = result.Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None);
            string url   = parts[0].Replace("\\\"", "\"");
            string name  = parts[1].Replace("\\\"", "\"");

            return(PluginResult.FromUrl(url, name));
        }
Exemplo n.º 19
0
        private static string GetURL(IntPtr intPtr, string programName, out string url)
        {
            string temp = null;

            if (programName.Equals("firefox"))
            {
                DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo");
                dde.Connect();
                string url1 = dde.Request("URL", int.MaxValue);
                dde.Disconnect();
                temp = url1;
            }

            url = temp;
            return(temp);
        }
Exemplo n.º 20
0
        public void getURLfirefox()
        {
            try
            {
                DdeClient dde = new DdeClient("firefox", "WWW_GetWindowInfo");
                dde.Connect();
                string   url  = dde.Request("URL", int.MaxValue);
                string[] urls = url.Split(new string[] { ",", "\"" }, StringSplitOptions.RemoveEmptyEntries);
                dde.Disconnect();

                listaStron.Add("[firefox]");
                listaStron.Add("URL: " + urls[0]);
                listaStron.Add("Title: " + urls[1]);
            }
            catch
            {
            }
        }
Exemplo n.º 21
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                if (_dc != null)
                {
                    _dc.Disconnect();
                    _dc = null;
                }
            }

            disposed = true;
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
            FileStream fs = File.Create(DateTime.Now.ToString("HH_mm_ss") + ".csv");

            writer = new StreamWriter(fs);
            writer.WriteLine("\"TIME\";\"T1\";\"T2\"");
            TimerCallback timerCallback = new TimerCallback(onTick);
            Timer         timer         = new Timer(timerCallback, null, 0, 2000);

            using (DdeClient client = new DdeClient("CoDeSys", @"D:\Project\discreteOut.pro"))
                try
                {
                    client.Disconnected += Client_Disconnected;
                    client.Connect();
                    //var s = client.Request("myitem1", 60000);
                    client.Advise += OnAdvise;
                    client.StartAdvise("T1", 1, true, 600);
                    client.StartAdvise("T2", 1, true, 600);
                    Console.ReadLine();
                }
                catch (NDde.DdeException e)
                {
                    Console.WriteLine(e.Message);
                }
            finally
            {
                timer.Dispose();
                if (client.IsConnected == true)
                {
                    client.Disconnect();
                }
                writer.Close();
                fs.Close();
            }

            /*}
             * catch(Exception e)
             * {
             *  Console.WriteLine(e.Message);
             * }*/
        }
Exemplo n.º 23
0
        /// <summary>
        /// DDE Server 접속 해제
        /// </summary>
        /// <returns>함수 실행 결과 (FuncResult 객체)</returns>
        public CommonStruct.FuncResult DisConnect()
        {
            CommonStruct.FuncResult result = new CommonStruct.FuncResult();

            stopWatch.Start();

            try
            {
                if (ddeHandle != null)
                {
                    if (ddeHandle.IsConnected)
                    {
                        ddeHandle.Disconnect();

                        result.isSuccess = true;
                    }
                    else
                    {
                        result.isSuccess = true;
                    }
                }
                else
                {
                    result.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                result.isSuccess     = false;
                result.funcException = ex;
            }

            stopWatch.Stop();

            result.totalMilliseconds = stopWatch.ElapsedMilliseconds;

            stopWatch.Reset();

            return(result);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Возвращет название активной вкладки браузера
        /// </summary>
        /// <param name="browser">название браузера</param>
        /// <param name="ptr"></param>
        /// <returns>Название вкладки</returns>
        public static string GetBrowserURL(string browser, IntPtr ptr = new IntPtr())
        {
            if (browser == "firefox")
            {
                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);
                }
            }
            else if (browser == "chrome")
            {
                {
                    string ret = "";

                    AutomationElement elm       = AutomationElement.FromHandle(ptr);
                    AutomationElement elmUrlBar = null;
                    try
                    {
                        var elm1 = elm.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Google Chrome"));
                        if (elm1 == null)
                        {
                            return(null);
                        }
                        var elm2 = TreeWalker.RawViewWalker.GetLastChild(elm1);   // I don't know a Condition for this for finding
                        var elm3 = elm2.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, ""));
                        var elm4 = TreeWalker.RawViewWalker.GetNextSibling(elm3); // I don't know a Condition for this for finding
                        var elm5 = elm4.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ToolBar));
                        var elm6 = elm5.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, ""));
                        elmUrlBar = elm6.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
                    }
                    catch
                    {
                        return(null);
                    }
                    AutomationPattern[] patterns = elmUrlBar.GetSupportedPatterns();
                    if (patterns.Length == 1)
                    {
                        try
                        {
                            ret = ((ValuePattern)elmUrlBar.GetCurrentPattern(patterns[0])).Current.Value;
                            //return ret;
                        }
                        catch { }
                        if (ret != "")
                        {
                            if (Regex.IsMatch(ret, @"^(https:\/\/)?[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}).*$"))
                            {
                                if (!ret.StartsWith("http"))
                                {
                                    ret = "http://" + ret;
                                }
                                return(ret);
                            }
                        }
                    }
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 25
0
        ///<summary>Launches the program if necessary.  Then passes patient.Cur data using DDE.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            ArrayList ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;

            if (pat == null)
            {
                MessageBox.Show("Please select a patient first");
                return;
            }
            if (!File.Exists(ProgramCur.Path))
            {
                MessageBox.Show("Could not find " + ProgramCur.Path);
                return;
            }
            //Make sure the program is running
            //Documentation says to include the -nostartup command line switch (to avoid optional program preference startup command).
            if (Process.GetProcessesByName("Vipersoft").Length == 0)
            {
                Process.Start(ProgramCur.Path, "-nostartup");
                Thread.Sleep(TimeSpan.FromSeconds(4));
            }
            //Data is sent to the Vipersoft DDE Server by use of the XTYP_EXECUTE DDE message only.
            //The format ot the XTYP_EXECUTE DDE message is"
            //command="\004hwnd|name|ID|Lastname|Firstname|MI|Comments|Provider|Provider Phone|Addrs1|Addrs2|City|State|Zip|Patient Phone|Practice Name|Patient SSN|restore server|"
            //\004 is one byte code for version 4. 0x04 or Char(4)
            //hwnd is calling software's windows handle.
            //name is for name of calling software (Open Dental)
            //ID is patient ID.  Required and must be unique.
            //Provider field is for provider name.
            //hwnd, ID, Lastname, Firstname, and Provider fields are required.  All other fields are optional.
            //All vertical bars (|) are required, including the ending bar.
            //The restore server flag is for a future release's support of the specialized capture/view commands (default is '1')
            //Visual Basic pseudo code:
            //Chan = DDEInitiate("Vipersoft", "Advanced IntraOral")
            //DDE_String$ = "" //etc
            //DDEExecute Chan, DDE_String$ //send XTYP_EXECUTE DDE command:
            //DDETerminate Chan
            Char   char4   = Convert.ToChar(4);
            string command = char4.ToString();          //tested to make sure this is just one non-printable byte.
            IntPtr hwnd    = Application.OpenForms[0].Handle;

            command += hwnd.ToString() + "|"   //hwnd
                       + "OpenDental|";        //name
            ProgramProperty PPCur = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
            string          patID;

            if (PPCur.PropertyValue == "0")
            {
                patID = pat.PatNum.ToString();
            }
            else
            {
                if (pat.ChartNumber == "")
                {
                    MessageBox.Show("ChartNumber for this patient is blank.");
                    return;
                }
                patID = pat.ChartNumber;
            }
            command += patID + "|";                            //ID
            command += pat.LName + "|";                        //Lastname
            command += pat.FName + "|";                        //Firstname
            command += pat.MiddleI + "|";                      //
            command += "|";                                    //Comments: blank
            command += Providers.GetNameLF(pat.PriProv) + "|"; //Provider
            command += "|";                                    //Provider phone
            command += "|";                                    //Addr
            command += "|";                                    //Addr2
            command += "|";                                    //City
            command += "|";                                    //State
            command += "|";                                    //Zip
            command += "|";                                    //Phone
            command += "|";                                    //Practice
            command += pat.SSN + "|";                          //SSN
            command += "1|";                                   //Restore Server
            //MessageBox.Show(command);
            try {
                //Create a context that uses a dedicated thread for DDE message pumping.
                using (DdeContext context = new DdeContext()){
                    //Create a client.
                    using (DdeClient client = new DdeClient("Vipersoft", "Advanced IntraOral", context)){
                        //Establish the conversation.
                        client.Connect();
                        //Select patient
                        client.Execute(command, 2000);                       //timeout 2 secs
                        client.Disconnect();
                    }
                }
            }
            catch {
                //MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 26
0
 ///<summary>Launches the program if necessary.  Then passes patient.Cur data using DDE.</summary>
 public static void SendData(Program ProgramCur, Patient pat)
 {
     ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;
     if(pat==null){
         MessageBox.Show("Please select a patient first");
         return;
     }
     if(!File.Exists(ProgramCur.Path)){
         MessageBox.Show("Could not find "+ProgramCur.Path);
         return;
     }
     //Make sure the program is running
     //Documentation says to include the -nostartup command line switch (to avoid optional program preference startup command).
     if(Process.GetProcessesByName("Vipersoft").Length==0){
         Process.Start(ProgramCur.Path,"-nostartup");
         Thread.Sleep(TimeSpan.FromSeconds(4));
     }
     //Data is sent to the Vipersoft DDE Server by use of the XTYP_EXECUTE DDE message only.
     //The format ot the XTYP_EXECUTE DDE message is"
     //command="\004hwnd|name|ID|Lastname|Firstname|MI|Comments|Provider|Provider Phone|Addrs1|Addrs2|City|State|Zip|Patient Phone|Practice Name|Patient SSN|restore server|"
     //\004 is one byte code for version 4. 0x04 or Char(4)
     //hwnd is calling software's windows handle.
     //name is for name of calling software (Open Dental)
     //ID is patient ID.  Required and must be unique.
     //Provider field is for provider name.
     //hwnd, ID, Lastname, Firstname, and Provider fields are required.  All other fields are optional.
     //All vertical bars (|) are required, including the ending bar.
     //The restore server flag is for a future release's support of the specialized capture/view commands (default is '1')
     //Visual Basic pseudo code:
     //Chan = DDEInitiate("Vipersoft", "Advanced IntraOral")
     //DDE_String$ = "" //etc
     //DDEExecute Chan, DDE_String$ //send XTYP_EXECUTE DDE command:
     //DDETerminate Chan
     Char char4=Convert.ToChar(4);
     string command=char4.ToString();//tested to make sure this is just one non-printable byte.
     IntPtr hwnd=Application.OpenForms[0].Handle;
     command+=hwnd.ToString()+"|"//hwnd
         +"OpenDental|";//name
     ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
     string patID;
     if(PPCur.PropertyValue=="0"){
         patID=pat.PatNum.ToString();
     }
     else{
         if(pat.ChartNumber==""){
             MessageBox.Show("ChartNumber for this patient is blank.");
             return;
         }
         patID=pat.ChartNumber;
     }
     command+=patID+"|";//ID
     command+=pat.LName+"|";//Lastname
     command+=pat.FName+"|";//Firstname
     command+=pat.MiddleI+"|";//
     command+="|";//Comments: blank
     Provider prov=Providers.GetProv(Patients.GetProvNum(pat));
     command+=prov.LName+", "+prov.FName+"|";//Provider
     command+="|";//Provider phone
     command+="|";//Addr
     command+="|";//Addr2
     command+="|";//City
     command+="|";//State
     command+="|";//Zip
     command+="|";//Phone
     command+="|";//Practice
     command+=pat.SSN+"|";//SSN
     command+="1|";//Restore Server
     //MessageBox.Show(command);
     try {
         //Create a context that uses a dedicated thread for DDE message pumping.
         using(DdeContext context=new DdeContext()){
             //Create a client.
             using(DdeClient client=new DdeClient("Vipersoft","Advanced IntraOral",context)){
                 //Establish the conversation.
                 client.Connect();
                 //Select patient
                 client.Execute(command,2000);//timeout 2 secs
                 client.Disconnect();
             }
         }
     }
     catch{
         //MessageBox.Show(e.Message);
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Get URL's from Browsers
        /// </summary>

        #region URL's from Chrome

        public static string GetURL(string Browser)
        {
            string ret = "";

            Process[] procs = Process.GetProcessesByName(Browser);

            foreach (Process proc in procs)
            {
                if (proc.MainWindowHandle == IntPtr.Zero)
                {
                    continue;
                }

                AutomationElement elmChrome       = AutomationElement.FromHandle(proc.MainWindowHandle);
                AutomationElement elmUrlBarChrome = null;

                // Google Chrome

                if (Browser == Settings.GoogleChrome_Browser)
                {
                    try
                    {
                        var elm1 = elmChrome.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Google Chrome"));
                        if (elm1 == null)
                        {
                            continue;
                        }
                        var elm2 = TreeWalker.RawViewWalker.GetLastChild(elm1);
                        var elm3 = elm2.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, ""));
                        var elm4 = TreeWalker.RawViewWalker.GetNextSibling(elm3);
                        var elm5 = elm4.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ToolBar));
                        var elm6 = elm5.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, ""));
                        elmUrlBarChrome = elm6.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
                    }
                    catch { continue; }

                    if (elmUrlBarChrome == null)
                    {
                        continue;
                    }
                    if ((bool)elmUrlBarChrome.GetCurrentPropertyValue(AutomationElement.HasKeyboardFocusProperty))
                    {
                        continue;
                    }

                    AutomationPattern[] patterns = elmUrlBarChrome.GetSupportedPatterns();

                    if (patterns.Length == 1)
                    {
                        try
                        {
                            ret = ((ValuePattern)elmUrlBarChrome.GetCurrentPattern(patterns[0])).Current.Value;
                            return(ret);
                        }
                        catch { }

                        if (ret != "")
                        {
                            if (Regex.IsMatch(ret, @"^(https:\/\/)?[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}).*$"))
                            {
                                if (!ret.StartsWith("http"))
                                {
                                    ret = "http://" + ret;
                                }
                                return(ret);
                            }
                        }
                        continue;
                    }
                    return(ret);
                }

                // Mozilla Firefox

                if (Browser == Settings.MozillaFirefox_Browser)
                {
                    try
                    {
                        DdeClient dde = new DdeClient("firefox", "WWW_GetWindowInfo");
                        dde.Connect();
                        string   url  = dde.Request("URL", int.MaxValue);
                        string[] text = url.Split(new string[] { "\",\"" }, StringSplitOptions.RemoveEmptyEntries);
                        dde.Disconnect();
                        ret = text[0].Substring(1);

                        return(ret);
                    }
                    catch { }
                }
            }

            return(ret);

            #endregion
        }
 /// <summary>
 /// Disconnect Request - Unconditionally disconnect the connection if any.
 /// </summary>
 void IConnectionManagement.DisReq()
 {
     client.Disconnect();
     m_connected = false;
 }