/// <summary>
        /// Opens an SNG with the specified settings
        /// </summary>
        public string OpenSNG(string buyin, string gameDescription, bool speedSNG, bool bln6Max, bool selectBuyin)
        {
            // Check for total abort
            if (totalAbort)
            {
                AbortAttempt = true;
                MessageBox.Show(totalAbortDescription);
                return("");
            }

            if (lobbyTreeviewHandle != 0)
            {
                TreeviewManipulation tm = new TreeviewManipulation(lobbyTreeviewHandle);
                int buyinLevelItem      = 0;

                // Find the buyin treeview item
                if (selectBuyin)
                {
                    buyinLevelItem = tm.GetItemByText(buyin);

                    // Select it
                    tm.SelectItem(buyinLevelItem);
                }

                // Now that we have the correct buyin selected, access the ListView
                ListviewManipulation lm = new ListviewManipulation(lobbyListviewHandle);

                // Loop indefinitely until aborted, seeing if we can find a suitable table
                while (true)
                {
                    // Check for abortion flag
                    if (AbortAttempt)
                    {
                        return("");
                    }

                    // Yield
                    Application.DoEvents();

                    // Loop through all istview items until we find the desired game, with at most 6 players
                    for (int i = 0; i < lm.GetItemCount(); i++)
                    {
                        if (AbortAttempt)
                        {
                            return("");
                        }

                        // Check gamedescription
                        if (lm.GetItemText(i, 1) == gameDescription)
                        {
                            Application.DoEvents();
                            if (AbortAttempt)
                            {
                                return("");
                            }

                            // Check speed sng
                            if (!speedSNG && !lm.GetItemText(i, 0).Contains("Speed") || speedSNG && lm.GetItemText(i, 0).Contains("Speed"))
                            {
                                Application.DoEvents();
                                if (AbortAttempt)
                                {
                                    return("");
                                }

                                // Check 6 max
                                if (bln6Max && lm.GetItemText(i, 3).EndsWith("/6") || !bln6Max && lm.GetItemText(i, 3).EndsWith("/10"))
                                {
                                    Application.DoEvents();
                                    if (AbortAttempt)
                                    {
                                        return("");
                                    }

                                    // Check it's registering
                                    if (lm.GetItemText(i, 4) == "Registering")
                                    {
                                        Application.DoEvents();
                                        if (AbortAttempt)
                                        {
                                            return("");
                                        }

                                        // Check players is below 7
                                        if (Convert.ToInt32(lm.GetItemText(i, 3)[0].ToString()) <= 8)
                                        {
                                            Application.DoEvents();
                                            if (AbortAttempt)
                                            {
                                                return("");
                                            }

                                            // Check that we have not tried to open this table before
                                            if (!lastOpenedTables.Contains(lm.GetItemText(i, 0)))
                                            {
                                                // Get the table name
                                                string tableName = lm.GetItemText(i, 0);

                                                // Gamedescription matches, and the number of players is at most 3, select this row
                                                lm.SelectItem(i);

                                                // Add to recently opened tables list
                                                lastOpenedTables.Add(tableName);
                                                if (lastOpenedTables.Count > 12)
                                                {
                                                    lastOpenedTables.RemoveAt(6);
                                                }

                                                // Press the enter key to open the table
                                                Win32.PostMessage(lobbyListviewHandle, (int)Win32.WM.KEYDOWN, (int)Win32.VK.RETURN, 1);

                                                return(tableName);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Sleep 3 seconds
                    for (int sleep = 0; sleep < 300; sleep++)
                    {
                        Application.DoEvents();
                        System.Threading.Thread.Sleep(10);
                    }

                    if (buyinLevelItem == 0)
                    {
                        buyinLevelItem = tm.GetItemByText(buyin);
                    }

                    tm.SelectItem(tm.GetNextItem(buyinLevelItem));

                    System.Threading.Thread.Sleep(20);

                    Application.DoEvents();

                    // Select it
                    tm.SelectItem(buyinLevelItem);

                    Application.DoEvents();
                }
            }
            else
            {
                AbortAttempt = true;
                MessageBox.Show("The lobby treeview could not be found, please make sure it's open");
            }

            return("");
        }
        /// <summary>
        /// Opens an SNG with the specified settings
        /// </summary>
        public string OpenSNG(string buyin, string gameDescription, bool speedSNG, bool bln6Max, bool selectBuyin)
        {
            // Check for total abort
            if(totalAbort)
            {
                AbortAttempt = true;
                MessageBox.Show(totalAbortDescription);
                return "";
            }

            if(lobbyTreeviewHandle != 0)
            {
                TreeviewManipulation tm = new TreeviewManipulation(lobbyTreeviewHandle);
                int buyinLevelItem = 0;

                // Find the buyin treeview item
                if (selectBuyin)
                {
                    buyinLevelItem = tm.GetItemByText(buyin);

                    // Select it
                    tm.SelectItem(buyinLevelItem);
                }

                // Now that we have the correct buyin selected, access the ListView
                ListviewManipulation lm = new ListviewManipulation(lobbyListviewHandle);

                // Loop indefinitely until aborted, seeing if we can find a suitable table
                while(true)
                {
                    // Check for abortion flag
                    if(AbortAttempt)
                        return "";

                    // Yield
                    Application.DoEvents();

                    // Loop through all istview items until we find the desired game, with at most 6 players
                    for(int i=0; i<lm.GetItemCount(); i++)
                    {
                        if (AbortAttempt)
                            return "";

                        // Check gamedescription
                        if (lm.GetItemText(i, 1) == gameDescription)
                        {
                            Application.DoEvents();
                            if (AbortAttempt)
                                return "";

                            // Check speed sng
                            if(!speedSNG && !lm.GetItemText(i, 0).Contains("Speed") || speedSNG && lm.GetItemText(i, 0).Contains("Speed"))
                            {
                                Application.DoEvents();
                                if (AbortAttempt)
                                    return "";

                                // Check 6 max
                                if(bln6Max && lm.GetItemText(i, 3).EndsWith("/6") || !bln6Max && lm.GetItemText(i, 3).EndsWith("/10"))
                                {
                                    Application.DoEvents();
                                    if (AbortAttempt)
                                        return "";

                                    // Check it's registering
                                    if (lm.GetItemText(i, 4) == "Registering")
                                    {
                                        Application.DoEvents();
                                        if (AbortAttempt)
                                            return "";

                                        // Check players is below 7
                                        if (Convert.ToInt32(lm.GetItemText(i, 3)[0].ToString()) <= 8)
                                        {
                                            Application.DoEvents();
                                            if (AbortAttempt)
                                                return "";

                                            // Check that we have not tried to open this table before
                                            if (!lastOpenedTables.Contains(lm.GetItemText(i, 0)))
                                            {
                                                // Get the table name
                                                string tableName = lm.GetItemText(i, 0);

                                                // Gamedescription matches, and the number of players is at most 3, select this row
                                                lm.SelectItem(i);

                                                // Add to recently opened tables list
                                                lastOpenedTables.Add(tableName);
                                                if (lastOpenedTables.Count > 12)
                                                    lastOpenedTables.RemoveAt(6);

                                                // Press the enter key to open the table
                                                Win32.PostMessage(lobbyListviewHandle, (int)Win32.WM.KEYDOWN, (int)Win32.VK.RETURN, 1);

                                                return tableName;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Sleep 3 seconds
                    for (int sleep = 0; sleep < 300; sleep++)
                    {
                        Application.DoEvents();
                        System.Threading.Thread.Sleep(10);
                    }

                    if(buyinLevelItem == 0)
                        buyinLevelItem = tm.GetItemByText(buyin);

                    tm.SelectItem(tm.GetNextItem(buyinLevelItem));

                    System.Threading.Thread.Sleep(20);

                    Application.DoEvents();

                    // Select it
                    tm.SelectItem(buyinLevelItem);

                    Application.DoEvents();
                }
            }
            else
            {
                AbortAttempt = true;
                MessageBox.Show("The lobby treeview could not be found, please make sure it's open");
            }

            return "";
        }