예제 #1
0
        private void RunReport(string reportName, string path, Action findReport, Action reportParameters, int numRetries = 3)
        {
            if (!EnoughRetries(numRetries))
            {
                return;
            }

            CloseInfoManager();
            if (GetInfoManager() == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager...Giving Up");
                return;
            }
            Thread.Sleep(1000);

            findReport.Invoke();
            Input.PressKey(Input.KEY_TAB);
            Thread.Sleep(500);
            Input.PressKey(Input.KEY_ENTER);
            Thread.Sleep(5000);

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Loading " + reportName + ", will save to " + path);

            HwndObject parameters = null;
            HwndObject report     = null;

            if (!InitializeReport(out parameters, out report, reportName))
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Trying again...");
                RunReport(reportName, path, findReport, reportParameters, numRetries - 1);
                return;
            }
            Thread.Sleep(5000);

            reportParameters.Invoke();

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Requesting Report");

            Stopwatch watch = Stopwatch.StartNew();

            while (report.GetChildren()[0].GetChildren().Count == 0)
            {
                Console.WriteLine("Waiting... (" + watch.ElapsedMilliseconds + ")");
                Thread.Sleep(3000);
            }
            watch.Stop();

            Console.ForegroundColor = Colors.Success;
            Console.WriteLine("Report Generated");

            SaveReport(path);

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Report Processed");

            report.CloseWindow();
        }
예제 #2
0
        public static WindowInfo GetWindow(string windowTitle, Size screenSize)
        {
            HwndObject window = HwndObject.GetWindowByTitle(windowTitle);

            if (window == null)
            {
                throw new ApplicationException(string.Format("Window '{0}' not found", windowTitle));
            }

            var parts = window.Title.Split('-');

            Bitmap   bitmap         = new Bitmap(screenSize.Width, screenSize.Height);
            Graphics memoryGraphics = Graphics.FromImage(bitmap);
            IntPtr   dc             = memoryGraphics.GetHdc();
            bool     success        = Win32.PrintWindow(window.Hwnd, dc, 0);

            memoryGraphics.ReleaseHdc(dc);

            return(new WindowInfo
            {
                Title = window.Title,
                TableName = parts.Length > 2 ? parts[2].Trim() : window.Title,
                Size = window.Size,
                Bitmap = bitmap
            });
        }
예제 #3
0
 protected string GetTitle(HwndObject hwndObj)
 {
     //String title = ""; //= hwndObj.GetOwner().Hwnd.ToString() + "_";
     //title += "0x" + ((int)hwndObj.Info.dwStyle).ToString("X8") + "_";
     //title += "0x" + ((int)hwndObj.Info.dwExStyle).ToString("X8") + "_";
     return(hwndObj.Title); //title + hwndObj.Title;
 }
예제 #4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (running)
     {
         delay += timer1.Interval;
         if (delay > (int)this.delayUpDown.Value * 1000)
         {
             for (int i = 0; i < Players.Count; i++)
             {
                 PlayerInfo p    = Players[i];
                 HwndObject hwnd = new HwndObject(p.Process.MainWindowHandle);
                 if (theresBigger && biggerPlayer == i && p.ScreenType == ScreenType.FullScreen && this.check_WindowedFullscreen.Checked ||
                     !theresBigger && p.ScreenType == ScreenType.FullScreen && this.check_WindowedFullscreen.Checked)
                 {
                     hwnd.Location = p.Location;
                 }
                 else
                 {
                     hwnd.Location = new Point(p.Location.X - 3, p.Location.Y - TitleHeight);
                 }
                 hwnd.Title = "Borderlands 2 PC Co-Op";
             }
         }
     }
 }
