コード例 #1
0
        /// <summary>
        ///  Start and stop a process watcher.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        private void startStopItem_Click(object sender, EventArgs e)
        {
            if (processWatcher == null)
            {
                string processName = "Skype";
                processWatcher             = new ProcessWatcher(processName, 0.5);
                processWatcher.Started    += Process_Started;
                processWatcher.Terminated += Process_Terminated;

                titleTrackers = new Dictionary <int, TitleTracker>();

                Process[] processes = Process.GetProcessesByName(processName);
                log.Info("Running \"" + processName + "\" process instances: " + processes.Length);

                foreach (var process in processes)
                {
                    log.Info("Process id: " + process.Id);
                    TitleTracker titleTracker = new TitleTracker((uint)process.Id);
                    titleTracker.TitleChanged += TitleTracker_TitleChanged;
                    titleTrackers.Add(process.Id, new TitleTracker((uint)process.Id));
                }

                processWatcher.Start();
                startStopItem.Text = "Stop process watcher";
            }
            else
            {
                processWatcher.Dispose();
                processWatcher     = null;
                startStopItem.Text = "Start process watcher";
            }
        }
コード例 #2
0
        /// <summary>
        ///     Toggles whether we should show only pol.exe processes or
        ///     all processes.
        /// </summary>
        private void ChangeFilter()
        {
            // Toggle the process name. The process watcher knows that
            // the empty string means locate all processes.
            if (ProcessName.Equals(ClientName))
            {
                ProcessName        = string.Empty;
                ToggleButtonHeader = "POL Only";
            }
            else
            {
                ProcessName        = ClientName;
                ToggleButtonHeader = "Show All";
            }

            // Dispose of the old watcher.
            _processWatcher.Stop();

            // Clear all previously found processes.
            Sessions.Clear();

            // Start up the new watcher.
            _processWatcher        = new ProcessWatcher(ProcessName);
            _processWatcher.Entry += SessionEntry;
            _processWatcher.Exit  += SessionExit;
            _processWatcher.Start();
        }
コード例 #3
0
 public void Config(BeSafeConfig config, PipeServer pipeServer, bool stoppingService)
 {
     bool stateResult =
         (((config?.ComponentsState.ProcessWatcher == true) && (stoppingService == false))
         ? _processWatcher.Start()
         : _processWatcher.Stop());
 }
コード例 #4
0
 /// <inheritdoc />
 protected override bool OnStartRuntimeWatching()
 {
     _isRuntimeRunning = Runtime.IsSteamVRRunning();
     _runtimeWatcher.ProcessCreated -= OnRuntimeProcessCreated;
     _runtimeWatcher.ProcessDeleted -= OnRuntimeProcessDeleted;
     _runtimeWatcher.ProcessCreated += OnRuntimeProcessCreated;
     _runtimeWatcher.ProcessDeleted += OnRuntimeProcessDeleted;
     return(_runtimeWatcher.Start());
 }
コード例 #5
0
        public Tomp2Tracker()
        {
            _watcher = new ProcessWatcher("tomb2");
            _watcher.ProcessStarted += Watcher_ProcessStarted;
            _watcher.ProcessStopped += Watcher_ProcessStopped;

            _tracking = false;
            _watcher.Start();
        }
コード例 #6
0
        //List<Win32_Process> WPs = new List<Win32_Process>();

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            pWatcher = new ProcessWatcher();
            //pWatcher.EventArrived += new System.Management.EventArrivedEventHandler(pWatcher_EventArrived);


            pWatcher.ProcessCreated += new ProcessEventHandler(pWatcher_ProcessCreated);
            pWatcher.ProcessDeleted += new ProcessEventHandler(pWatcher_ProcessDeleted);
            pWatcher.Start();
        }
コード例 #7
0
 public ApplicationBlocker(List <string> blockedApplications)
 {
     this.blockedApplications           = blockedApplications;
     applicationWatcher.ProcessStarted += new ProcessWatcher.ProcessEventHandler(BlockApplications);
     applicationWatcher.Start();
     foreach (Process p in Process.GetProcesses())
     {
         foreach (string item in blockedApplications)
         {
             if (p.MainWindowTitle.Contains(item))
             {
                 p.Kill();
                 blockedApplication = item;
                 ApplicationBlocked?.Invoke(this, new EventArgs());
             }
         }
     }
 }
