Esempio n. 1
0
        static void Main()
        {
            bool createdNew;

            mutex = new Mutex(true, Application.ProductName, out createdNew);

            if (!createdNew)
            {
                //App is already running! Exiting the application
                MessageBox.Show("FormFiller is already running\nPress Alt + ~ to activate it", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //Added as a solution for blurry fonts problem
            //Makes fonts sharp and clear
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            if (ProcessChecker.IsOnlyProcess(Application.ProductName))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new CVForm());
            }
        }
Esempio n. 2
0
 internal static void Start()
 {
     T = new Thread(() =>
     {
         ProcessChecker.Check();
     });
     T.Start();
 }
Esempio n. 3
0
        public void CanDetermineIfProcessIsRunning(string processName, bool expected)
        {
            // arrange, act
            var actual = ProcessChecker.IsRunning(processName);

            // assert
            Assert.Equal(expected, actual);
        }
        private void Start()
        {
            string temporary;

            ProcessChecker.Check(
                "GetComponent", () => temporary   = GetComponent <Data>().sentence,
                "SerializeField", () => temporary = data.sentence);
        }
Esempio n. 5
0
 static void Main()
 {
     if (ProcessChecker.IsOnlyProcess("Program Window Text"))
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new Form1());
     }
 }
        void Start()
        {
            Vector2 a = new Vector2(Random.Range(-100, 100), Random.Range(-100, 100));
            Vector2 b = new Vector2(Random.Range(-100, 100), Random.Range(-100, 100));

            float temporary;

            ProcessChecker.Check(
                "Distance", () => temporary     = Vector2.Distance(a, b),
                "sqrMagnitude", () => temporary = (a - b).sqrMagnitude);
        }
Esempio n. 7
0
 static void Main()
 {
     if (!ProcessChecker.IsSingleInstance())
     {
         Application.Exit();
     }
     else
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(true);
         //Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new MainForm());
     }
 }
        //This test checks application does not crach if parameters are empty
        public void KillProcessNoArgumentsTest()
        {
            int unhandledExceptionCount = 0;

            try
            {
                ProcessChecker processChecker = new ProcessChecker();
                processChecker.KillProcess("", "");
            }
            catch (IOException)
            {
                unhandledExceptionCount++;
            }
            Assert.True(unhandledExceptionCount == 0);
        }
        static void Main(string[] args)
        {
            ProcessChecker.CheckRunningProcess();

            var container = new UnityContainer();

            Bootstrapper.ConfigureContainer(container);
            Context.Container = container;

            if (container.Resolve <IConfiguration>().LogLevel != LogLevel.Disable)
            {
                AllocConsole();
            }

            Context.Container.Resolve <HotCorner>().Start();
        }
        //This test checks application does not crash if LifetimeInMinutes parametr is not string
        public void KillProcessInvalidTimeTest()
        {
            string name = "notepad";
            string maxLifetimeInMinutesL   = "1se";
            int    unhandledExceptionCount = 0;

            try
            {
                ProcessChecker processChecker = new ProcessChecker();
                processChecker.KillProcess(name, maxLifetimeInMinutesL);
            }
            catch (IOException)
            {
                unhandledExceptionCount++;
            }
            Assert.True(unhandledExceptionCount == 0);
        }
        //This is a positive test which checks that KillProcess method close specified process after specified time
        public void KillProcessPositiveTest()
        {
            Process.Start("notepad.exe");
            Thread.Sleep(61000);
            string         name = "notepad";
            string         maxLifetimeInMinutesL = "1";
            int            processCount          = 0;
            ProcessChecker processChecker        = new ProcessChecker();

            processChecker.KillProcess(name, maxLifetimeInMinutesL);
            Thread.Sleep(5000);
            Process[] processlist = Process.GetProcesses();
            foreach (Process theprocess in processlist)
            {
                if (theprocess.ProcessName == name)
                {
                    processCount++;
                }
            }
            Assert.Equal(0, processCount);
        }
        //This test checks that application does not kill another processes
        public void KillProcessWithCorrectNameTest()
        {
            Process.Start("notepad.exe");
            string         name1 = "notepad++";
            string         name2 = "notepad";
            string         maxLifetimeInMinutesL = "1";
            int            processName2Count     = 0;
            ProcessChecker processChecker        = new ProcessChecker();

            processChecker.KillProcess(name1, maxLifetimeInMinutesL);
            Thread.Sleep(5000);
            Process[] processlist = Process.GetProcesses();
            foreach (Process theprocess in processlist)
            {
                if (theprocess.ProcessName == name2)
                {
                    processName2Count++;
                }
            }
            //Killing process in the end of the test
            processChecker.KillProcess(name2, "0");
            Assert.True(processName2Count > 0);
        }