예제 #5
0
        public String PrintWindow(int number)
        {
            HwndObject pr        = images[number];
            Bitmap     bmp       = new Bitmap(pr.Size.Width, pr.Size.Height, PixelFormat.Format32bppArgb);
            Graphics   gfxBmp    = Graphics.FromImage(bmp);
            IntPtr     hdcBitmap = gfxBmp.GetHdc();

            PrintWindow(pr.Hwnd, hdcBitmap, 0);
            gfxBmp.ReleaseHdc(hdcBitmap);
            gfxBmp.Dispose();

            MemoryStream ms = new MemoryStream();
            String       r  = Convert.ToBase64String(ms.ToArray());

            bmp.Save(ms, ImageFormat.Jpeg);
            if (lastImage == r)
            {
                return("0");                //doesn't work... yet
            }
            else
            {
                lastImage = r;
                return(r);
            }
        }
예제 #6
0
        private bool InitializeReport(out HwndObject parameters, out HwndObject report, string reportName)
        {
            parameters = null;
            report     = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                if (o.Title.Equals(reportName))
                {
                    report = o;
                }
                else if (o.Title.Equals("Enter Parameter Values"))
                {
                    parameters = o;
                }
            }

            if (parameters == null || report == null)
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Not enough time to find these windows.");
                return(false);
            }

            return(true);
        }
예제 #7
0
        public HwndObject GetInfoManager() // TODO: make this a retryable action
        {
            foreach (HwndObject o in getMainContainer().GetChildren())
            {
                Console.ForegroundColor = Colors.Message;
                if (o.Title.StartsWith("Info Manager"))
                {
                    Stuff.WriteConsoleMessage("Info Manager already opened");
                    return(o);
                }
            }

            Stuff.WriteConsoleMessage("Info Manager not opened...");
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_A);
            Thread.Sleep(1000);
            Input.PressKey(Input.KEY_I);
            Thread.Sleep(1000);
            HwndObject infoManager = GetInfoManager();

            if (infoManager == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager");
            }
            return(infoManager);
        }
예제 #8
0
 public static void ScanWindows()
 {
     foreach (HwndObject o in HwndObject.GetWindows())
     {
         Console.WriteLine(GetHwndInfoString(o));
     }
 }
예제 #9
0
        /// <summary>
        /// Tries 5 times to get a HwndObject corresponding to Paint's window. Returns true if one was found, false (and null) otherwise.
        /// </summary>
        /// <param name="obj">The HwndObject found</param>
        static bool ForceGetPaintHwnd(out HwndObject obj)
        {
            const int MaxTries = 5;

            List <HwndObject> list = HwndObject.GetWindows();
            int i = 0;

            while (true)
            {
                if (GetPaintHwnd(out obj))
                {
                    Console.ForegroundColor = Colors.Success;
                    Console.WriteLine("[Program] Found (hopefully) paint window: " + obj.Text);
                    return(true);
                }

                if (++i >= MaxTries)
                {
                    Console.WriteLine(String.Concat("[Program] (", i, ')', " No Paint window found. Not retrying #yolo"));
                    obj = null;
                    return(false);
                }
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine(String.Concat("[Program] (", i, ")", "No Paint window found. Retrying in 1s..."));
                Thread.Sleep(1000);
            }
        }
예제 #10
0
 private void setValueControlByHandle(Process p, int ID, string valueIP)
 {
     try
     {
         int num2;
         Thread.Sleep(0x3e8);
         IntPtr            mainWindowHandle = p.MainWindowHandle;
         List <HwndObject> windows          = HwndObject.GetWindows();
         int num = -1;
         for (num2 = 0; num2 < windows.Count; num2++)
         {
             if (windows[num2].Hwnd == mainWindowHandle)
             {
                 num = num2;
                 break;
             }
         }
         List <HwndObject> children = windows[num].GetChildren();
         int num3 = -1;
         for (num2 = 0; num2 < children.Count; num2++)
         {
             if (GetDlgCtrlID(children[num2].Hwnd) == ID)
             {
                 num3 = num2;
                 break;
             }
         }
         children[num3].Text = valueIP;
     }
     catch (Exception exception)
     {
         CtlError.WriteError("ErroLog", "setValueControlByHandle Loi khi set handle tren form", exception.Message);
     }
 }