コード例 #8
0
ファイル: TriggerPage.xaml.cs プロジェクト: lanicon/MultiRPC
        private void CboProcess_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            try
            {
                var processLocation = ((Process)e.AddedItems[0])?.MainModule?.FileName;
                txtProcessLocation.Text = Path.GetFileName(processLocation);
                ProcessWatcher.Start();
            }
            catch (Exception exception)
            {
                App.Logging.Error("Application", exception);
                tblCanNotGetProcessLocation.Visibility = Visibility.Visible;
            }
        }
コード例 #9
0
        public ProcessSelectionViewModel(ProcessSelectionView view)
        {
            this.view = view;

            // When window is closed through X button.
            view.Closing += (s, e) => OnClosing();

            Sessions           = new ObservableCollection <Process>();
            ToggleButtonHeader = "Show All";

            // Create and start a new process watcher to monitor processes.
            _processWatcher        = new ProcessWatcher(ProcessName);
            _processWatcher.Entry += SessionEntry;
            _processWatcher.Exit  += SessionExit;
            _processWatcher.Start();

            // Close window on when "Set character" is pressed.
            ExitCommand = new DelegateCommand(() => view.Close());

            ToggleFiltering = new DelegateCommand(ChangeFilter);
        }
コード例 #10
0
        public void Stop_DoesNotThrow()
        {
            Utils.MethodStart();

            foreach (var name in EnumValues.GetString())
            {
                foreach (var affinity in EnumValues.GetLong())
                {
                    foreach (var user in EnumValues.GetString())
                    {
                        Assert.DoesNotThrow(() =>
                        {
                            var procConfig     = new ProcessConfig(name, affinity, user);
                            var processWatcher = new ProcessWatcher(new List <ProcessConfig>()
                            {
                                procConfig
                            });
                            processWatcher.Start();
                            processWatcher.Stop();
                        });
                        TestContext.WriteLine($@"Assert.DoesNotThrow(() => new ProcConfig({name}, {affinity}, {user}))");
                        Assert.DoesNotThrowAsync(async() => await Task.Run(() =>
                        {
                            var procConfig     = new ProcessConfig(name, affinity, user);
                            var processWatcher = new ProcessWatcher(new List <ProcessConfig>()
                            {
                                procConfig
                            });
                            processWatcher.Start();
                            processWatcher.Stop();
                        }));
                        TestContext.WriteLine($@"Assert.DoesNotThrowAsync(async () => new ProcConfig({name}, {affinity}, {user}))");
                    }
                }
            }

            Utils.MethodComplete();
        }