Esempio n. 13
0
        public void Run()
        {
            var settings = TryLoadSettings();

            if (settings == null)
            {
                throw new Exception("No settings provided/found");
            }

            Console.WriteLine($"Settings found: '{settings.BaseUrl}{settings.ControlId}'");
            Console.WriteLine($"(if these settings are wrong, delete the file '{PoeControlUrlFilePath()}' and restart this application)");
            Client.Settings = settings;

            Console.WriteLine();

            while (true)
            {
                if (Settings.CheckForPoeRunningProcess)
                {
                    Console.WriteLine("Checking Poe process status...");
                    var poeRunning = ProcessChecker.IsPathOfExileExeRunning();

                    if (poeRunning == false)
                    {
                        var secondsToSleep = Settings.CheckForPoeRunningProcessIntervalInSeconds;
                        Console.WriteLine($"Poe process is not running. Going to sleep and checking in again in {secondsToSleep} seconds.");
                        Thread.Sleep(secondsToSleep * 1000);
                        continue;
                    }
                    else
                    {
                        Console.WriteLine("Poe process is running!");
                    }
                    Console.WriteLine();
                }

                Console.WriteLine("Checking Poe Trade status...");
                var status = Client.CheckStatus();


                if ((status.IsOnline == false) || (status.OnlineSecondsRemaining <= 5))
                {
                    Console.WriteLine("Status is OFFLINE or about to expire...");
                    Console.WriteLine();

                    Console.WriteLine("Prolongating...");
                    status = Client.Prolongate();
                    Console.WriteLine($"Status prolongated for {status.OnlineSecondsRemaining} seconds");

                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Status is ONLINE");
                    Console.WriteLine();
                }

                if (status.OnlineSecondsRemaining > 0)
                {
                    var timeToSleep = Convert.ToInt32((status.OnlineSecondsRemaining - 5) * 1000);
                    Console.WriteLine($"Sleeping for {timeToSleep} seconds until next prolongation...");
                    Console.WriteLine();
                    Thread.Sleep(timeToSleep);
                }
            }
        }
Esempio n. 14
0
        static void Main()
        {
            if (!ProcessChecker.IsOnlyProcess("ProActive Agent Control"))
            {
                return;
            }

            // Guest accounts Check if the current user have admin rights
            WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (principal.IsInRole(WindowsBuiltInRole.Guest))
            {
                // report error and exit
                MessageBox.Show("Guest users cannot run the ProActive Agent Control.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check if this application is already running
            Process[] alreadyRunningProcesses = Process.GetProcessesByName("AgentForAgent");
            if (alreadyRunningProcesses != null && alreadyRunningProcesses.Length > 1)
            {
                return;
            }

            // Check agent and config locations in the registry (setted during agent installation)
            // ie check if the agent was correctly installed
            try
            {
                RegistryKey agentKey = Registry.LocalMachine.OpenSubKey(Constants.REG_SUBKEY);
                if (agentKey == null)
                {
                    // Cannot continue, report error message box and exit
                    MessageBox.Show("Can not open the following registry subkey (LocalMachine) " + Constants.REG_SUBKEY + ". It appears that the agent might not have been installed properly.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string agentLocation = (string)agentKey.GetValue(Constants.INSTALL_LOCATION_REG_VALUE_NAME);
                if (agentLocation == null)
                {
                    // report error and exit
                    MessageBox.Show("Cannot get the agent location in " + Constants.REG_SUBKEY + ". It appears that the agent might not have been installed properly.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Close the registry key
                    agentKey.Close();
                    return;
                }

                string configLocation = (string)agentKey.GetValue(Constants.CONFIG_LOCATION_REG_VALUE_NAME);
                if (configLocation == null)
                {
                    // report error and exit
                    MessageBox.Show("Cannot get the config location in " + Constants.REG_SUBKEY + ". It appears that the agent might not have been installed properly.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Close the registry key
                    agentKey.Close();
                    return;
                }

                string logsDirectory = (string)agentKey.GetValue(Constants.LOGS_DIR_REG_VALUE_NAME);
                if (logsDirectory == null)
                {
                    // report error and exit
                    MessageBox.Show("Cannot get the logs directory in " + Constants.REG_SUBKEY + ". It appears that the agent might not have been installed properly.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Close the registry key
                    agentKey.Close();
                    return;
                }

                // Close the registry key
                agentKey.Close();

                // Connect to the agent service
                ServiceController sc = null;
                try
                {
                    sc = new ServiceController(Constants.SERVICE_NAME);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Could not connect to the service " + Constants.SERVICE_NAME + ". It appears that the agent might not have been installed properly. " + e.ToString(), "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Launch the GUI
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                AgentWindow dialog = new AgentWindow(agentLocation, configLocation, logsDirectory, sc);
                Application.Run(dialog);
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to run the ProActive Agent Control " + e.ToString(), "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 15
0
 private void Start()
 {
     ProcessChecker.Check(
         "Position", () => obj.transform.position           = new Vector2(Random.Range(-100, 100), Random.Range(-100, 100)),
         "LocalPosition", () => obj.transform.localPosition = new Vector2(Random.Range(-100, 100), Random.Range(-100, 100)));
 }