예제 #11
0
 private IntPtr GetValueControlByHandle(Process p, int ID, string title)
 {
     try
     {
         Thread.Sleep(0x3e8);
         IntPtr            mainWindowHandle = p.MainWindowHandle;
         List <HwndObject> children         = HwndObject.GetWindowByTitle(title).GetChildren();
         IntPtr            zero             = IntPtr.Zero;
         int num2 = -1;
         for (int i = 0; i < children.Count; i++)
         {
             if (GetDlgCtrlID(children[i].Hwnd) == ID)
             {
                 num2 = i;
                 zero = children[i].Hwnd;
                 break;
             }
         }
         return(zero);
     }
     catch (Exception exception)
     {
         CtlError.WriteError("ErroLog", "get ValueControlByHandle by title Loi khi set handle tren form", exception.Message);
         return(IntPtr.Zero);
     }
 }
예제 #12
0
        public int setProcess(IntPtr i)
        {
            HwndObject hw = new HwndObject(i);

            pnumber++;
            images.Add(pnumber, hw);
            return(pnumber);
        }
예제 #13
0
        protected bool UpdateAppWinData(AppWinData appWinData, HwndObject hwndObj)
        {
            string title = GetTitle(hwndObj);

            appWinData.IsPresent = true;
            appWinData.WinTitle  = title;
            return(hwndObj.ResetPosition());
        }
예제 #14
0
 private void refreshWindowButton_Click(object sender, EventArgs e)
 {
     handle           = HwndObject.GetWindowByTitle(windowsComboBox.Text);
     widthField.Text  = handle.Size.Width.ToString();
     heightField.Text = handle.Size.Height.ToString();
     xField.Text      = handle.Location.X.ToString();
     yField.Text      = handle.Location.Y.ToString();
 }
예제 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="appData"></param>
 /// <param name="hwndObj"></param>
 /// <returns>true if a new AppWinData object was created</returns>
 protected bool AddOrUpdateAppWinData(AppData appData, HwndObject hwndObj)
 {
     if (appData.Windows.ContainsKey(hwndObj))
     {
         return(UpdateAppWinData(appData.Windows[hwndObj], hwndObj));
     }
     appData.Windows.Add(hwndObj, CreateAppWinData(hwndObj));
     return(true);
 }
예제 #16
0
 public static int GetWindowCount(params WindowExtractor[] tableNameExtractors)
 {
     return(tableNameExtractors
            .SelectMany(extractor => HwndObject
                        .GetWindows()
                        .Select(w => extractor.Extractor(w.Title))
                        .Where(n => !string.IsNullOrEmpty(n)))
            .Count());
 }
예제 #17
0
 protected bool IsHwndSelectable(HwndObject hwndObj)
 {
     // neither the owner of a window nor the dimension of a 0x0 would change during its lifetime
     if (hwndObj.GetOwner().Hwnd.ToInt32() != 0 || hwndObj.Rect.Width == 0 || hwndObj.Rect.Height == 0)
     {
         return(false);
     }
     hwndObj.ResetInfo();
     return(hwndObj.Info.IsVisible());
 }
예제 #18
0
 /// <summary>
 /// Searches for a main window in the predifined vicinity of the given window.
 /// Looks for windows of the same size only.
 /// </summary>
 /// <param name="hwndObj"></param>
 /// <returns></returns>
 protected int IdxOfMainWindowInRange(HwndObject hwndObj)
 {
     for (int i = 0; i < MainHwndObjs.Count; i++)
     {
         if (IsWindowSizeInRange(MainHwndObjs[i], hwndObj) && IsWindowPosInRange(MainHwndObjs[i], hwndObj))
         {
             return(i);
         }
     }
     return(-1);
 }
예제 #19
0
 // if combobox is empty, refresh the window titles autocomplete source
 public void RefreshHwndAutocomplete()
 {
     if (windowsComboBox.Text.Length == 0)
     {
         AutoCompleteStringCollection data = new AutoCompleteStringCollection();
         foreach (HwndObject o in HwndObject.GetWindows())
         {
             data.Add(o.Title);
         }
         windowsComboBox.AutoCompleteCustomSource = data;
     }
 }
