private void btnFinished_Click(object sender, EventArgs e)
        {
            if (tbProfileName.Text == string.Empty)
            {
                ErrorWindow.ShowBox("Error", "Profile needs a name.", this);
                return;
            }

            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoc‌​uments), "Desktop Work Setup", tbProfileName.Text);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            foreach (string file in Directory.GetFiles(path))
            {
                File.Delete(file);
            }

            foreach (AppProfile appProfile in appProfiles)
            {
                File.WriteAllLines(path + "\\" + appProfiles.IndexOf(appProfile) + appProfile.appNickname + ".txt", appProfile.GetToFileFormat());
            }

            parentForm.ProfileFormExit(false);
        }
예제 #2
0
        private void btnDeleteProfile_Click(object sender, EventArgs e)
        {
            if (lbProfiles.SelectedItem != null)
            {
                string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoc‌​uments), "Desktop Work Setup", lbProfiles.SelectedItem.ToString()).Replace("*", "");

                string[] files = Directory.GetFiles(path);

                try
                {
                    foreach (string file in files)
                    {
                        File.Delete(file);
                    }

                    Directory.Delete(path);
                }
                catch
                {
                    ErrorWindow.ShowBox("Error", "Unknown Item in selected Profile's folder.", this);
                }

                UpdateProfilesList();
            }
            else
            {
                ErrorWindow.ShowBox("Error", "No profile has been selected.", this);
            }
        }
예제 #3
0
        private void btnRunProfile_Click(object sender, EventArgs e)
        {
            RunProfile();

            this.Activate();

            if (ErrorWindow.ShowBox("Done", "Your desktop has been setup.", this) == DialogResult.OK)
            {
                Application.Exit();
            }
        }
        private void btnTest_Click(object sender, EventArgs e)
        {
            if (filePath == string.Empty)
            {
                ErrorWindow.ShowBox("Error", "No file path.", this);
                return;
            }

            if (windowName == string.Empty)
            {
                ErrorWindow.ShowBox("Error", "Window name not found.", this);
                return;
            }

            btnAddToProfile.Enabled = true;

            if (cbIsWebsite.Checked && !cbIsNewTab.Checked)
            {
                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);
            }

            Thread.Sleep((int)nudWaitForSeconds.Value * 1000);
            Process proc = GetWindowProcess(windowName);

            try
            {
                MoveWindow(proc.MainWindowHandle, windowRect.Left, windowRect.Top, windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top, false);

                if (cbCredentials.Checked)
                {
                    string test = "TESTING";
                    for (int index = 0; index < test.Length; index++)
                    {
                        SendKeys.SendWait(test[index].ToString());
                        Thread.Sleep(10);
                    }
                }
            }
            catch
            {
                ErrorWindow.ShowBox("Error", "Program failed to load in time / was not found.", this);
                return;
            }
        }
        private void btnRemoveSelected_Click(object sender, EventArgs e)
        {
            if (lbAppProfiles.SelectedItem != null)
            {
                appProfiles.RemoveAt(lbAppProfiles.SelectedIndex);
                lbAppProfiles.Items.RemoveAt(lbAppProfiles.SelectedIndex);

                btnFinished.Enabled = false;
            }
            else
            {
                ErrorWindow.ShowBox("Error", "No application has been selected.", this);
            }
        }
        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");
                }
            }
        }