コード例 #1
0
ファイル: Main.cs プロジェクト: marcussacana/Social-Savior
        internal void PanicHotkeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (PanicRunning)
            {
                return;
            }
            InPanic      = true;
            PanicRunning = true;
            try {
                if (Visible)
                {
                    lblPanicTest.Text      = "Panic!";
                    lblPanicTest.BackColor = Color.Red;
                }
                else
                {
                    Program.Log("EVENT: Panic Triggered");

                    //Real Panic - LET'S HIDE THIS SHIT
                    Process[] Targets = GetExecutingBlackList();
                    string[]  LOG     = new string[0];
                    if (Settings.MuteBlacklist)
                    {
                        foreach (var Target in Targets)
                        {
                            SafeInvoker(() => Target.MuteProcess(true), () => {
                                if (Settings.KillProcessIfFails)
                                {
                                    Target.Kill();
                                }
                            });
                        }
                    }

                    if (Settings.MuteAll)
                    {
                        AudioController.AudioManager.SetMasterVolumeMute(true);
                    }

                    if (HideWindowRatio.Checked)
                    {
                        foreach (var Target in Targets)
                        {
                            SafeInvoker(Target.HideWindow, () => {
                                if (Settings.KillProcessIfFails)
                                {
                                    Target.Kill();
                                }
                            });
                        }
                    }
                    if (KillProcessRadio.Checked)
                    {
                        foreach (var Target in Targets)
                        {
                            SafeInvoker(Target.Kill);
                        }
                    }
                    if (SuspendProcessRadio.Checked)
                    {
                        foreach (var Target in Targets)
                        {
                            SafeInvoker(() => {
                                Target.HideWindow();
                                Target.SuspendProcess();
                            }, () => {
                                if (Settings.KillProcessIfFails)
                                {
                                    Target.Kill();
                                }
                            });
                        }
                    }

                    if (Settings.InvokeScreenSaver)
                    {
                        RegistryKey screenSaverKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop");
                        bool        Lock           = false;
                        if (screenSaverKey != null)
                        {
                            string screenSaverFilePath = screenSaverKey.GetValue("SCRNSAVE.EXE", string.Empty).ToString();
                            if (!string.IsNullOrEmpty(screenSaverFilePath) && File.Exists(screenSaverFilePath))
                            {
                                System.Diagnostics.Process.Start(new ProcessStartInfo(screenSaverFilePath, "/s"));  // "/s" for full-screen mode
                            }
                            else
                            {
                                Lock = true;
                            }
                        }
                        else
                        {
                            Lock = true;
                        }

                        if (Lock)
                        {
                            LockWorkStation();
                        }
                    }

                    if (Settings.FocusProcess)
                    {
                        var Processes = System.Diagnostics.Process.GetProcessesByName(Settings.ProcessToFocus);
                        if (Processes.Length > 0)
                        {
                            foreach (Process Process in Processes)
                            {
                                if (Process.MainWindowHandle != IntPtr.Zero)
                                {
                                    Process.FocusMainWindow();
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Program.Log(ex.Message + "\n" + ex.StackTrace + "\n" + ex.Source);
            }
            PanicRunning = false;
        }
コード例 #2
0
        private void PanicHotkeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (Visible)
            {
                lblPanicTest.Text      = "Panic!";
                lblPanicTest.BackColor = Color.Red;
            }
            else
            {
                //Real Panic - LET'S HIDE THIS SHIT
                Process[] Targets = GetExecutingBlackList();
                string[]  LOG     = new string[0];
                if (Settings.MuteBlacklist)
                {
                    foreach (Process Target in Targets)
                    {
                        SafeInvoker(() => Target.MuteProcess(true), () => {
                            if (Settings.KillProcessIfFails)
                            {
                                Target.Kill();
                            }
                        });
                    }
                }

                if (Settings.MuteAll)
                {
                    AudioController.AudioManager.SetMasterVolumeMute(true);
                }

                if (HideWindowRatio.Checked)
                {
                    foreach (Process Target in Targets)
                    {
                        SafeInvoker(Target.HideMainWindow, () => {
                            if (Settings.KillProcessIfFails)
                            {
                                Target.Kill();
                            }
                        });
                    }
                }
                if (KillProcessRadio.Checked)
                {
                    foreach (Process Target in Targets)
                    {
                        SafeInvoker(Target.Kill);
                    }
                }
                if (SuspendProcessRadio.Checked)
                {
                    foreach (Process Target in Targets)
                    {
                        SafeInvoker(() => {
                            Target.HideMainWindow();
                            Thread.Sleep(10);
                            Target.SuspendProcess();
                        }, () => {
                            if (Settings.KillProcessIfFails)
                            {
                                Target.Kill();
                            }
                        });
                    }
                }

                if (Settings.InvokeScreenSaver)
                {
                    RegistryKey screenSaverKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop");
                    if (screenSaverKey != null)
                    {
                        string screenSaverFilePath = screenSaverKey.GetValue("SCRNSAVE.EXE", string.Empty).ToString();
                        if (!string.IsNullOrEmpty(screenSaverFilePath) && File.Exists(screenSaverFilePath))
                        {
                            Process screenSaverProcess = System.Diagnostics.Process.Start(new ProcessStartInfo(screenSaverFilePath, "/s"));  // "/s" for full-screen mode
                        }
                    }
                }

                if (Settings.FocusProcess)
                {
                    var Processes = System.Diagnostics.Process.GetProcessesByName(Settings.ProcessToFocus);
                    if (Processes.Length > 0)
                    {
                        foreach (Process Process in Processes)
                        {
                            if (Process.MainWindowHandle != IntPtr.Zero)
                            {
                                Process.FocusMainWindow();
                                break;
                            }
                        }
                    }
                }
            }
        }