예제 #20
0
        private void ClearOpenReports()
        {
            List <HwndObject> list = HwndObject.GetWindows().FindAll(o => o.Title.Equals("Enter Parameter Values"));

            foreach (HwndObject o in list)
            {
                o.CloseWindow();
                Thread.Sleep(1000);
                Input.PressKey(Input.KEY_SPACE);
                axiUm.Activate();
            }
        }
예제 #21
0
 public void Move(AppWinData appWinData)
 {
     if (Windows.Count > 1 && !MainHwndObjs.Contains(appWinData.HwndObj))
     {
         int        mainHwndIdx = IdxOfMainWindowInRange(appWinData.HwndObj); // index will always be valid
         HwndObject mainHwndObj = MainHwndObjs[mainHwndIdx];
         if (IsWindowPosDiff(mainHwndObj, appWinData.HwndObj) || IsWindowSizeDiff(mainHwndObj, appWinData.HwndObj))
         {
             appWinData.HwndObj.Rect = mainHwndObj.Rect;
         }
     }
 }
예제 #22
0
 // ideally this should utilize the find/move single window function, however
 // the Hwnd library i'm using does not really allow for that :/
 private void MoveLayoutWindows(WindowCollection coll)
 {
     foreach (HwndObject o in HwndObject.GetWindows())
     {
         foreach (Window w in coll.Windows)
         {
             if (TitlesMatch(w, o))
             {
                 w.MoveAndResize(o);
             }
         }
     }
 }
예제 #23
0
        public static IEnumerable <WindowInfo> GetWindowList(Size screenSize, Size targetSize, params WindowExtractor[] tableNameExtractors)
        {
            foreach (var extractor in tableNameExtractors)
            {
                var ws = HwndObject
                         .GetWindows();
                var windows = ws
                              .Select(w => new { Room = extractor.Name, Window = w, TableName = extractor.Extractor(w.Title) })
                              .Where(w => !string.IsNullOrEmpty(w.TableName));
                foreach (var window in windows)
                {
                    var size = window.Window.Size;
                    if (targetSize != size)
                    {
                        Console.WriteLine($"Current size {size.Width}x{size.Height}, resizing to {targetSize.Width}x{targetSize.Height}");
                        HwndObject.GetWindowByTitle(window.Window.Title).Size = targetSize;
                        continue;
                    }

                    Bitmap   bitmap         = new Bitmap(size.Width, size.Height);
                    Graphics memoryGraphics = Graphics.FromImage(bitmap);
                    IntPtr   dc             = memoryGraphics.GetHdc();
                    bool     success        = Win32.PrintWindow(window.Window.Hwnd, dc, 0);
                    memoryGraphics.ReleaseHdc(dc);

                    if (true)
                    {
                        RECT rect = new RECT();
                        if (Win32.GetWindowRect(window.Window.Hwnd, ref rect))
                        {
                            int width  = rect.right - rect.left;
                            int height = rect.bottom - rect.top;

                            bitmap = new Bitmap(width, height);
                            Graphics graphics = Graphics.FromImage(bitmap);
                            graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
                        }
                    }

                    yield return(new WindowInfo
                    {
                        Room = window.Room,
                        Title = window.Window.Title,
                        TableName = window.TableName,
                        Size = size,
                        Bitmap = bitmap
                    });
                }
            }
        }
