Ejemplo n.º 1
0
        static void Main()
        {
            if (!StartChecks.StartCheck())
            {
                return;
            }

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm();

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();
            Settings sform = new Settings();

            DPIManager.AddForm(sform);
            DPIManager.ForceUpdate();
            SearchDisksForm sdf = new SearchDisksForm(form);

            DPIManager.AddForm(sdf);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            new Log(true);

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);

            // Set the unhandled exception mode to force all Windows Forms errors
            // to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm(args);

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            new Log(true);

            ThreadUtil.Initialize();

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);

            // Set the unhandled exception mode to force all Windows Forms errors
            // to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

            // initialize DPIManager BEFORE setting
            // the application to be DPI aware,
            // or else Windows will give us pre-scaled monitor sizes
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            GameManager gameManager = new GameManager();

            StartMainForm(args, gameManager);
        }
Ejemplo n.º 4
0
        public void End()
        {
            User32Util.ShowTaskBar();

            hasEnded = true;
            GameManager.Instance.ExecuteBackup(this.userGame.Game);

            LogManager.UnregisterForLogCallback(this);

            Cursor.Clip = Rectangle.Empty; // guarantee were not clipping anymore
            string backupDir = GameManager.Instance.GempTempFolder(this.userGame.Game);

            // delete symlink folder
            try
            {
#if RELEASE
                for (int i = 0; i < profile.PlayerData.Count; i++)
                {
                    string linkFolder = Path.Combine(backupDir, "Instance" + i);
                    if (Directory.Exists(linkFolder))
                    {
                        Directory.Delete(linkFolder, true);
                    }
                }
#endif
            }
            catch { }

            if (Ended != null)
            {
                Ended();
            }
        }
Ejemplo n.º 5
0
        private void btn_Play_Click(object sender, EventArgs e)
        {
            if (btn_Play.Text == "S T O P")
            {
                if (handler.FakeFocus != null)
                {
                    handler.FakeFocus.Abort();
                }
                if (handler != null)
                {
                    Log("Stop button clicked, calling Handler End function");
                    handler.End();
                }
                SetBtnToPlay();
                btn_Play.Enabled = false;
                this.Controls.Clear();
                this.InitializeComponent();
                RefreshGames();

                return;
            }

            btn_Play.Text   = "S T O P";
            btnBack.Enabled = false;

            handler = gameManager.MakeHandler(currentGame);
            handler.Initialize(currentGameInfo, GameProfile.CleanClone(currentProfile));
            handler.Ended += handler_Ended;

            gameManager.Play(handler);
            if (handler.TimerInterval > 0)
            {
                handlerThread = new Thread(UpdateGameManager);
                handlerThread.Start();
            }

            if (currentGame.HideTaskbar)
            {
                User32Util.HideTaskbar();
            }

            if (currentGame.HideDesktop)
            {
                foreach (Screen screen in Screen.AllScreens)
                {
                    System.Windows.Forms.Form hform = new System.Windows.Forms.Form();
                    hform.BackColor       = Color.Black;
                    hform.Location        = new Point(0, 0);
                    hform.Size            = screen.WorkingArea.Size;
                    this.Size             = screen.WorkingArea.Size;
                    hform.FormBorderStyle = FormBorderStyle.None;
                    hform.StartPosition   = FormStartPosition.Manual;
                    //hform.TopMost = true;
                    hform.Show();
                }
            }

            WindowState = FormWindowState.Minimized;
        }
Ejemplo n.º 6
0
 public static void PreInitialize()
 {
     if (ini.IniReadValue("Advanced", "Scale") != "")
     {
         Scale = float.Parse(ini.IniReadValue("Advanced", "Scale"));
     }
     else
     {
         Scale = User32Util.GetDPIScalingFactor();
     }
 }
Ejemplo n.º 7
0
        public static UserScreen[] AllScreens()
        {
            Display[]    all   = User32Util.GetDisplays();
            UserScreen[] rects = new UserScreen[all.Length];

            for (int i = 0; i < rects.Length; i++)
            {
                rects[i] = new UserScreen(all[i].Bounds);
            }

            return(rects);
        }
Ejemplo n.º 8
0
        public static Rectangle[] AllScreensRec()
        {
            //return GetSetup_Triple4kHorizontal();
            Display[]   all   = User32Util.GetDisplays();
            Rectangle[] rects = new Rectangle[all.Length];

            for (int i = 0; i < all.Length; i++)
            {
                rects[i] = all[i].Bounds;
            }

            return(rects);
        }
Ejemplo n.º 9
0
        public static UserScreen[] AllScreens()
        {
#if WINDOWS
            Display[]    all   = User32Util.GetDisplays();
            UserScreen[] rects = new UserScreen[all.Length];

            for (int i = 0; i < rects.Length; i++)
            {
                rects[i] = new UserScreen(all[i].Bounds);
            }

            return(rects);
#else
            throw new Exception();
#endif
        }
Ejemplo n.º 10
0
        static void Main()
        {
            // initialize DPIManager BEFORE setting
            // the application to be DPI aware
            DPIManager.PreInitialize();
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm form = new MainForm();

            DPIManager.AddForm(form);
            DPIManager.ForceUpdate();

            Application.Run(form);
        }
Ejemplo n.º 11
0
        private void BaseForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (!User32Util.IsFormFocused(this) ||
                WindowState == FormWindowState.Maximized)
            {
                return;
            }

            if (mouseDown)
            {
                startResizer();
            }
            else
            {
                UpdateCursor();
            }
        }
Ejemplo n.º 12
0
        private void BaseForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (!User32Util.IsFormFocused(this) ||
                WindowState == FormWindowState.Maximized)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (!mouseDown)
                {
                    // make sure we update before we try moving anything
                    UpdateCursor();
                }
                mouseDown = true;
            }
        }
