private void btnRunFilePath_Click(object sender, EventArgs e) { if (tbFilePath.Text == string.Empty) { ErrorWindow.ShowBox("Error", "File path is needed to continue.", this); } else { filePath = tbFilePath.Text; Process.Start(filePath); Thread.Sleep((int)nudWaitForSeconds.Value * 1000); btnRefreshOpenProcess.Enabled = true; ShowProcesses(); } }
private void btnAddToProfile_Click(object sender, EventArgs e) { if (tbNickname.Text == string.Empty) { ErrorWindow.ShowBox("Error", "Application profile needs a nickname.", this); } else if (lbAppProfiles.Items.Contains(tbNickname.Text)) { ErrorWindow.ShowBox("Error", "That nickname is already in use.", this); } else { appProfiles.Add(new AppProfile(tbNickname.Text, Int32.Parse(tbPositionX.Text), Int32.Parse(tbPositionY.Text), Int32.Parse(tbWidth.Text), Int32.Parse(tbHeight.Text), filePath, windowName, cbCredentials.Checked, cbAutoLogin.Checked, cbIsWebsite.Checked, cbIsNewTab.Checked, (int)nudWaitForSeconds.Value * 1000)); lbAppProfiles.Items.Add(tbNickname.Text); ClearInputs(); } }
public void Run(string userName, string password, Form parent) { try { if (isWebsite && !isNewTab) { Process process = new Process(); process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; process.StartInfo.Arguments = filePath + " --new-window"; process.Start(); } else { Process.Start(filePath); } } catch { ErrorWindow.ShowBox("Error", appNickname + "'s file path was not found. Application skipped.", parent); return; } Thread.Sleep(loadTime); if (!isNewTab) { try { MoveWindow(GetWindowProcess(windowName).MainWindowHandle, positionX, positionY, width, height, false); } catch { if (requiresCredentials) { if (ErrorWindow.ShowBox("Error", appNickname + "'s window did not load in time and was not found. Do you wish to attempt Login anyway?.", MessageBoxButtons.YesNo, parent) == DialogResult.No) { return; } } else { ErrorWindow.ShowBox("Error", appNickname + "'s window did not load in time.", MessageBoxButtons.OK, parent); } } } if (requiresCredentials) { for (int index = 0; index < userName.Length; index++) { SendKeys.SendWait(userName[index].ToString()); Thread.Sleep(10); } if (!testRun) { SendKeys.SendWait("{TAB}"); for (int index = 0; index < password.Length; index++) { SendKeys.SendWait(password[index].ToString()); Thread.Sleep(10); } if (autoLogin) { SendKeys.SendWait("{ENTER}"); } } if (testRun) { testRun = false; } if (isNewTab) { Thread.Sleep(10); SendKeys.SendWait("^1"); } } }