예제 #24
0
파일: Game.cs 프로젝트: splendur/PokeBasic
        public Game(PictureBox pictureBox1)
        {
            OpponentTeam = new List <Poke>();
            OwnTeam      = new List <Poke>();
            Board        = new Board();
            //System.Drawing.Bitmap table = (Bitmap)Bitmap.FromFile(@"c:\users\frick\documents\visual studio 2017\Projects\ConsoleApp1\ConsoleApp1\Images\op1.png");

            HwndObject blueStacksWindow = HwndObject.GetWindowByTitle(GameWindowTitle);

            blueStacksWindow.Location = new Point(10, 100);
            SetForegroundWindow(blueStacksWindow.Hwnd);
            blueStacksWindow = HwndObject.GetWindowByTitle(GameWindowTitle);
            var location = blueStacksWindow.Location;
            var size     = blueStacksWindow.Size;

            Rectangle formBounds = new Rectangle(location.X + 500, location.Y + 184, size.Width - 680, size.Height - 130);

            Bitmap bmp = new Bitmap(formBounds.Width, formBounds.Height);

            SetForegroundWindow(blueStacksWindow.Hwnd);
            using (Graphics g = Graphics.FromImage(bmp))
                g.CopyFromScreen(formBounds.Location, Point.Empty, formBounds.Size);

            //Console.WriteLine("Own Team");
            var idBoard = ConvertToFormat(bmp, PixelFormat.Format24bppRgb);

            OwnTeam = PokeFinder.FindPokes(idBoard, PokeFinder.Teams.Own, pictureBox1);
            //OwnTeam.ForEach(pok => Console.WriteLine(pok.Name));
            ConvertOwnTeamCoordsToBoard();
            //int benchc = 0;
            //foreach (var benchPos in Board._MyBench)
            //{
            //    var OcName = benchPos.Occupant != null ? benchPos.Occupant.Name : "";
            //    //Console.WriteLine($"Bench{benchc++}: {OcName}");
            //}
            //Console.WriteLine("Opponent Team");
            OpponentTeam = PokeFinder.FindPokes(idBoard, PokeFinder.Teams.Opponent, pictureBox1);
            //OpponentTeam.ForEach(pok => Console.WriteLine(pok.Name));
            ConvertOpponentTeamCoordsToBoard();
            //benchc = 0;
            //foreach (var benchPos in Board._OpponentBench)
            //{
            //    var OcName = benchPos.Occupant != null ? benchPos.Occupant.Name : "";
            //    //Console.WriteLine($"Bench{benchc++}: {OcName}");
            //}
            bmp.Save($"board_{DateTime.Now:ddMMyyyyhhmm}.jpg", ImageFormat.Jpeg);

            Console.Write(Board.ToString());
        }
예제 #25
0
        /// <summary>
        /// Tries once to get a HwndObject with the string "Paint". Returns whether any was found
        /// </summary>
        /// <param name="obj">The Hwnd object found</param>
        /// <returns></returns>
        static bool GetPaintHwnd(out HwndObject obj)
        {
            List <HwndObject> list = HwndObject.GetWindows();

            foreach (HwndObject o in list)
            {
                if (o.Text.Contains("Paint") && !o.Text.ToLower().Contains("drawer"))
                {
                    obj = o;
                    return(true);
                }
            }
            obj = null;
            return(false);
        }
예제 #26
0
        public AxiUmPuppet(HwndObject axiUm)
        {
            Stuff.Init();
            Thread.Sleep(1000);

            this.axiUm = axiUm;
            axiUm.Activate();
            WindowScrape.Static.HwndInterface.ShowWindow(axiUm.Hwnd, 3);
            Thread.Sleep(1000);

            // Maximize AxiUm if it already isn't
            axiUm.Maximize();

            // Close any open reports to ensure axiUm is in its default resting state
            ClearOpenReports();
        }
예제 #27
0
        public IntPtr getHandleFromName(String inp)
        {
            List <HwndObject> p = HwndObject.GetWindows();

            foreach (HwndObject o in p)
            {
                if (o.Title.Length > 0)
                {
                    if (o.Title.ToLower() == inp.ToLower())
                    {
                        return(o.Hwnd);
                    }
                }
            }
            return(IntPtr.Zero);
        }