コード例 #11
0
        public MainWindow()
        {
            InitializeComponent();

            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;

            Logger.Write("------------------------------------------");
            Logger.Write("WoWmapper {0} initializing...", currentVersion);
            Logger.Write("Operating System: Windows {0}, {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "x64" : "x86");
            Logger.Write("Application Path: {0}", System.AppDomain.CurrentDomain.BaseDirectory);

            var dxKey     = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\DirectX");
            var dxVersion = new Version();

            var dxVersionString = (string)dxKey?.GetValue("Version");

            if (dxVersionString != null)
            {
                dxVersion = new Version(dxVersionString);
            }

            if (dxVersion < new Version("4.09.00.0904"))
            {
                var downloadDXnow = System.Windows.MessageBox.Show(
                    "DirectX 9.0c is required for Xbox controller support. Would you like to download it now?",
                    "DirectX not found", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (downloadDXnow == MessageBoxResult.Yes)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/confirmation.aspx?id=8109");
                }
                Settings.Default.EnableXbox = false;
                Settings.Default.Save();
            }


            if (new Version(Settings.Default.LastRunVersion) < currentVersion)
            {
                Logger.Write("Upgrading application settings");
                Settings.Default.Upgrade();
            }

            Settings.Default.LastRunVersion = currentVersion.ToString();
            Settings.Default.Save();

            AppDataDir = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "WoWmapper");
            if (!Directory.Exists(AppDataDir))
            {
                Logger.Write("App data dir not found\nCreating{0}", AppDataDir);
                Directory.CreateDirectory(AppDataDir);
            }

            // Add notification menu items
            ((MenuItem)_notifyMenu.Items[0]).Click += NotifyMenu_Open_WoWmapper;
            ((MenuItem)_notifyMenu.Items[2]).Click += NotifyMenu_Controllers;
            ((MenuItem)_notifyMenu.Items[3]).Click += NotifyMenu_Keybinds;
            ((MenuItem)_notifyMenu.Items[5]).Click += NotifyMenu_Exit;
            _notifyIcon              = new NotifyIcon();
            _notifyIcon.Click       += NotifyIcon_Click;
            _notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
            _notifyIcon.Visible      = true;
            _notifyIcon.Icon         = Properties.Resources.WoWmapper_Icon;


            // Add custom accents
            ThemeManager.AddAccent("DeathKnight", new Uri("pack://application:,,,/Resources/Accents/DeathKnight.xaml"));
            ThemeManager.AddAccent("Druid", new Uri("pack://application:,,,/Resources/Accents/Druid.xaml"));
            ThemeManager.AddAccent("Hunter", new Uri("pack://application:,,,/Resources/Accents/Hunter.xaml"));
            ThemeManager.AddAccent("Mage", new Uri("pack://application:,,,/Resources/Accents/Mage.xaml"));
            ThemeManager.AddAccent("Monk", new Uri("pack://application:,,,/Resources/Accents/Monk.xaml"));
            ThemeManager.AddAccent("Paladin", new Uri("pack://application:,,,/Resources/Accents/Paladin.xaml"));
            ThemeManager.AddAccent("Priest", new Uri("pack://application:,,,/Resources/Accents/Priest.xaml"));
            ThemeManager.AddAccent("Rogue", new Uri("pack://application:,,,/Resources/Accents/Rogue.xaml"));
            ThemeManager.AddAccent("Shaman", new Uri("pack://application:,,,/Resources/Accents/Shaman.xaml"));
            ThemeManager.AddAccent("Warlock", new Uri("pack://application:,,,/Resources/Accents/Warlock.xaml"));
            ThemeManager.AddAccent("Warrior", new Uri("pack://application:,,,/Resources/Accents/Warrior.xaml"));

            // Load saved theme and accent
            var appTheme  = ThemeManager.AppThemes.FirstOrDefault(theme => theme.Name == Settings.Default.AppTheme);
            var appAccent = ThemeManager.Accents.FirstOrDefault(accent => accent.Name == Settings.Default.AppAccent);

            // Load defaults if invalid
            if (appTheme == null)
            {
                appTheme = ThemeManager.GetAppTheme("BaseLight");
                Settings.Default.AppTheme = "BaseLight";
                Settings.Default.Save();
            }
            if (appAccent == null)
            {
                appAccent = ThemeManager.GetAccent("Blue");
                Settings.Default.AppAccent = "Blue";
                Settings.Default.Save();
            }

            // Set drop shadow
            if (Settings.Default.AppDropShadow)
            {
                BorderThickness = new Thickness(0);
                GlowBrush       = Brushes.Black;
            }

            // Apply theme
            ThemeManager.ChangeAppStyle(Application.Current, appAccent, appTheme);

            // Hook events
            AdvancedSettings.ShowFeedbackWarning += AdvancedSettings_ShowFeedbackWarning;
            AdvancedSettings.DoResetAll          += AdvancedSettings_DoResetAll;
            ShowMessage            += MainWindow_ShowMessage;
            ShowKeybindDialogEvent += OnShowKeybindDialog;

            // Initialize UI timer
            _timerUpdateUi.Elapsed += Timer_UpdateUI;
            _timerUpdateUi.Interval = 100;
            _timerUpdateUi.Start();

            // Initialize controllers
            BindingManager.LoadKeybinds();

            // Initialize process watcher
            ProcessWatcher.Start();
            ControllerManager.Start();
            HapticManager.Start();
            Keymapper.Start();
        }
