public static bool LoginSISCOBWhite(string User, string Pass) { //Carrega o numero do ramal das configurações do 3cx IniFile ramalConfig = new IniFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\AppData\Local\3CX VoIP Phone\3CXVoipPhone.ini"); int profile = 0; String ramal = ""; while (true) { if (ramalConfig.KeyExists("CallerID", "Profile" + profile.ToString())) { if (ramalConfig.Read("Enabled", "Profile" + profile.ToString()).Equals("1")) { ramal = ramalConfig.Read("CallerID", "Profile" + profile.ToString()); break; } } else { break; } profile++; } var appLauncher = TestStack.White.Application.Launch(@"C:\Program Files\CSLog\Cobranca2\startsiscob.exe"); while (Process.GetProcessesByName("cobdesk").Count() == 0) { Thread.Sleep(100); } var app2 = TestStack.White.Application.Attach("cobdesk"); var mainWindow = app2.GetWindow("Login CSLog"); var txtLogin = mainWindow.Get(SearchCriteria.ByClassName("TEditCob")); txtLogin.SetValue(User); var txtSenha = mainWindow.Get(SearchCriteria.ByClassName("TMaskEditCob")); txtSenha.SetValue(Pass); var btnEnter = mainWindow.Get(SearchCriteria.ByText("[Ctrl + Enter]")); btnEnter.Click(); Thread.Sleep(500); try { mainWindow.Get(SearchCriteria.ByClassName("TMaskEditCob")); Logger.LoginSicobError(); DialogResult result2 = MessageBox.Show("SENHA INCORRETA. RESTA(M) 2 TENTATIVA(S) PARA BLOQUEIO !!!", "Facilita", MessageBoxButtons.OK, MessageBoxIcon.Error); var loginCerto = TestStack.White.Application.Attach("cobdesk"); var ramalWindow = app2.GetWindow("Digite o seu Ramal:"); var txtRamal = ramalWindow.Get(SearchCriteria.ByClassName("TEditCob")); txtRamal.SetValue(ramal); Thread.Sleep(300); ramalWindow.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.RETURN); return(true); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); var ramalWindow = app2.GetWindow("Digite o seu Ramal:"); var txtRamal = ramalWindow.Get(SearchCriteria.ByClassName("TEditCob")); txtRamal.SetValue(ramal); Thread.Sleep(300); ramalWindow.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.RETURN); Thread.Sleep(1000); Ligacao(); //if (liga) // { // //Pronto chamada // //Task.Run(() => RetornarLigacao()); // } return(true); } }