예제 #28
0
        public void MoveAndResize(HwndObject o)
        {
            /*
             * long style = GetWindowLong(Marshal.ReadInt64(o.Hwnd), -16L);
             * style &= -12582913L;
             * SetWindowLong((long)o.Hwnd, -16L, style);
             * SetWindowPos((long)o.Hwnd, 0L, 0L, 0L, 0L, 0L, 0x27L);
             */

            o.Location = translate
                ? TranslatePositionForDecoration(new Point(this.x, this.y))
                : new Point(this.x, this.y);
            o.Size = translate
                ? TranslateSizeForDecoration(new Size(this.width, this.height))
                : new Size(this.width, this.height);
        }
예제 #29
0
        static void ShowSelf()
        {
            List <HwndObject> list = HwndObject.GetWindows();

            foreach (HwndObject o in list)
            {
                if (o.Size.Width == 0 || o.Size.Height == 0 || o.Text.Length == 0)
                {
                    continue;
                }

                if (o.ClassName.Equals("ConsoleWindowClass") || o.Title.Contains("PaintDrawer.exe"))
                {
                    WindowScrape.Static.HwndInterface.ShowWindow(o.Hwnd, 3);
                }
            }
        }
예제 #30
0
        public List <HwndObject> getProcesses()
        {
            List <HwndObject> procs = new List <HwndObject>();
            List <HwndObject> p     = HwndObject.GetWindows();

            foreach (HwndObject o in p)
            {
                if (o.Title.Length > 0)
                {
                    if (!o.Size.IsEmpty && o.Size.Height > 1 && o.Size.Width > 1)
                    {
                        procs.Add(o);
                    }
                }
            }
            return(procs);
        }
예제 #31
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (running)
     {
         delay += timer1.Interval;
         if (delay > (int)this.delayUpDown.Value * 1000)
         {
             for (int i = 0; i < Players.Count; i++)
             {
                 PlayerInfo p = Players[i];
                 HwndObject hwnd = new HwndObject(p.Process.MainWindowHandle);
                 if (theresBigger && biggerPlayer == i && p.ScreenType == ScreenType.FullScreen && this.check_WindowedFullscreen.Checked ||
                     !theresBigger && p.ScreenType == ScreenType.FullScreen && this.check_WindowedFullscreen.Checked)
                 {
                     hwnd.Location = p.Location;
                 }
                 else
                 {
                     hwnd.Location = new Point(p.Location.X - 3, p.Location.Y - TitleHeight);
                 }
                 hwnd.Title = "Borderlands 2 PC Co-Op";
             }
         }
     }
 }