Ejemplo n.º 13
0
        private static void AppForm_LocationChanged(object sender, EventArgs e)
        {
            Form  form     = (Form)sender;
            uint  val      = User32Util.GetDpiForWindow(form.Handle);
            float newScale = val / 96.0f;
            float dif      = Math.Abs(newScale - Scale);

            if (dif > 0.001f)
            {
                // DPI changed
                Scale = newScale;
                UpdateFont();

                // update all components
                form.Invoke((Action) delegate() {
                    UpdateAll();
                });
            }
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Log.WriteLine("Invalid usage! Need arguments to proceed!", Palette.Error);
                return;
            }

            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            NotifyIcon  notifyIcon  = new NotifyIcon();
            ContextMenu contextMenu = new ContextMenu();

            MenuItem exitMenuItem = new MenuItem();

            contextMenu.MenuItems.AddRange(new MenuItem[] { exitMenuItem });
            exitMenuItem.Index  = 0;
            exitMenuItem.Text   = "Exit";
            exitMenuItem.Click += new EventHandler(exitClick);

            notifyIcon.Icon        = Resources.icon;
            notifyIcon.Text        = "Nucleus Coop GameTasks";
            notifyIcon.ContextMenu = contextMenu;
            notifyIcon.Visible     = true;

            string        base64 = Encoding.UTF8.GetString(Convert.FromBase64String(args[0]));
            StartGameData data   = JsonConvert.DeserializeObject <StartGameData>(base64);

            ThreadPool.QueueUserWorkItem(ExecuteTaskOnThread, data);

            Application.Run();
            notifyIcon.Visible = false;
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            if (args.Length == 0)
            {
                ConsoleU.WriteLine("Invalid usage! Need arguments to proceed!", Palette.Error);
                return;
            }

#if RELEASE
            try
#endif
            {
                string        base64 = Encoding.UTF8.GetString(Convert.FromBase64String(args[0]));
                StartGameData data   = JsonConvert.DeserializeObject <StartGameData>(base64);

                switch (data.Task)
                {
                case GameStarterTask.StartGame:
                {
                    string gamePath       = data.Parameters[0];
                    string gameArgs       = data.Parameters[1];
                    string gameWorkingDir = data.Parameters[2];

                    ConsoleU.WriteLine($"Start game: EXE: {gamePath} ARGS: {gameArgs} WORKDIR: {gameWorkingDir}", Palette.Feedback);
                    StartGame(gamePath, gameArgs, gameWorkingDir);
                }
                break;

                case GameStarterTask.KillMutex:
                {
                    string procId = data.Parameters[0];
                    ConsoleU.WriteLine($"Process ID {procId} request to kill mutexes", Palette.Wait);
                    proc = Process.GetProcessById(int.Parse(procId));

                    ConsoleU.WriteLine($"Trying to kill mutexes {data.Parameters.Length - 1} mutexes", Palette.Wait);
                    for (int j = 1; j < data.Parameters.Length; j++)
                    {
                        string m      = data.Parameters[j];
                        string prefix = $"({j}/{data.Parameters.Length - 1}) ";
                        ConsoleU.WriteLine(prefix + "Trying to kill mutex: " + m, Palette.Feedback);

                        if (!ProcessUtil.KillMutex(proc, m))
                        {
                            ConsoleU.WriteLine(prefix + "Mutex " + m + " could not be killed", Palette.Error);
                        }
                        else
                        {
                            ConsoleU.WriteLine(prefix + "Mutex killed " + m, Palette.Success);
                        }
                        Thread.Sleep(150);
                    }
                }
                break;

                case GameStarterTask.QueryMutex:
                {
                    string procId = data.Parameters[0];
                    ConsoleU.WriteLine($"Process ID {procId} request to be queried for mutexes", Palette.Wait);
                    proc = Process.GetProcessById(int.Parse(procId));

                    ConsoleU.WriteLine($"Trying to query for any mutex's existance", Palette.Wait);
                    for (int j = 0; j < data.Parameters.Length; j++)
                    {
                        string m      = data.Parameters[j];
                        string prefix = $"({j + 1}/{data.Parameters.Length}) ";
                        ConsoleU.WriteLine(prefix + "Trying to kill mutex: " + m, Palette.Feedback);

                        if (!ProcessUtil.KillMutex(proc, m))
                        {
                            ConsoleU.WriteLine(prefix + "Mutex " + m + " could not be killed", Palette.Error);
                        }
                        else
                        {
                            ConsoleU.WriteLine(prefix + "Mutex killed " + m, Palette.Success);
                        }
                        Thread.Sleep(150);
                    }
                }
                break;

                case GameStarterTask.FindProcessId:
                {
                    string procId = data.Parameters[0];
                    int    id     = int.Parse(procId);
                    try
                    {
                        proc = Process.GetProcessById(id);
                        ConsoleU.WriteLine($"Process ID {id} found!", Palette.Success);
                    }
                    catch
                    {
                        ConsoleU.WriteLine($"Process ID {id} not found", Palette.Error);
                    }
                }
                break;

                case GameStarterTask.ListMonitors:
                    break;
                }
            }
#if RELEASE
            catch (Exception ex)
            {
                ConsoleU.WriteLine(ex.Message);
            }
#endif
        }