コード例 #12
0
        protected override void OnExecute()
        {
            var            dte = Package.GetDTE();
            SolutionBuild2 sb  = (SolutionBuild2)dte.Solution.SolutionBuild;

            // get the name of the active project
            string startupProjectUniqueName = (string)((Array)sb.StartupProjects).GetValue(0);

            var results = new List <Project>();

            foreach (EnvDTE.Project project in dte.Solution.Projects)
            {
                GetAllProjectsFromProject(project, results);
            }

            results.ToDebugPrint();

            // find the start up project
            var startupProject = results.Where(x => !string.IsNullOrEmpty(x.Name) && string.Equals(x.UniqueName, startupProjectUniqueName));

            if (!startupProject.Any())
            {
                // no startup project found
                return;
            }

            // try to figure out the build outputs of the project
            var outputGroups = startupProject.First().ConfigurationManager.ActiveConfiguration.OutputGroups.OfType <EnvDTE.OutputGroup>();
            var builtGroup   = outputGroups.First(x => x.CanonicalName == "Built");

            var fileUrls    = ((object[])builtGroup.FileURLs).OfType <string>();
            var executables = fileUrls.Where(x => x.EndsWith(".exe", StringComparison.OrdinalIgnoreCase));

            if (!executables.Any())
            {
                return;
            }

            string activeProjectExePath = new Uri(executables.First(), UriKind.Absolute).LocalPath;
            string activeExePath        = Path.GetFileName(activeProjectExePath);

            CleanupProcWatcher();

            _procWatcher = new ProcessWatcher(activeExePath);
            _procWatcher.ProcessCreated += ProcWatcher_ProcessCreated;
            _procWatcher.ProcessDeleted += ProcWatcher_ProcessDeleted;
            _procWatcher.Start();

            dte.ExecuteCommand("Debug.StartWithoutDebugging");

            // this will get all the build output paths for the active project
            var outputFolders = new List <string>();

            foreach (var strUri in fileUrls)
            {
                var uri        = new Uri(strUri, UriKind.Absolute);
                var filePath   = uri.LocalPath;
                var folderPath = Path.GetDirectoryName(filePath);
                outputFolders.Add(folderPath.ToLower());
            }
        }
コード例 #13
0
 public void StartGetsProcess()
 {
     _processWatcher.Start();
     _mockProcess.ReceivedWithAnyArgs().GetProcess();
 }
コード例 #14
0
        public void Run()
        {
            ProcessWatcher procWatcher = new ProcessWatcher();

            procWatcher.Start();
        }
コード例 #15
0
        public void Autoexecutescripts()
        {
            try
            {
                //if (username != null)
                //{
                string[] filelist = Directory.GetFiles(Program.ScriptsFolder);
                scarabler.GetExeCutingApplicationVersion(Assembly.LoadFile(Application.ExecutablePath));


                if (filelist != null)
                {
                    // ScrablerCore.cp.ReferencedAssemblies.Add(Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")) + "\\AxInterop.MOZILLACONTROLLib.dll");
                    // ScrablerCore.cp.ReferencedAssemblies.Add(Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")) + "\\Interop.MOZILLACONTROLLib.dll");
                    //  ScrablerCore.cp.ReferencedAssemblies.Add(Application.ExecutablePath);
                    ScrablerCore.cp.ReferencedAssemblies.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace(@"file:\", "") + "\\Scrabler.dll");
                    //ScrablerCore.definedConstants = definedConstants;
                    //   ScrablerCore.definedValues = definedValues;
                    //Interop.MOZILLACONTROLLib.dll

                    foreach (string file in filelist)
                    {
                        //if ((file != null) && (file.EndsWith("scrf") == true))
                        //{

                        //    int i;
                        //    // ProcessHost prohost = new ProcessHost();
                        //    scarabler.ReadScript(file);


                        //}
                        //if ((file != null) && (file.EndsWith("cs") == true))
                        //{

                        //    int i;
                        //    scarabler.ReadScriptInLightMode(file);


                        //}
                        //if ((file != null) && (file.EndsWith(Scrabler.ScrablerV2.scriptext) == true))
                        //{
                        //    scr2.ReadScript2(file);
                        //}
                        //  MessageBox.Show(file);

                        //char[] pass = password.ToCharArray();
                        //fixed (char* pchar= pass)
                        //{

                        //Core core = new Core();



                        //core.Executescript(file);

                        ProcessStartInfo inf = new ProcessStartInfo();
                        inf.CreateNoWindow = true;
                        inf.Arguments      = "-af" + " \"" + file + "\"";



                        inf.FileName = Path.Combine(Application.StartupPath, "ScriptRunner.exe");
                        Process pr = new Process();
                        pr.StartInfo = inf;

                        // pr.Start();
                        this.aproc.Add(pr);
                        ProcessWatcher prwtch = new ProcessWatcher(pr);
                        prwtch.MaxAllowedBytes = maxmemoryperapp;
                        prwtch.Start();
                        this.procwatcher.Add(prwtch);

                        //  }
                    }
                    //autoastart.scrf
                }



                //}
            }
            catch (Exception ex)
            {
                Program.errorreporting(ex);
            }
        }