예제 #32
0
        private void btn_Play_Click(object sender, EventArgs e)
        {
            string starter = this.txt_File.Text;
            if (string.IsNullOrEmpty(starter))
            {
                MessageBox.Show("Select a Borderlands 2 file first!");
                return;
            }

            if (string.IsNullOrEmpty(saveFile))
            {
                string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                string myGames = Path.Combine(documents, @"My Games\Borderlands 2\WillowGame\Config");
                string willowEngine = Path.Combine(myGames, "WillowEngine.ini");

                if (File.Exists(willowEngine))
                {
                    saveFile = willowEngine;
                }
                else
                {
                    MessageBox.Show("Could not find WillowEngine.ini file!");

                    using (OpenFileDialog open = new OpenFileDialog())
                    {
                        open.Filter = "WillowEngine.ini file|WillowEngine.ini";
                        if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            saveFile = open.FileName;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            

            IniFile file = new IniFile(saveFile);
            file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False");
            file.IniWriteValue("SystemSettings", "Fullscreen", "False");

            //[Engine.Engine]
            //bPauseOnLossOfFocus
            //bMuteAudioWhenNotInFocus
            file.IniWriteValue("Engine.Engine", "bMuteAudioWhenNotInFocus", "FALSE");
            file.IniWriteValue("Engine.Engine", "bPauseOnLossOfFocus", "FALSE");

            file.IniWriteValue("WillowGame.WillowGameEngine", "bPauseLostFocusWindowed", "FALSE");
            file.IniWriteValue("WillowGame.WillowGameEngine", "bMuteAudioWhenNotInFocus", "FALSE");

            Screen[] all =  Screen.AllScreens;

            Screen bigger = null;
            for (int i = 0; i < all.Length; i++)
            {
                Screen s = all[i];
                if (bigger == null)
                {
                    bigger = s;
                }
                else
                {
                    if (s.Bounds.Width > bigger.Bounds.Width)
                    {
                        bigger = s;
                    }

                    if (s.Bounds.Width != bigger.Bounds.Width)
                    {
                        theresBigger = true;
                    }
                }
            }

            for (int i = 0; i < Players.Count; i++)
            {
                PlayerInfo player = Players[i];

                // Set Borderlands 2 Resolution and stuff to run
                Screen screen = all[player.ScreenIndex];
                int Width = 0;
                int Height = 0;

                Point location = new Point();

                switch (player.ScreenType)
                {
                    case ScreenType.FullScreen:
                        {
                            Width = screen.Bounds.Width - 5;
                            Height = screen.Bounds.Height - 5;
                            location = new Point(screen.Bounds.X, screen.Bounds.Y);
                            if (theresBigger && screen == bigger ||
                                !theresBigger && this.check_WindowedFullscreen.Checked)
                            {
                                biggerPlayer = i;
                                file.IniWriteValue("SystemSettings", "WindowedFullscreen", "True");
                            }
                            else
                            {
                                file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False");
                            }
                        }
                        break;
                    case ScreenType.HalfHorizontalLeft:
                        {
                            Width = screen.Bounds.Width / 2;
                            Height = screen.Bounds.Height;
                            location = new Point(screen.Bounds.X, screen.Bounds.Y);
                        }
                        break;
                    case ScreenType.HalfHorizontalRight:
                        {
                            Width = screen.Bounds.Width / 2;
                            Height = screen.Bounds.Height;
                            location = new Point(screen.Bounds.X + (screen.Bounds.Width / 2), screen.Bounds.Y);
                        }
                        break;
                    case ScreenType.HalfVerticalBottom:
                        {
                            Width = screen.Bounds.Width;
                            Height = screen.Bounds.Height / 2;
                            location = new Point(screen.Bounds.X, screen.Bounds.Y + (screen.Bounds.Height / 2));
                        }
                        break;
                    case ScreenType.HalfVerticalTop:
                        {
                            Width = screen.Bounds.Width;
                            Height = screen.Bounds.Height / 2;
                            location = new Point(screen.Bounds.X, screen.Bounds.Y);
                        }
                        break;
                }

                file.IniWriteValue("SystemSettings", "ResX", Width.ToString(CultureInfo.InvariantCulture));
                file.IniWriteValue("SystemSettings", "ResY", Height.ToString(CultureInfo.InvariantCulture));

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName = starter;
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                if (i == 0)
                {
                    if (check_Keyboard.Checked)
                    {
                        startInfo.Arguments = "-AlwaysFocus -ControllerOffset=3 -SaveDataId=1";
                    }
                    else
                    {
                        startInfo.Arguments = "-AlwaysFocus -SaveDataId=0";
                    }
                }
                else
                {
                    if (check_Keyboard.Checked)
                    {
                        startInfo.Arguments = "-AlwaysFocus -ControllerOffset=" + (i - 1).ToString(CultureInfo.InvariantCulture) + " -SaveDataId=" + (i + 1).ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        startInfo.Arguments = "-AlwaysFocus -ControllerOffset=" + i.ToString(CultureInfo.InvariantCulture) + " -SaveDataId=" + (i + 1).ToString(CultureInfo.InvariantCulture);
                    }
                }
                Process proc = Process.Start(startInfo);
                HwndObject hwnd = new HwndObject(proc.Handle);
                
                player.Location = location;
                player.HWND = hwnd;
                player.Process = proc;
                player.Size = new Size(Width, Height);

                int timeDelay = (int)this.delayUpDown.Value * 1000;
                Thread.Sleep(timeDelay);
            }

            running = true;
            Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle);

            TitleHeight = screenRectangle.Top - this.Top;
            TitleWidth = screenRectangle.Left - this.Left;
        }