Ejemplo n.º 16
0
        // ========================================
        // method
        // ========================================
        private ContextMenuStrip CreateNotifyIconContextMenu()
        {
            var items = new List <ToolStripItem>(16);

            var newMemo = new ToolStripMenuItem();

            newMemo.Text   = "ノートを作成(&N)";
            newMemo.Click += (sender, e) => {
                CreateMemo();
            };
            items.Add(newMemo);

            var newFusenMemo = new ToolStripMenuItem();

            newFusenMemo.Text   = "付箋ノートを作成(&F)";
            newFusenMemo.Click += (sender, e) => {
                CreateFusenMemo();
            };
            items.Add(newFusenMemo);

            var clipMemo = new ToolStripMenuItem();

            clipMemo.Text   = "ノートにクリップ(&C)";
            clipMemo.Click += (sender, e) => {
                var mainForm = _app.MainForm;
                var hWnd     = User32PI.GetWindow(
                    mainForm.Handle,
                    GetWindowCmd.GW_HWNDFIRST
                    );
                hWnd = User32Util.GetNextWindow(
                    hWnd,
                    handle => {
                    if (User32PI.IsWindowVisible(handle) && !User32Util.IsOwnedWindow(handle))
                    {
                        var cname = User32Util.GetWindowClassName(handle);
                        return
                        (!string.Equals(cname, "Shell_TrayWnd", StringComparison.OrdinalIgnoreCase) &&
                         !string.Equals(cname, "NotifyIconOverflowWindow", StringComparison.OrdinalIgnoreCase));
                    }
                    else
                    {
                        return(false);
                    }
                }
                    );

                var oldTopMost = mainForm.TopMost;
                mainForm.TopMost = false;
                if (hWnd != IntPtr.Zero)
                {
                    User32Util.ActivateWindow(hWnd);
                    Thread.Sleep(1000);
                }
                _app.ClipAndCreateMemo();
                mainForm.TopMost = oldTopMost;
            };
            items.Add(clipMemo);

            var capture = new ToolStripMenuItem();

            capture.Text   = "画面を取り込み(&D)";
            capture.Click += (sender, e) => {
                Thread.Sleep(500);
                _app.CaptureAndCreateMemo();
            };
            items.Add(capture);

            items.Add(new ToolStripSeparator());

            var searchMemo = new ToolStripMenuItem();

            searchMemo.Text   = "ノートを検索(&S)";
            searchMemo.Click += (sender, e) => {
                _app.ShowMainForm();
                _app.ActivateMainForm();
                var form = _app.MainForm;
                if (form != null)
                {
                    form.FocusConditionTextBox();
                }
            };
            items.Add(searchMemo);

            var activate = new ToolStripMenuItem();

            activate.Text   = "アクティブにする(&A)";
            activate.Click += (sender, e) => {
                ShowMainForm();
            };
            items.Add(activate);

            var showAllFusens = new ToolStripMenuItem();

            showAllFusens.Text   = "付箋ノートを表示(&F)";
            showAllFusens.Click += (sender, e) => {
                ShowFusenForms(false);
            };
            items.Add(showAllFusens);

            items.Add(new ToolStripSeparator());

            var action = new ToolStripMenuItem();

            action.Text = "アイコンの動作(&A)";
            items.Add(action);

            {
                var click = new ToolStripMenuItem();
                click.Text = "クリック(&C)";
                action.DropDown.Items.Add(click);
                InitClickSetting(click);
            }
            {
                var dclick = new ToolStripMenuItem();
                dclick.Text = "ダブルクリック(&D)";
                action.DropDown.Items.Add(dclick);

                InitDoubleClickSetting(dclick);
            }

            items.Add(new ToolStripSeparator());

            var exitItem = new ToolStripMenuItem();

            exitItem.Text   = "終了(&X)";
            exitItem.Click += (sender, e) => {
                _app.Exit();
            };
            items.Add(exitItem);

            var ret = new ContextMenuStrip();

            ret.SuspendLayout();
            ret.Items.AddRange(items.ToArray());
            ret.ResumeLayout();
            return(ret);
        }
Ejemplo n.º 17
0
 private void btnShowTaskbar_Click(object sender, EventArgs e)
 {
     User32Util.ShowTaskBar();
 }
Ejemplo n.º 18
0
        public override void Tick(double delayMs)
        {
            exited = 0;
            timer += delayMs;

            bool updatedHwnd = false;

            if (timer > HWndInterval)
            {
                updatedHwnd = true;
                timer       = 0;
            }

            List <PlayerInfo> players = profile.PlayerData;

            //CursorModule cursorModule = handler.GetModule<CursorModule>();

            for (int i = 0; i < players.Count; i++)
            {
                PlayerInfo  p    = players[i];
                ProcessInfo data = p.ProcessData;
                if (data == null)
                {
                    continue;
                }

                if (data.Finished)
                {
                    if (data.Process.HasExited)
                    {
                        exited++;
                    }
                    continue;
                }

                if (updatedHwnd)
                {
                    if (data.Setted)
                    {
                        if (data.Process.HasExited)
                        {
                            exited++;
                            continue;
                        }

                        //data.HWnd.TopMost = true;
                        //if (data.Status == 2) {
                        //    uint lStyle = User32Interop.GetWindowLong(data.HWnd.NativePtr, User32_WS.GWL_STYLE);
                        //    lStyle = lStyle & ~User32_WS.WS_CAPTION;
                        //    lStyle = lStyle & ~User32_WS.WS_THICKFRAME;
                        //    lStyle = lStyle & ~User32_WS.WS_MINIMIZE;
                        //    lStyle = lStyle & ~User32_WS.WS_MAXIMIZE;
                        //    lStyle = lStyle & ~User32_WS.WS_SYSMENU;
                        //    User32Interop.SetWindowLong(data.HWnd.NativePtr, User32_WS.GWL_STYLE, lStyle);

                        //    lStyle = User32Interop.GetWindowLong(data.HWnd.NativePtr, User32_WS.GWL_EXSTYLE);
                        //    lStyle = lStyle & ~User32_WS.WS_EX_DLGMODALFRAME;
                        //    lStyle = lStyle & ~User32_WS.WS_EX_CLIENTEDGE;
                        //    lStyle = lStyle & ~User32_WS.WS_EX_STATICEDGE;
                        //    User32Interop.SetWindowLong(data.HWnd.NativePtr, User32_WS.GWL_EXSTYLE, lStyle);
                        //    User32Interop.SetWindowPos(data.HWnd.NativePtr, IntPtr.Zero, 0, 0, 0, 0, (uint)(PositioningFlags.SWP_FRAMECHANGED | PositioningFlags.SWP_NOMOVE | PositioningFlags.SWP_NOSIZE | PositioningFlags.SWP_NOZORDER | PositioningFlags.SWP_NOOWNERZORDER));
                        //    //User32Interop.SetForegroundWindow(data.HWnd.NativePtr);

                        //    data.Finished = true;
                        //    Debug.WriteLine("State 2");

                        //    if (i == players.Count - 1 && handlerData.Hook.ClipMouse) {
                        //        //last screen setuped
                        //        cursorModule?.SetActiveWindow();
                        //    }
                        //} else if (data.Status == 1) {
                        //    data.HWnd.Location = data.Position;
                        //    data.Status++;
                        //    Debug.WriteLine("State 1");

                        //    if (handlerData.Hook.ClipMouse) {
                        //        if (p.IsKeyboardPlayer) {
                        //            cursorModule?.Setup(data.Process, p.MonitorBounds);
                        //        } else {
                        //            cursorModule?.AddOtherGameHandle(data.Process.MainWindowHandle);
                        //        }
                        //    }
                        //} else if (data.Status == 0) {
                        //    data.HWnd.Size = data.Size;

                        //    data.Status++;
                        //    Debug.WriteLine("State 0");
                        //}
                    }
                    else
                    {
                        data.Process.Refresh();

                        if (data.Process.HasExited)
                        {
                            if (p.GotLauncher)
                            {
                                if (p.GotGame)
                                {
                                    exited++;
                                }
                                else
                                {
                                    List <int> children = ProcessUtil.GetChildrenProcesses(data.Process);
                                    if (children.Count > 0)
                                    {
                                        for (int j = 0; j < children.Count; j++)
                                        {
                                            int     id  = children[j];
                                            Process pro = Process.GetProcessById(id);

                                            if (!attached.Contains(pro))
                                            {
                                                attached.Add(pro);
                                                data.HWnd = null;
                                                p.GotGame = true;
                                                data.AssignProcess(pro);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                // Steam showing a launcher, need to find our game process
                                string launcher = handlerData.LauncherExe;
                                if (!string.IsNullOrEmpty(launcher))
                                {
                                    if (launcher.ToLower().EndsWith(".exe"))
                                    {
                                        launcher = launcher.Remove(launcher.Length - 4, 4);
                                    }

                                    Process[] procs = Process.GetProcessesByName(launcher);
                                    for (int j = 0; j < procs.Length; j++)
                                    {
                                        Process pro = procs[j];
                                        if (!attached.Contains(pro))
                                        {
                                            attached.Add(pro);
                                            data.AssignProcess(pro);
                                            p.GotLauncher = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (data.HWNDRetry || data.HWnd == null || data.HWnd.NativePtr != data.Process.MainWindowHandle)
                            {
                                data.HWnd = new HwndObject(data.Process.MainWindowHandle);
                                Point pos = data.HWnd.Location;

                                var windows = User32Util.EnumerateProcessWindowHandles(data.Process.Id);
                                foreach (IntPtr window in windows)
                                {
                                    HwndObject obj = new HwndObject(window);

                                    if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                        new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(obj.Title))
                                    {
                                        data.HWnd = obj;
                                        break;
                                    }
                                }

                                List <int> children = ProcessUtil.GetChildrenProcesses(data.Process);
                                if (children.Count > 0)
                                {
                                    for (int j = 0; j < children.Count; j++)
                                    {
                                        int     id  = children[j];
                                        Process pro = Process.GetProcessById(id);

                                        var proWindows = User32Util.EnumerateProcessWindowHandles(pro.Id);
                                        foreach (IntPtr window in proWindows)
                                        {
                                            HwndObject obj = new HwndObject(window);

                                            if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                                new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(obj.Title))
                                            {
                                                data.HWnd = obj;
                                                break;
                                            }
                                        }
                                    }
                                }

                                if (String.IsNullOrEmpty(data.HWnd.Title) ||
                                    pos.X == -32000 ||
                                    data.HWnd.Title.ToLower() == handlerData.LauncherTitle.ToLower())
                                {
                                    data.HWNDRetry = true;
                                }
                                else if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                         // TODO: this Levenshtein distance is being used to help us around Call of Duty Black Ops, as it uses a ® icon in the title bar
                                         //       there must be a better way
                                         //StringUtil.ComputeLevenshteinDistance(data.HWnd.Title, handlerData.Hook.ForceFocusWindowRegex) > 2)
                                         !(new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(data.HWnd.Title)))
                                {
                                    /// ?? redundant call??
                                    data.HWNDRetry = true;
                                }
                                else
                                {
                                    Size s = data.Size;
                                    data.Setted = true;
                                }
                            }
                        }
                    }
                }
            }

            if (exited == players.Count)
            {
                handler.End();
            }
        }
Ejemplo n.º 19
0
        //protected override void OnGotFocus(EventArgs e)
        //{
        //    base.OnGotFocus(e);
        //    //this.TopMost = true;
        //    this.BringToFront();

        //    System.Diagnostics.Debug.WriteLine("Got Focus");
        //}
        //private void CheckForManualExit()
        //{
        //    while (true)
        //    {
        //        //you need to use Invoke because the new thread can't access the UI elements directly
        //        MethodInvoker mi = delegate () { if (handler == null) { GoToStep(0); this.Controls.Clear(); this.InitializeComponent(); RefreshGames(); t.Abort(); } };
        //        this.Invoke(mi);
        //        Thread.Sleep(500);
        //    }
        //}

        //protected override void OnDeactivate(EventArgs e)
        //{
        //    if (t != null && t.IsAlive)
        //        t.Abort();
        //}

        //protected override void OnActivated(EventArgs e)
        //{

        //    if (btn_Play.Text == "S T O P")
        //    {
        //        if (handler == null)
        //        {
        //            ////MessageBox.Show("handle not null and has ended");
        //            ////SetBtnToPlay();
        //            //if (handlerThread != null)
        //            //{
        //            //    handlerThread.Abort();
        //            //    handlerThread = null;
        //            //}
        //            ////list_Games_SelectedChanged(null, null);
        //            //RefreshGames();
        //            //Invoke(new Action(SetBtnToPlay));
        //            //btn_Play.Enabled = false;
        //            GoToStep(0);
        //            this.Controls.Clear();
        //            this.InitializeComponent();
        //            RefreshGames();
        //        }
        //        else
        //        {
        //            //btn_Play.Enabled = false;
        //            t = new System.Threading.Thread(CheckForManualExit);
        //            t.Start();
        //        }
        //    }
        //}

        protected override void WndProc(ref Message m)
        {
            //int msg = m.Msg;
            //LogManager.Log(msg.ToString());
            if (m.Msg == 0x0312 && m.WParam.ToInt32() == KillProcess_HotkeyID)
            {
                //System.Diagnostics.Process.GetCurrentProcess().Kill();
                Close();
            }
            else if (m.Msg == 0x0312 && m.WParam.ToInt32() == TopMost_HotkeyID)
            {
                if (TopMostToggle && handler != null)
                {
                    try
                    {
                        Process[] procs = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(currentGame.ExecutableName.ToLower()));
                        if (procs.Length > 0)
                        {
                            for (int i = 0; i < procs.Length; i++)
                            {
                                IntPtr hWnd = procs[i].MainWindowHandle;
                                User32Interop.SetWindowPos(hWnd, new IntPtr(-2), 0, 0, 0, 0, (uint)(PositioningFlags.SWP_NOSIZE | PositioningFlags.SWP_NOMOVE));
                                ShowWindow(hWnd, ShowWindowEnum.Minimize);
                            }
                        }
                    }
                    catch { }
                    User32Util.ShowTaskBar();
                    //currentGame.LockMouse = false;
                    this.Activate();
                    this.BringToFront();
                    TopMostToggle = false;
                }
                else if (!TopMostToggle && handler != null)
                {
                    Process[] procs = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(currentGame.ExecutableName.ToLower()));
                    if (procs.Length > 0)
                    {
                        for (int i = 0; i < procs.Length; i++)
                        {
                            IntPtr hWnd = procs[i].MainWindowHandle;
                            ShowWindow(hWnd, ShowWindowEnum.Restore);
                            User32Interop.SetWindowPos(hWnd, new IntPtr(-1), 0, 0, 0, 0, (uint)(PositioningFlags.SWP_NOSIZE | PositioningFlags.SWP_NOMOVE));
                        }
                    }
                    User32Util.HideTaskbar();
                    //currentGame.LockMouse = true;
                    //this.Activate();
                    //this.BringToFront();
                    TopMostToggle = true;
                }
            }
            else if (m.Msg == 0x0312 && m.WParam.ToInt32() == StopSession_HotkeyID)
            {
                if (btn_Play.Text == "S T O P")
                {
                    WindowState = FormWindowState.Normal;
                    this.BringToFront();
                    btn_Play.PerformClick();
                }
            }
            base.WndProc(ref m);
        }
Ejemplo n.º 20
0
        public override void Tick(double delayMs)
        {
            exited = 0;
            timer += delayMs;

            bool updatedHwnd = false;

            if (timer > HWndInterval)
            {
                updatedHwnd = true;
                timer       = 0;
            }

            List <PlayerInfo> players = profile.PlayerData;

            //CursorModule cursorModule = handler.GetModule<CursorModule>();

            for (int i = 0; i < players.Count; i++)
            {
                PlayerInfo  p    = players[i];
                ProcessInfo data = p.ProcessData;
                if (data == null)
                {
                    continue;
                }

                if (data.Finished)
                {
                    if (data.Process.HasExited)
                    {
                        exited++;
                    }
                    continue;
                }

                if (updatedHwnd)
                {
                    if (data.Setted)
                    {
                        if (data.Process.HasExited)
                        {
                            exited++;
                            continue;
                        }
                    }
                    else
                    {
                        data.Process.Refresh();

                        if (data.Process.HasExited)
                        {
                            if (p.GotLauncher)
                            {
                                if (p.GotGame)
                                {
                                    exited++;
                                }
                                else
                                {
                                    List <int> children = ProcessUtil.GetChildrenProcesses(data.Process);
                                    if (children.Count > 0)
                                    {
                                        for (int j = 0; j < children.Count; j++)
                                        {
                                            int     id  = children[j];
                                            Process pro = Process.GetProcessById(id);

                                            if (!attached.Contains(pro))
                                            {
                                                attached.Add(pro);
                                                data.HWnd = null;
                                                p.GotGame = true;
                                                data.AssignProcess(pro);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                // Steam showing a launcher, need to find our game process
                                string launcher = handlerData.LauncherExe;
                                if (!string.IsNullOrEmpty(launcher))
                                {
                                    if (launcher.ToLower().EndsWith(".exe"))
                                    {
                                        launcher = launcher.Remove(launcher.Length - 4, 4);
                                    }

                                    Process[] procs = Process.GetProcessesByName(launcher);
                                    for (int j = 0; j < procs.Length; j++)
                                    {
                                        Process pro = procs[j];
                                        if (!attached.Contains(pro))
                                        {
                                            attached.Add(pro);
                                            data.AssignProcess(pro);
                                            p.GotLauncher = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (data.HWNDRetry || data.HWnd == null || data.HWnd.NativePtr != data.Process.MainWindowHandle)
                            {
                                data.HWnd = new HwndObject(data.Process.MainWindowHandle);
                                Point pos = data.HWnd.Location;

                                var windows = User32Util.EnumerateProcessWindowHandles(data.Process.Id);
                                foreach (IntPtr window in windows)
                                {
                                    HwndObject obj = new HwndObject(window);

                                    if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                        new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(obj.Title))
                                    {
                                        data.HWnd = obj;
                                        break;
                                    }
                                }

                                List <int> children = ProcessUtil.GetChildrenProcesses(data.Process);
                                if (children.Count > 0)
                                {
                                    for (int j = 0; j < children.Count; j++)
                                    {
                                        int     id  = children[j];
                                        Process pro = Process.GetProcessById(id);

                                        var proWindows = User32Util.EnumerateProcessWindowHandles(pro.Id);
                                        foreach (IntPtr window in proWindows)
                                        {
                                            HwndObject obj = new HwndObject(window);

                                            if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                                new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(obj.Title))
                                            {
                                                data.HWnd = obj;
                                                break;
                                            }
                                        }
                                    }
                                }

                                if (String.IsNullOrEmpty(data.HWnd.Title) ||
                                    pos.X == -32000 ||
                                    data.HWnd.Title.ToLower() == handlerData.LauncherTitle.ToLower())
                                {
                                    data.HWNDRetry = true;
                                }
                                else if (!string.IsNullOrEmpty(handlerData.Hook.ForceFocusWindowRegex) &&
                                         // TODO: this Levenshtein distance is being used to help us around Call of Duty Black Ops, as it uses a ® icon in the title bar
                                         //       there must be a better way
                                         //StringUtil.ComputeLevenshteinDistance(data.HWnd.Title, handlerData.Hook.ForceFocusWindowRegex) > 2)
                                         !(new Regex(handlerData.Hook.ForceFocusWindowRegex).IsMatch(data.HWnd.Title)))
                                {
                                    /// ?? redundant call??
                                    data.HWNDRetry = true;
                                }
                                else
                                {
                                    Size s = data.Size;
                                    data.Setted = true;
                                }
                            }
                        }
                    }
                }
            }

            if (exited == players.Count)
            {
                handler.End();
            }
        }
Ejemplo n.º 21
0
 public static void PreInitialize()
 {
     Scale = User32Util.GetDPIScalingFactor();
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            if (args.Length == 0)
            {
                ConsoleU.WriteLine("Invalid usage! Need arguments to proceed!", Palette.Error);
                return;
            }

#if RELEASE
            try
#endif
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    ConsoleU.WriteLine("Parsing line " + i + ": " + arg, Palette.Feedback);

                    string argument = "";
                    for (int j = i; j < args.Length; j++)
                    {
                        string skey = args[j];
                        if (!skey.Contains("monitors") &&
                            !skey.Contains("game") &&
                            !skey.Contains("mutex") &&
                            !skey.Contains("proc") &&
                            !skey.Contains("output"))
                        {
                            i++;
                            if (string.IsNullOrEmpty(argument))
                            {
                                argument = skey;
                            }
                            else
                            {
                                argument = argument + " " + skey;
                            }
                        }
                    }
                    ConsoleU.WriteLine("Extra arguments:" + argument, Palette.Feedback);

                    string[] splited = (arg + argument).Split(':');
                    string   key     = splited[0].ToLower();

                    if (key.Contains("monitors"))
                    {
                    }
                    else if (key.Contains("game"))
                    {
                        string   data    = splited[1];
                        string[] subArgs = data.Split(';');
                        string   path    = subArgs[0];

                        string argu = null;
                        if (subArgs.Length > 1)
                        {
                            argu = subArgs[1];
                        }

                        string workingDir = null;
                        if (path.Contains("|"))
                        {
                            string[] div = path.Split('|');
                            path       = div[0];
                            workingDir = div[1];
                        }

                        ConsoleU.WriteLine($"Start game: EXE: {path} ARGS: {argu} WORKDIR: {workingDir}", Palette.Feedback);
                        StartGame(path, argu, workingDir);
                    }
                    else if (key.Contains("mutex"))
                    {
                        string[] mutex = splited[1].Split(';');
                        ConsoleU.WriteLine("Trying to kill mutexes", Palette.Wait);
                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Trying to kill mutex: " + m, Palette.Feedback);

                            if (!ProcessUtil.KillMutex(proc, m))
                            {
                                ConsoleU.WriteLine("Mutex " + m + " could not be killed", Palette.Error);
                            }
                            else
                            {
                                ConsoleU.WriteLine("Mutex killed " + m, Palette.Success);
                            }
                            Thread.Sleep(150);
                        }
                    }
                    else if (key.Contains("proc"))
                    {
                        string procId = splited[1];
                        int    id     = int.Parse(procId);
                        try
                        {
                            proc = Process.GetProcessById(id);
                            ConsoleU.WriteLine($"Process ID {id} found!", Palette.Success);
                        }
                        catch
                        {
                            ConsoleU.WriteLine($"Process ID {id} not found", Palette.Error);
                        }
                    }
                    else if (key.Contains("output"))
                    {
                        string[] mutex = splited[1].Split(';');
                        bool     all   = true;

                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Requested mutex: " + m, Palette.Error);
                            bool exists = ProcessUtil.MutexExists(proc, m);
                            if (!exists)
                            {
                                all = false;
                            }

                            Thread.Sleep(500);
                        }
                        Console.WriteLine(all.ToString());
                    }
                }
            }
#if RELEASE
            catch (Exception ex)
            {
                ConsoleU.WriteLine(ex.Message);
            }
#endif
        }
Ejemplo n.º 23
0
 private static void ActivateMochaNote()
 {
     User32Util.ActivateWindow(null, TargetWindowTitle, TargetExeFilename);
 }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            if (args.Length == 0)
            {
                Console.WriteLine("Invalid usage! Need arguments to proceed!");
                return;
            }

            try
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string   arg     = args[i];
                    string[] splited = arg.Split(':');

                    string key = splited[0].ToLower();

                    switch (key)
                    {
                    case "monitors":
                    {
                        // enumerates and outputs monitors in JSON
                    }
                    break;

                    case "game":
                    {
                        string[] arguments = (splited[1] + ":" + splited[2]).Split(';');
                        string   path      = arguments[0];

                        string argu = "";
                        if (arguments.Length > 1)
                        {
                            argu = arguments[1];
                        }
                        StartGame(path, argu);
                    }
                    break;

                    case "mutex":
                    {
                        string[] mutex = splited[1].Split(';');
                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            if (!ProcessUtil.KillMutex(proc, m))
                            {
                                Console.WriteLine("Mutex " + m + " could not be killed");
                            }
                            Thread.Sleep(500);
                        }
                    }
                    break;

                    case "proc":
                    {
                        string procId = splited[1];
                        int    id     = int.Parse(procId);
                        proc = Process.GetProcessById(id);
                    }
                    break;

                    case "output":
                    {
                        string[] mutex = splited[1].Split(';');
                        bool     all   = true;

                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m      = mutex[j];
                            bool   exists = ProcessUtil.MutexExists(proc, m);
                            if (!exists)
                            {
                                all = false;
                            }

                            Console.WriteLine("Mutex " + m + (exists ? " exists" : " doesn't exist"));
                            Thread.Sleep(500);
                        }
                        Console.WriteLine(all.ToString());
                    }
                    break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            if (args.Length == 0)
            {
                ConsoleU.WriteLine("Invalid usage! Need arguments to proceed!", Palette.Error);
                return;
            }

#if RELEASE
            try
#endif
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    ConsoleU.WriteLine("Parsing line " + i + ": " + arg, Palette.Feedback);
                    //Log(string.Format("Parsing line {0}: {1}", i, arg));

                    string argument = "";
                    for (int j = i; j < args.Length; j++)
                    {
                        string skey = args[j];
                        if (!skey.Contains("monitors") &&
                            !skey.Contains("game") &&
                            !skey.Contains("partialmutex") &&
                            !skey.Contains("mutextype") &&
                            !skey.Contains("mutex") &&
                            !skey.Contains("proc") &&
                            !skey.Contains("hook") &&
                            !skey.Contains("delay") &&
                            !skey.Contains("renamemutex") &&
                            !skey.Contains("mutextorename") &&
                            !skey.Contains("setwindow") &&
                            !skey.Contains("isdebug") &&
                            !skey.Contains("nucleusfolderpath") &&
                            !skey.Contains("blockraw")
                            //&& !skey.Contains("rawhid")
                            && !skey.Contains("output"))
                        {
                            i++;
                            if (string.IsNullOrEmpty(argument))
                            {
                                argument = skey;
                            }
                            else
                            {
                                argument = argument + " " + skey;
                            }
                        }
                    }
                    //Log("Extra arguments:" + argument);
                    ConsoleU.WriteLine("Extra arguments:" + argument, Palette.Feedback);

                    string[] splited = (arg + argument).Split(new string[] { "|::|" }, StringSplitOptions.None);
                    string   key     = splited[0].ToLower();

                    if (key.Contains("monitors"))
                    {
                    }
                    else if (key.Contains("hook"))
                    {
                        isHook = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("delay"))
                    {
                        isDelay = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("renamemutex"))
                    {
                        renameMutex = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("mutextorename"))
                    {
                        mutexToRename = splited[1];
                    }
                    else if (key.Contains("partialmutex"))
                    {
                        partialMutex = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("setwindow"))
                    {
                        setWindow = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("isdebug"))
                    {
                        isDebug = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("nucleusfolderpath"))
                    {
                        nucleusFolderPath = splited[1];
                    }
                    else if (key.Contains("blockraw"))
                    {
                        blockRaw = Boolean.Parse(splited[1]);
                    }
                    //else if (key.Contains("rawhid"))
                    //{
                    //    rawHid = splited[1];
                    //}
                    else if (key.Contains("game"))
                    {
                        string   data    = splited[1];
                        string[] subArgs = data.Split(';');
                        string   path    = subArgs[0];

                        string argu = null;
                        if (subArgs.Length > 1)
                        {
                            argu = subArgs[1];
                        }

                        string workingDir = null;
                        if (path.Contains("|"))
                        {
                            string[] div = path.Split('|');
                            path       = div[0];
                            workingDir = div[1];
                        }
                        Log($"EXE: {path} ARGS: {argu} WORKDIR: {workingDir}");
                        ConsoleU.WriteLine($"Start game: EXE: {path} ARGS: {argu} WORKDIR: {workingDir}", Palette.Feedback);
                        StartGame(path, argu, workingDir);
                    }
                    else if (key.Contains("mutextype"))
                    {
                        mt = splited[1];
                    }
                    else if (key.Contains("mutex"))
                    {
                        string[] mutex = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                        ConsoleU.WriteLine("Trying to kill mutexes", Palette.Wait);
                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Trying to kill mutex: " + m, Palette.Feedback);
                            if (!ProcessUtil.KillMutex(proc, mt, m, partialMutex))
                            {
                                ConsoleU.WriteLine("Mutex " + m + " could not be killed", Palette.Error);
                            }
                            else
                            {
                                ConsoleU.WriteLine("Mutex killed " + m, Palette.Success);
                            }
                            Thread.Sleep(150);
                        }
                    }
                    else if (key.Contains("proc"))
                    {
                        string procId = splited[1];
                        int    id     = int.Parse(procId);
                        try
                        {
                            proc = Process.GetProcessById(id);
                            ConsoleU.WriteLine($"Process ID {id} found!", Palette.Success);
                        }
                        catch
                        {
                            ConsoleU.WriteLine($"Process ID {id} not found", Palette.Error);
                        }
                    }
                    else if (key.Contains("output"))
                    {
                        string[] mutex = splited[1].Split(';');
                        bool     all   = true;

                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Requested mutex: " + m, Palette.Error);
                            bool exists = ProcessUtil.MutexExists(proc, mt, m, partialMutex);
                            if (!exists)
                            {
                                all = false;
                            }

                            Thread.Sleep(500);
                        }
                        Console.WriteLine(all.ToString());
                    }
                }
            }
#if RELEASE
            catch (Exception ex)
            {
                ConsoleU.WriteLine(ex.Message);
            }
#endif
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            // We need this, else Windows will fake
            // all the data about monitors inside the application
            User32Util.SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);

            if (args.Length == 0)
            {
                ConsoleU.WriteLine("Invalid usage! Need arguments to proceed!", Palette.Error);
                return;
            }

#if RELEASE
            try
#endif
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    ConsoleU.WriteLine("Parsing line " + i + ": " + arg, Palette.Feedback);
                    //Log(string.Format("Parsing line {0}: {1}", i, arg));

                    string argument = "";
                    for (int j = i; j < args.Length; j++)
                    {
                        string skey = args[j];
                        if (!skey.Contains("monitors") &&
                            !skey.Contains("game") &&
                            !skey.Contains("partialmutex") &&
                            !skey.Contains("mutextype") &&
                            !skey.Contains("mutex") &&
                            !skey.Contains("proc") &&
                            !skey.Contains("hook") &&
                            !skey.Contains("delay") &&
                            !skey.Contains("renamemutex") &&
                            !skey.Contains("mutextorename") &&
                            !skey.Contains("setwindow") &&
                            !skey.Contains("width") &&
                            !skey.Contains("height") &&
                            !skey.Contains("posx") &&
                            !skey.Contains("posy") &&
                            !skey.Contains("isdebug") &&
                            !skey.Contains("nucleusfolderpath") &&
                            !skey.Contains("blockraw") &&
                            !skey.Contains("nucenv") &&
                            !skey.Contains("playernick") &&
                            !skey.Contains("starthks") &&
                            !skey.Contains("root") &&
                            !skey.Contains("destination") &&
                            !skey.Contains("direxclusions") &&
                            !skey.Contains("fileexclusions") &&
                            !skey.Contains("filecopyinstead") &&
                            !skey.Contains("hardlink") &&
                            !skey.Contains("symfolder") &&
                            !skey.Contains("numplayers") &&
                            !skey.Contains("symlink")
                            //&& !skey.Contains("rawhid")
                            && !skey.Contains("createsingle") &&
                            !skey.Contains("rawhid") &&
                            !skey.Contains("docpath") &&
                            !skey.Contains("usedocs") &&
                            !skey.Contains("output"))


                        {
                            i++;
                            if (string.IsNullOrEmpty(argument))
                            {
                                argument = skey;
                            }
                            else
                            {
                                argument = argument + " " + skey;
                            }
                        }
                    }
                    //Log("Extra arguments:" + argument);
                    ConsoleU.WriteLine("Extra arguments:" + argument, Palette.Feedback);


                    string[] splited = (arg + argument).Split(new string[] { "|::|" }, StringSplitOptions.None);
                    string   key     = splited[0].ToLower();
                    //Log("key " + key);

                    if (key.Contains("monitors"))
                    {
                    }
                    else if (key.Contains("hook"))
                    {
                        isHook = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("delay"))
                    {
                        isDelay = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("renamemutex"))
                    {
                        renameMutex = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("mutextorename"))
                    {
                        mutexToRename = splited[1];
                    }
                    else if (key.Contains("partialmutex"))
                    {
                        partialMutex = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("setwindow"))
                    {
                        setWindow = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("width"))
                    {
                        width = Int32.Parse(splited[1]);
                    }
                    else if (key.Contains("height"))
                    {
                        height = Int32.Parse(splited[1]);
                    }
                    else if (key.Contains("posx"))
                    {
                        posx = Int32.Parse(splited[1]);
                    }
                    else if (key.Contains("posy"))
                    {
                        posy = Int32.Parse(splited[1]);
                    }
                    else if (key.Contains("docpath"))
                    {
                        DocumentsRoot = splited[1];
                    }
                    else if (key.Contains("usedocs"))
                    {
                        useDocs = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("isdebug"))
                    {
                        isDebug = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("nucleusfolderpath"))
                    {
                        nucleusFolderPath = splited[1];
                    }
                    else if (key.Contains("blockraw"))
                    {
                        blockRaw = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("createsingle"))
                    {
                        createSingle = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("rawhid"))
                    {
                        rawHid = splited[1];
                    }
                    else if (key.Contains("nucenv"))
                    {
                        useNucleusEnvironment = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("playernick"))
                    {
                        playerNick = splited[1];
                    }
                    else if (key.Contains("starthks"))
                    {
                        useStartupHooks = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("root"))
                    {
                        root = splited[1];
                    }
                    else if (key.Contains("currentdir"))
                    {
                        currentDir = splited[1];
                    }
                    else if (key.Contains("destination"))
                    {
                        destination = splited[1].Substring(0, splited[1].LastIndexOf('\\'));
                    }
                    else if (key.Contains("direxclusions"))
                    {
                        dirExclusions = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                    }
                    else if (key.Contains("fileexclusions"))
                    {
                        fileExclusions = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                    }
                    else if (key.Contains("filecopyinstead"))
                    {
                        fileCopyInstead = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                    }
                    else if (key.Contains("hardlink"))
                    {
                        hardLink = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("symfolder"))
                    {
                        symFolders = Boolean.Parse(splited[1]);
                    }
                    else if (key.Contains("numplayers"))
                    {
                        numPlayers = int.Parse(splited[1]);
                    }
                    else if (key.Contains("symlink"))
                    {
                        int exitCode = 1;
                        for (int p = 0; p < numPlayers; p++)
                        {
                            Nucleus.Gaming.Platform.Windows.IO.WinDirectoryUtil.LinkDirectory(root, new DirectoryInfo(root), destination + "\\Instance" + p, out exitCode, dirExclusions, fileExclusions, fileCopyInstead, hardLink, symFolders);
                        }
                    }
                    //else if (key.Contains("rawhid"))
                    //{
                    //    rawHid = splited[1];
                    //}
                    else if (key.Contains("game"))
                    {
                        string   data    = splited[1];
                        string[] subArgs = data.Split(';');
                        string   path    = subArgs[0];

                        string argu = null;
                        if (subArgs.Length > 1)
                        {
                            argu = subArgs[1];
                        }

                        string workingDir = null;
                        if (path.Contains("|"))
                        {
                            string[] div = path.Split('|');
                            path       = div[0];
                            workingDir = div[1];
                        }

                        Log($"EXE: {path} ARGS: {argu} WORKDIR: {workingDir}");
                        ConsoleU.WriteLine($"Start game: EXE: {path} ARGS: {argu} WORKDIR: {workingDir}", Palette.Feedback);
                        StartGame(path, argu, workingDir);
                    }
                    else if (key.Contains("mutextype"))
                    {
                        mt = splited[1];
                    }
                    else if (key.Contains("mutex"))
                    {
                        string[] mutex = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                        ConsoleU.WriteLine("Trying to kill mutexes", Palette.Wait);
                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Trying to kill mutex: " + m, Palette.Feedback);
                            if (!ProcessUtil.KillMutex(proc, mt, m, partialMutex))
                            {
                                ConsoleU.WriteLine("Mutex " + m + " could not be killed", Palette.Error);
                            }
                            else
                            {
                                ConsoleU.WriteLine("Mutex killed " + m, Palette.Success);
                            }
                            Thread.Sleep(150);
                        }
                    }
                    else if (key.Contains("proc"))
                    {
                        string procId = splited[1];
                        int    id     = int.Parse(procId);
                        try
                        {
                            proc = Process.GetProcessById(id);
                            Log(string.Format($"Process ID {id} found!"));
                            ConsoleU.WriteLine($"Process ID {id} found!", Palette.Success);
                        }
                        catch
                        {
                            Log(string.Format($"Process ID {id} not found"));
                            ConsoleU.WriteLine($"Process ID {id} not found", Palette.Error);
                        }
                    }
                    else if (key.Contains("output"))
                    {
                        string[] mutex = splited[1].Split(new string[] { "|==|" }, StringSplitOptions.None);
                        bool     all   = true;

                        for (int j = 0; j < mutex.Length; j++)
                        {
                            string m = mutex[j];
                            ConsoleU.WriteLine("Requested mutex: " + m, Palette.Error);
                            bool exists = ProcessUtil.MutexExists(proc, mt, m, partialMutex);
                            if (!exists)
                            {
                                all = false;
                            }

                            Thread.Sleep(500);
                        }
                        Console.WriteLine(all.ToString());
                    }
                }
            }
#if RELEASE
            catch (Exception ex)
            {
                ConsoleU.WriteLine(ex.Message);
            }
#endif
        }