Our members are dedicated to PASSION and PURPOSE without drama!

[ALPHA] Definitions Generator (Universal Clicker + OCR)

Started by VLS, August 07, 2013, 06:53:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VLS

This is the first Alpha for our new Definitions Generator (for enabling an Universal Clicker + OCR). Its mission is to empower people to configure the settings for any casino without having to wait for the programmer to update the clicker/bot.

Feedback from first users is needed.

Sponsor download: [attachmini=1]


Email/Paypal: betselectiongmail.com
-- Victor

VLS

Relevant sources below.


Main form:
Code (csharp) Select
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace DefinitionsGenerator
{
    public partial class Form1 : Form
    {
        // intPtr holding Last Window
        public IntPtr LastWindow = IntPtr.Zero;

        // Capture window
        FormCapture fCapture = new FormCapture();

        // Rectangle window
        FormRectangle fRectangle = new FormRectangle();

        // Last selected items
        int lastKeyword, lastLocation = -1;

        // List of bitmap for saved numbers
        List<Image> numbers = new List<Image>();

        /// <summary>
        /// Constructor
        /// </summary>
        public Form1()
        {
            // Initialize
            InitializeComponent();

            // Attach VisibleChanged handler to event in capture form
            fCapture.VisibleChanged += new EventHandler(this.fCapture_VisibleChanged);

            // Attach to rectangle form
            fRectangle.VisibleChanged += new EventHandler(this.fRectangle_VisibleChanged);   

            // Set capture form icon
            fCapture.Icon = this.Icon;

            // Set rectangle form icon
            fRectangle.Icon = this.Icon;

            // Insert 37 empty images in list
            for (int i = 0; i < 37; i++)
            {
                // Use resource image for padding
                numbers.Add(Properties.Resources.transparent);
            }
        }

        /// <summary>
        /// Handle MouseDown on Scope
        /// </summary>
        private void pbCursor_MouseDown(object sender, MouseEventArgs e)
        {
            // Set cursor
            Cursor = new Cursor(new System.IO.MemoryStream(Properties.Resources.searchw));

            // Change image to blank background one
            pbCursor.Image = Properties.Resources.findere;
        }

        /// <summary>
        /// Handle MouseMove on Scope
        /// </summary>
        private void pbCursor_MouseMove(object sender, MouseEventArgs e)
        {
            if (Cursor != Cursors.Default)
            {
                // We are, determine found window
                IntPtr FoundWindow = Win32.ChildWindowFromPoint(Cursor.Position);

                // Not this application
                if (Control.FromHandle(FoundWindow) == null)
                {
                    // Not an already-processed window
                    if (FoundWindow != LastWindow)
                    {
                        // clear old window
                        Win32.ShowInvertRectTracker(LastWindow);

                        // Set new window
                        LastWindow = FoundWindow;

                        // Paint inverted rectangle on new window
                        Win32.ShowInvertRectTracker(LastWindow);
                    }
                }

            }
        }

        /// <summary>
        /// Handle MouseUp on Scope
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbCursor_MouseUp(object sender, MouseEventArgs e)
        {
            // Check if it's done
            if (Cursor != Cursors.Default)
            {
                // Invert last window back
                Win32.ShowInvertRectTracker(LastWindow);

                // Change image back
                pbCursor.Image = Properties.Resources.finderf;

                // Change cursor back
                Cursor = Cursors.Default;

                /* Set title */
                string title = Win32.GetWindowText(LastWindow);

                // Check if there is some length to work with
                if (title.Length == 0)
                {
                    // Nothing to do, advice user
                    MessageBox.Show("No window title present.", "Empty title", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Exit
                    return;
                }

                // Enable keywords listbox
                if (!clbKeywords.Enabled)
                {
                    clbKeywords.Enabled = true;
                }

                // Clear keywords list
                clbKeywords.Items.Clear();

                // Set keywords
                string[] keywords = Regex.Split(title, @"\W");

                // Assign keywords to list
                clbKeywords.Items.AddRange(keywords);

                // Capture image
                Image img = Win32.CaptureWindow(LastWindow);

                // Set coordinates capture form's background
                fCapture.BackgroundImage = img;

                // Set its width and height
                fCapture.ClientSize = new Size(img.Width, img.Height);

                // Set rectangle form's picturebox image
                fRectangle.setPbRect(img);

                // Set its width and height
                fRectangle.ClientSize = new Size(img.Width, img.Height);

                // Reset last window
                LastWindow = IntPtr.Zero;
            }
        }

        /// <summary>
        /// Toggle currently selected item on CheckedListBox
        /// </summary>
        /// <param name="sender">Passed CheckedListBox</param>
        private void ToggleSelected(object sender)
        {
            // Check index is valid
            if (((CheckedListBox)sender).SelectedIndex > -1)
            {
                // Reverse checked status
                ((CheckedListBox)sender).SetItemChecked(((CheckedListBox)sender).SelectedIndex, !((CheckedListBox)sender).GetItemChecked(((CheckedListBox)sender).SelectedIndex));
            }
        }

        /// <summary>
        /// A secondary handler for visibility toggling on capture form
        /// </summary>
        private void fCapture_VisibleChanged(object sender, EventArgs e)
        {
            // Check if it's invisible
            if (fCapture.Visible == false)
            {
                // Activate set rectangle button
                bSetRectangle.Enabled = true;
            }           
        }

        /// <summary>
        /// A secondary handler for visibility toggling on rectangle form
        /// </summary>
        private void fRectangle_VisibleChanged(object sender, EventArgs e)
        {
            // Check if it's invisible
            if (fRectangle.Visible == false)
            {
                // Set ret image
                pbCrop.Image = fRectangle.getRectImg();
               
                // Activate define button
                bDefine.Enabled = true;

                // Activate library ListBox
                clbLibrary.Enabled = true;
            }
        }

        /// <summary>
        /// Handle click on keywords CheckedListBox
        /// </summary>
        private void clbKeywords_Click(object sender, EventArgs e)
        {
            // Act only on newly selected items
            if (lastKeyword != ((CheckedListBox)sender).SelectedIndex)
            {
                // Toggle selected item
                ToggleSelected(sender);

                // Set last keyword
                lastKeyword = ((CheckedListBox)sender).SelectedIndex;
            }

            // Enable locations listbox
            if (clbKeywords.SelectedIndex > -1 && !clbLocations.Enabled)
            {
                clbLocations.Enabled = true;
            }
        }

        /// <summary>
        /// Handle click on locations CheckedListBox
        /// </summary>
        private void clbLocations_Click(object sender, EventArgs e)
        {
            // Act only on newly selected items
            if (lastLocation != ((CheckedListBox)sender).SelectedIndex)
            {
                // Toggle selected item
                ToggleSelected(sender);

                // Set last location
                lastLocation = ((CheckedListBox)sender).SelectedIndex;
            }

            // Enable set locations button
            if (clbLocations.SelectedIndex > -1 && !bSetLocations.Enabled)
            {
                bSetLocations.Enabled = true;
            }
        }

        /// <summary>
        /// Start coordinates process
        /// </summary>
        private void bSetLocations_Click(object sender, EventArgs e)
        {
            // If user wants to set chips
            if (clbLocations.GetSelected()
            {
                // String to hold InputBox value
                string value = string.Empty;

                // Ask how many chips are going to be set
                InputBox.Show("Casino chips", "How many chips are you going to set?", ref value);

                // Int to hold the amount of chips
                int chipsAmount;

                // Try to parse the chips amount from assigned value
                Int32.TryParse(value, out chipsAmount);

                // Check there's something to work with
                if (chipsAmount > 0)
                {
                    // Clear chips list
                    Locations.clearChips();

                    // Ask for chips' values
                    for (int c = 0; c < chipsAmount; c++)
                    {
                        // Int to hold current chip value
                        double currentChip = 0.0;

                        // Reset value
                        value = string.Empty;

                        // Assign current one
                        InputBox.Show("Define chip", "Set value for chip #" + (c + 1).ToString(), ref value);

                        // Try to parse the current chip's amount from assigned value
                        Double.TryParse(value, out currentChip);

                        // Assign current value
                        Locations.addChip(currentChip.ToString(), "Chip " + currentChip.ToString());
                    }
                }
            }

            // List for selected locations
            List<string> selected = new List<string>();

            // Prepare selected locations list
            for (int i = 0; i < clbLocations.Items.Count; i++)
            {
                // Test current i
                switch (i)
                {
                    // Numbers
                    case 0:
                        // Check
                        if (clbLocations.GetItemChecked(0))
                        {
                            // Add
                            selected.Add("numbers");
                        }

                        // Halt
                        break;
                    // Splits
                    case 1:
                        // Check
                        if (clbLocations.GetItemChecked(1))
                        {
                            // Add
                            selected.Add("splits");
                        }

                        // Halt
                        break;
                    // Streets
                    case 2:
                        // Check
                        if (clbLocations.GetItemChecked(2))
                        {
                            // Add
                            selected.Add("streets");
                        }

                        // Halt
                        break;
                    // Corners
                    case 3:
                        // Check
                        if (clbLocations.GetItemChecked(3))
                        {
                            // Add
                            selected.Add("corners");
                        }

                        // Halt
                        break;
                    // Lines
                    case 4:
                        // Check
                        if (clbLocations.GetItemChecked(4))
                        {
                            // Add
                            selected.Add("lines");
                        }

                        // Halt
                        break;
                    // Dozens and colunms
                    case 5:
                        // Check
                        if (clbLocations.GetItemChecked(5))
                        {
                            // Add
                            selected.Add("dc");
                        }

                        // Halt
                        break;
                    // Even chances
                    case 6:
                        // Check
                        if (clbLocations.GetItemChecked(6))
                        {
                            // Add
                            selected.Add("ec");
                        }

                        // Halt
                        break;
                    // Casino buttons
                    case 7:
                        // Check
                        if (clbLocations.GetItemChecked(7))
                        {
                            // Add
                            selected.Add("buttons");
                        }

                        // Halt
                        break;
                    // Chips
                    case 8:
                        // Check
                        if (clbLocations.GetItemChecked()
                        {
                            // Add
                            selected.Add("chips");
                        }

                        // Halt
                        break;
                }
            }

            // Set all locations
            Locations.setAll(selected);

            // Set fCapture to visible
            fCapture.Visible = true;
        }

        /// <summary>
        /// Set rectangle form visible
        /// </summary>
        private void bSetRectangle_Click(object sender, EventArgs e)
        {
            // Set it
            fRectangle.Visible = true;
        }

        /// <summary>
        /// Ask for current number
        /// </summary>
        private void bDefine_Click(object sender, EventArgs e)
        {
            // String to hold InputBox value
            string value = string.Empty;

            // Ask how many chips are going to be set
            InputBox.Show("Set number", "Which number is it?", ref value);

            // Int to hold the amount of chips
            int number;

            // Try to parse the chips amount from assigned value
            Int32.TryParse(value, out number);

            // Check number
            if (number > -1 && number < 36)
            {
                // Assign
                numbers[number] = fRectangle.getRectImg();

                // Tick in library
                clbLibrary.SetItemChecked(number, true);
            }
        }

        /// <summary>
        /// Display current image from library
        /// </summary>
        private void clbLibrary_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Display image from current index
            pbLibrary.Image = numbers[((CheckedListBox)sender).SelectedIndex];
        }
    }
}

Email/Paypal: betselectiongmail.com
-- Victor

VLS

Locations:

Code (csharp) Select
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms; // DEBUG TIME ONLY, Remove

namespace DefinitionsGenerator
{
    static class Locations
    {
        /* Locations lists */

        // Numbers
        private static List<KeyValuePair<string, string>> numbers = new List<KeyValuePair<string, string>>();

        // Splits
        private static List<KeyValuePair<string, string>> splits = new List<KeyValuePair<string, string>>();

        // Streets
        private static List<KeyValuePair<string, string>> streets = new List<KeyValuePair<string, string>>();

        // Corners / Quads
        private static List<KeyValuePair<string, string>> corners = new List<KeyValuePair<string, string>>();

        // Lines / Double-streets
        private static List<KeyValuePair<string, string>> lines = new List<KeyValuePair<string, string>>();

        // Dozens and Columns
        private static List<KeyValuePair<string, string>> dc = new List<KeyValuePair<string, string>>();

        // Even chances
        private static List<KeyValuePair<string, string>> ec = new List<KeyValuePair<string, string>>();

        // Buttons
        private static List<KeyValuePair<string, string>> buttons = new List<KeyValuePair<string, string>>();

        // Chips
        private static List<KeyValuePair<string, string>> chips = new List<KeyValuePair<string, string>>();

        // All locations
        private static List<KeyValuePair<string, string>> all = new List<KeyValuePair<string, string>>();

        // Assigned locations dictionary
        private static Dictionary<string, Point> assigned = new Dictionary<string, Point>();

        // Last selected locations
        private static List<string> lastSelected = new List<string>();

        /// <summary>
        /// Static constructor
        /// </summary>
        static Locations()
        {
            /* Populate lists */

            // Numbers
            for (int n = 0; n <= 36; n++)
            {
                // Add current number
                numbers.Add(new KeyValuePair<string, string>(n.ToString(), "number " + n.ToString()));
            }

            // Splits
            splits.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("1-0", "split 1-0"),
                new KeyValuePair<string, string>("2-0", "split 2-0"),
                new KeyValuePair<string, string>("3-0", "split 3-0"),
                new KeyValuePair<string, string>("1-2", "split 3-0"),
                new KeyValuePair<string, string>("1-4", "split 1-4"),
                new KeyValuePair<string, string>("2-3", "split 2-3"),
                new KeyValuePair<string, string>("2-5", "split 2-5"),
                new KeyValuePair<string, string>("3-6", "split 3-6"),
                new KeyValuePair<string, string>("4-5", "split 4-5"),
                new KeyValuePair<string, string>("4-7", "split 4-7"),
                new KeyValuePair<string, string>("5-6", "split 5-6"),
                new KeyValuePair<string, string>("5-8", "split 5-8"),
                new KeyValuePair<string, string>("6-9", "split 6-9"),
                new KeyValuePair<string, string>("7-8", "split 7-8"),
                new KeyValuePair<string, string>("7-10", "split 7-10"),
                new KeyValuePair<string, string>("8-9", "split 8-9"),
                new KeyValuePair<string, string>("8-11", "split 8-11"),
                new KeyValuePair<string, string>("9-12", "split 9-12"),
                new KeyValuePair<string, string>("10-11", "split 10-11"),
                new KeyValuePair<string, string>("10-13", "split 10-13"),
                new KeyValuePair<string, string>("11-12", "split 11-12"),
                new KeyValuePair<string, string>("11-14", "split 11-14"),
                new KeyValuePair<string, string>("12-15", "split 12-15"),
                new KeyValuePair<string, string>("13-14", "split 13-14"),
                new KeyValuePair<string, string>("13-16", "split 13-16"),
                new KeyValuePair<string, string>("14-15", "split 14-15"),
                new KeyValuePair<string, string>("14-17", "split 14-17"),
                new KeyValuePair<string, string>("15-18", "split 15-18"),
                new KeyValuePair<string, string>("16-17", "split 16-17"),
                new KeyValuePair<string, string>("16-19", "split 16-19"),
                new KeyValuePair<string, string>("17-18", "split 17-18"),
                new KeyValuePair<string, string>("17-20", "split 17-20"),
                new KeyValuePair<string, string>("18-21", "split 18-21"),
                new KeyValuePair<string, string>("19-20", "split 19-20"),
                new KeyValuePair<string, string>("19-22", "split 19-22"),
                new KeyValuePair<string, string>("20-21", "split 20-21"),
                new KeyValuePair<string, string>("20-23", "split 20-23"),
                new KeyValuePair<string, string>("21-24", "split 21-24"),
                new KeyValuePair<string, string>("22-23", "split 22-23"),
                new KeyValuePair<string, string>("22-25", "split 22-25"),
                new KeyValuePair<string, string>("23-24", "split 23-24"),
                new KeyValuePair<string, string>("23-26", "split 23-26"),
                new KeyValuePair<string, string>("24-27", "split 24-27"),
                new KeyValuePair<string, string>("25-26", "split 25-26"),
                new KeyValuePair<string, string>("25-28", "split 25-28"),
                new KeyValuePair<string, string>("26-27", "split 26-27"),
                new KeyValuePair<string, string>("26-29", "split 26-29"),
                new KeyValuePair<string, string>("27-30", "split 27-30"),
                new KeyValuePair<string, string>("28-29", "split 28-29"),
                new KeyValuePair<string, string>("28-31", "split 28-31"),
                new KeyValuePair<string, string>("29-30", "split 29-30"),
                new KeyValuePair<string, string>("29-32", "split 29-32"),
                new KeyValuePair<string, string>("30-33", "split 30-33"),
                new KeyValuePair<string, string>("31-32", "split 31-32"),
                new KeyValuePair<string, string>("31-34", "split 31-34"),
                new KeyValuePair<string, string>("32-33", "split 32-33"),
                new KeyValuePair<string, string>("32-35", "split 32-35"),
                new KeyValuePair<string, string>("33-36", "split 33-36"),
                new KeyValuePair<string, string>("34-35", "split 34-35"),
                new KeyValuePair<string, string>("35-36", "split 35-36")});


            // Streets
            streets.AddRange(new KeyValuePair<string, string>[] {
               new KeyValuePair<string, string>("1-3", "street 1-3"),
                new KeyValuePair<string, string>("4-6", "street 4-6"),
                new KeyValuePair<string, string>("7-9", "street 7-9"),
                new KeyValuePair<string, string>("10-12", "street 10-12"),
                new KeyValuePair<string, string>("13-15", "street 13-15"),
                new KeyValuePair<string, string>("16-18", "street 16-18"),
                new KeyValuePair<string, string>("19-21", "street 19-21"),
                new KeyValuePair<string, string>("22-24", "street 22-24"),
                new KeyValuePair<string, string>("25-27", "street 25-27"),
                new KeyValuePair<string, string>("28-30", "street 28-30"),
                new KeyValuePair<string, string>("31-33", "street 31-33"),
                new KeyValuePair<string, string>("34-36", "street 34-36")});

            // Corners
            corners.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("1-5", "corner 1-5"),
                new KeyValuePair<string, string>("2-6", "corner 2-6"),
                new KeyValuePair<string, string>("4-8", "corner 4-8"),
                new KeyValuePair<string, string>("5-9", "corner 5-9"),
                new KeyValuePair<string, string>("7-11", "corner 7-11"),
                new KeyValuePair<string, string>("8-12", "corner 8-12"),
                new KeyValuePair<string, string>("10-14", "corner 10-14"),
                new KeyValuePair<string, string>("11-15", "corner 11-15"),
                new KeyValuePair<string, string>("13-17", "corner 13-17"),
                new KeyValuePair<string, string>("14-18", "corner 14-18"),
                new KeyValuePair<string, string>("16-20", "corner 16-20"),
                new KeyValuePair<string, string>("17-21", "corner 17-21"),
                new KeyValuePair<string, string>("19-23", "corner 19-23"),
                new KeyValuePair<string, string>("20-24", "corner 20-24"),
                new KeyValuePair<string, string>("22-26", "corner 22-26"),
                new KeyValuePair<string, string>("23-27", "corner 23-27"),
                new KeyValuePair<string, string>("25-29", "corner 25-29"),
                new KeyValuePair<string, string>("26-30", "corner 26-30"),
                new KeyValuePair<string, string>("28-32", "corner 28-32"),
                new KeyValuePair<string, string>("29-33", "corner 29-33"),
                new KeyValuePair<string, string>("31-35", "corner 31-35"),
                new KeyValuePair<string, string>("32-36", "corner 32-36")});

            // Lines
            lines.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("1-6", "line 1-6"),
                new KeyValuePair<string, string>("4-9", "line 4-9"),
                new KeyValuePair<string, string>("7-12", "line 7-12"),
                new KeyValuePair<string, string>("10-15", "line 10-15"),
                new KeyValuePair<string, string>("13-18", "line 13-18"),
                new KeyValuePair<string, string>("16-21", "line 16-21"),
                new KeyValuePair<string, string>("19-24", "line 19-24"),
                new KeyValuePair<string, string>("22-27", "line 22-27"),
                new KeyValuePair<string, string>("25-30", "line 25-30"),
                new KeyValuePair<string, string>("28-33", "line 28-33"),
                new KeyValuePair<string, string>("31-36", "line 31-36")});

            // Dozens and columns
            dc.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("1-12", "Dozen 1"),
                new KeyValuePair<string, string>("13-24", "Dozen 2"),
                new KeyValuePair<string, string>("25-36", "Dozen 3"),
                new KeyValuePair<string, string>("1-34", "Column 1"),
                new KeyValuePair<string, string>("2-35", "Column 2"),
                new KeyValuePair<string, string>("3-36", "Column 3")});

            // Even chances
            ec.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("low", "Low (1-18)"),
                new KeyValuePair<string, string>("high", "High (19-36)"),
                new KeyValuePair<string, string>("even", "Even"),
                new KeyValuePair<string, string>("odd", "Odd"),
                new KeyValuePair<string, string>("red", "Red"),
                new KeyValuePair<string, string>("black", "Black")});

            // Buttons
            buttons.AddRange(new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>("confirm", "Confirm"),
                new KeyValuePair<string, string>("rebet", "Rebet"),
                new KeyValuePair<string, string>("clear", "Clear")});
        }

        /// <summary>
        /// Clear list of chips
        /// </summary>
        public static void clearChips()
        {
            // Clear chips
            chips.Clear();
        }

        /// <summary>
        /// Adds chip to list
        /// </summary>
        /// <param name="chip">Chip to add</param>
        public static void addChip(string chipKey, string chipValue)
        {
            // Add passed chip
            chips.Add(new KeyValuePair<string, string>(chipKey, chipValue));
        }


        /// <summary>
        /// Sets "all" list
        /// </summary>
        public static void setAll(List<string> selected)
        {
            // Clear last selected
            lastSelected.Clear();
           
            // Set last selected
            lastSelected.AddRange(selected);
           
            // Clear "all" list
            all.Clear();

            /* Add passed selected locations */

            // Numbers
            if (selected.Contains("numbers"))
            {
                // Add numbers
                all.AddRange(numbers);
            }

            // Splits
            if (selected.Contains("splits"))
            {
                // Add splits
                all.AddRange(splits);
            }

            // Streets
            if (selected.Contains("streets"))
            {
                // Add streets
                all.AddRange(streets);
            }

            // Corners
            if (selected.Contains("corners"))
            {
                // Add corners
                all.AddRange(corners);
            }

            // Lines
            if (selected.Contains("lines"))
            {
                // Add lines
                all.AddRange(lines);
            }

            // dc
            if (selected.Contains("dc"))
            {
                // Add Dozens and columns
                all.AddRange(dc);
            }

            // ec
            if (selected.Contains("ec"))
            {
                // Add even chances
                all.AddRange(ec);
            }

            // Buttons
            if (selected.Contains("buttons"))
            {
                // Add buttons
                all.AddRange(buttons);
            }

            // Chips
            if (selected.Contains("chips"))
            {
                // Add chips
                all.AddRange(chips);
            }
        }

        /// <summary>
        /// Clears assigned dictionary
        /// </summary>
        public static void clearAssigned()
        {
            // Clear it
            assigned.Clear();
        }

        /// <summary>
        /// Adds new name/coord pair to assigned dictionary
        /// </summary>
        /// <param name="coord">coordinates for location</param>
        public static void addAssigned(Point coord)
        {
            // Assign
            assigned.Add(all[assigned.Count].Key, coord);
        }

        /// <summary>
        /// Takes one from assigned
        /// </summary>
        public static void undoAssigned()
        {
            // Check there is something to undo
            if (assigned.Count == 0)
            {
                // Halt
                return;
            }
           
            // Remove last one from assigned
            assigned.Remove(all[assigned.Count - 1].Key);
        }

        /// <summary>
        /// Gets the display name for the next location to add
        /// </summary>
        /// <returns>string with the display name of the next location in line</returns>
        public static string getNextLocation()
        {
            // Check if count is still within list' boundaries
            if (assigned.Count == all.Count)
            {
                // Return empty string
                return string.Empty;
            }

            // Return next
            return all[assigned.Count].Value;
        }
    }
}



Email/Paypal: betselectiongmail.com
-- Victor

VLS

FormRectangle

Code (csharp) Select
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DefinitionsGenerator
{
    public partial class FormRectangle : Form
    {
        // Boolean for selection state
        bool selecting;

        // ints for point 1 and point 2
        int x1, y1, x2, y2;

        // Var to keep base image intact
        Bitmap bmBase;

        // Rectangle for crop
        Rectangle rect;

        /// <summary>
        /// Constructor
        /// </summary>
        public FormRectangle()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Prevents window from closing
        /// </summary>
        private void FormRectangle_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Set status to invisible
            this.Visible = false;

            // Cancel closing
            e.Cancel = true;
        }

        /// <summary>
        /// Sets image on picturebox
        /// </summary>
        /// <param name="img">The passed image</param>
        public void setPbRect(Image img)
        {
            // Set base image
            bmBase = new Bitmap(img);

            // Set picturebox image
            pbRect.Image = img;
        }

        /// <summary>
        /// Gets an image from currentyl selected rectangle
        /// </summary>
        /// <returns>image with cropped rectangle</returns>
        public Image getRectImg()
        {
            Bitmap bmCrop = bmBase.Clone(rect, bmBase.PixelFormat);
            return (Image)(bmCrop);
        }

        /// <summary>
        /// Handle MouseDown on pbRect
        /// </summary>
        private void pbRect_MouseDown(object sender, MouseEventArgs e)
        {
            // Toggle selection status
            selecting = true;

            // Set X1, Y1
            x1 = e.X;
            y1 = e.Y;
        }

        /// <summary>
        /// Handle MouseUp on pbRect
        /// </summary>
        private void pbRect_MouseUp(object sender, MouseEventArgs e)
        {
            // Set selection state
            selecting = false;
        }

        /// <summary>
        /// Handle MouseMove on pbRect
        /// </summary>
        private void pbRect_MouseMove(object sender, MouseEventArgs e)
        {
            // Proceed only if we are in selection state
            if (!selecting)
            {
                // Halt
                return;
            }

            // Set X2, Y2
            x2 = e.X;
            y2 = e.Y;

            // Get BitMap
            Bitmap bm = new Bitmap(bmBase);

            // Set graphics
            using (Graphics gr = Graphics.FromImage(bm))
            {
                // Set pen
                using (Pen pen = new Pen(Color.Red, 2))
                {
                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    rect = new Rectangle(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x1 - x2), Math.Abs(y1 - y2));
                    gr.DrawRectangle(pen, rect);
                }
            }

            // Display the temporary bitmap.
            pbRect.Image = bm;

            // Update
            pbRect.Refresh();
        }

        /// <summary>
        /// Handle visible state toggling
        /// </summary>
        private void pbRect_VisibleChanged(object sender, EventArgs e)
        {
            // Check if it's becoming visible
            if (this.Visible)
            {
                // It is; center form
                this.CenterToScreen();
            }
        }
    }
}


FormCapture

Code (csharp) Select
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DefinitionsGenerator
{
    public partial class FormCapture : Form
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public FormCapture()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Prevents window from closing
        /// </summary>
        private void FormCapture_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Set status to invisible
            this.Visible = false;

            // Cancel closing
            e.Cancel = true;
        }


        /// <summary>
        /// Handle visible/invisible toggling
        /// </summary>
        private void FormCapture_VisibleChanged(object sender, EventArgs e)
        {
            // Check if it's becoming visible
            if (this.Visible)
            {
                // It is; center form
                this.CenterToScreen();
               
                // Prepare assigned on locations class
                Locations.clearAssigned();

                // Set title
                FormCapture_MouseMove(sender, new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 0, 0, 0));
            }
        }

        /// <summary>
        /// Handles MouseMove
        /// </summary>
        private void FormCapture_MouseMove(object sender, MouseEventArgs e)
        {
            this.Text = "Please click on " + Locations.getNextLocation() + "   [x: " + e.X + ", y:" + e.Y + "]";
        }

        /// <summary>
        /// Handles MouseClick on form
        /// </summary>
        private void FormCapture_MouseClick(object sender, MouseEventArgs e)
        {
            // Check if it's a right click
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                // Undo
                Locations.undoAssigned();

                // Halt
                return;
            }
           
            // Add current location
            Locations.addAssigned(new Point(e.X, e.Y));

            // Check if it's the last one
            if (Locations.getNextLocation() == string.Empty)
            {
                // Coordinates are done
                this.Visible = false;
            }
        }
    }
}

Email/Paypal: betselectiongmail.com
-- Victor

VLS

Win32

Code (csharp) Select
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace DefinitionsGenerator
{
    static class Win32
    {
        [Flags]
        public enum MouseEventFlags
        {
            LEFTDOWN = 0x00000002,
            LEFTUP = 0x00000004,
            MIDDLEDOWN = 0x00000020,
            MIDDLEUP = 0x00000040,
            MOVE = 0x00000001,
            ABSOLUTE = 0x00008000,
            RIGHTDOWN = 0x00000008,
            RIGHTUP = 0x00000010
        }

        public static void Click(int x, int y)
        {
            // Set cursor position
            Cursor.Position = new System.Drawing.Point(x, y);

            // Perform click
            mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
            mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);
        }
       
        [DllImport("user32.dll")]
        static extern int GetSystemMetrics(SystemMetric smIndex);

        /// <summary>
        /// Flags used with the Windows API (User32.dll):GetSystemMetrics(SystemMetric smIndex)
        ///   
        /// This Enum and declaration signature was written by Gabriel T. Sharp
        /// ai_productions@verizon.net or osirisgothra@hotmail.com
        /// Obtained on pinvoke.net, please contribute your code to support the wiki!
        /// </summary>
        public enum SystemMetric : int
        {
            /// <summary>
            /// The flags that specify how the system arranged minimized windows. For more information, see the Remarks section in this topic.
            /// </summary>
            SM_ARRANGE = 56,

            /// <summary>
            /// The value that specifies how the system is started:
            /// 0 Normal boot
            /// 1 Fail-safe boot
            /// 2 Fail-safe with network boot
            /// A fail-safe boot (also called SafeBoot, Safe Mode, or Clean Boot) bypasses the user startup files.
            /// </summary>
            SM_CLEANBOOT = 67,

            /// <summary>
            /// The number of display monitors on a desktop. For more information, see the Remarks section in this topic.
            /// </summary>
            SM_CMONITORS = 80,

            /// <summary>
            /// The number of buttons on a mouse, or zero if no mouse is installed.
            /// </summary>
            SM_CMOUSEBUTTONS = 43,

            /// <summary>
            /// The width of a window border, in pixels. This is equivalent to the SM_CXEDGE value for windows with the 3-D look.
            /// </summary>
            SM_CXBORDER = 5,

            /// <summary>
            /// The width of a cursor, in pixels. The system cannot create cursors of other sizes.
            /// </summary>
            SM_CXCURSOR = 13,

            /// <summary>
            /// This value is the same as SM_CXFIXEDFRAME.
            /// </summary>
            SM_CXDLGFRAME = 7,

            /// <summary>
            /// The width of the rectangle around the location of a first click in a double-click sequence, in pixels. ,
            /// The second click must occur within the rectangle that is defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system
            /// to consider the two clicks a double-click. The two clicks must also occur within a specified time.
            /// To set the width of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKWIDTH.
            /// </summary>
            SM_CXDOUBLECLK = 36,

            /// <summary>
            /// The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins.
            /// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
            /// If this value is negative, it is subtracted from the left of the mouse-down point and added to the right of it.
            /// </summary>
            SM_CXDRAG = 68,

            /// <summary>
            /// The width of a 3-D border, in pixels. This metric is the 3-D counterpart of SM_CXBORDER.
            /// </summary>
            SM_CXEDGE = 45,

            /// <summary>
            /// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
            /// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
            /// This value is the same as SM_CXDLGFRAME.
            /// </summary>
            SM_CXFIXEDFRAME = 7,

            /// <summary>
            /// The width of the left and right edges of the focus rectangle that the DrawFocusRectdraws.
            /// This value is in pixels.
            /// Windows 2000:  This value is not supported.
            /// </summary>
            SM_CXFOCUSBORDER = 83,

            /// <summary>
            /// This value is the same as SM_CXSIZEFRAME.
            /// </summary>
            SM_CXFRAME = 32,

            /// <summary>
            /// The width of the client area for a full-screen window on the primary display monitor, in pixels.
            /// To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars,
            /// call the SystemParametersInfofunction with the SPI_GETWORKAREA value.
            /// </summary>
            SM_CXFULLSCREEN = 16,

            /// <summary>
            /// The width of the arrow bitmap on a horizontal scroll bar, in pixels.
            /// </summary>
            SM_CXHSCROLL = 21,

            /// <summary>
            /// The width of the thumb box in a horizontal scroll bar, in pixels.
            /// </summary>
            SM_CXHTHUMB = 10,

            /// <summary>
            /// The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions
            /// that SM_CXICON and SM_CYICON specifies.
            /// </summary>
            SM_CXICON = 11,

            /// <summary>
            /// The width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
            /// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CXICON.
            /// </summary>
            SM_CXICONSPACING = 38,

            /// <summary>
            /// The default width, in pixels, of a maximized top-level window on the primary display monitor.
            /// </summary>
            SM_CXMAXIMIZED = 61,

            /// <summary>
            /// The default maximum width of a window that has a caption and sizing borders, in pixels.
            /// This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions.
            /// A window can override this value by processing the WM_GETMINMAXINFO message.
            /// </summary>
            SM_CXMAXTRACK = 59,

            /// <summary>
            /// The width of the default menu check-mark bitmap, in pixels.
            /// </summary>
            SM_CXMENUCHECK = 71,

            /// <summary>
            /// The width of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
            /// </summary>
            SM_CXMENUSIZE = 54,

            /// <summary>
            /// The minimum width of a window, in pixels.
            /// </summary>
            SM_CXMIN = 28,

            /// <summary>
            /// The width of a minimized window, in pixels.
            /// </summary>
            SM_CXMINIMIZED = 57,

            /// <summary>
            /// The width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
            /// This value is always greater than or equal to SM_CXMINIMIZED.
            /// </summary>
            SM_CXMINSPACING = 47,

            /// <summary>
            /// The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
            /// A window can override this value by processing the WM_GETMINMAXINFO message.
            /// </summary>
            SM_CXMINTRACK = 34,

            /// <summary>
            /// The amount of border padding for captioned windows, in pixels. Windows XP/2000:  This value is not supported.
            /// </summary>
            SM_CXPADDEDBORDER = 92,

            /// <summary>
            /// The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling
            /// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).
            /// </summary>
            SM_CXSCREEN = 0,

            /// <summary>
            /// The width of a button in a window caption or title bar, in pixels.
            /// </summary>
            SM_CXSIZE = 30,

            /// <summary>
            /// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
            /// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
            /// This value is the same as SM_CXFRAME.
            /// </summary>
            SM_CXSIZEFRAME = 32,

            /// <summary>
            /// The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
            /// </summary>
            SM_CXSMICON = 49,

            /// <summary>
            /// The width of small caption buttons, in pixels.
            /// </summary>
            SM_CXSMSIZE = 52,

            /// <summary>
            /// The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
            /// The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen.
            /// </summary>
            SM_CXVIRTUALSCREEN = 78,

            /// <summary>
            /// The width of a vertical scroll bar, in pixels.
            /// </summary>
            SM_CXVSCROLL = 2,

            /// <summary>
            /// The height of a window border, in pixels. This is equivalent to the SM_CYEDGE value for windows with the 3-D look.
            /// </summary>
            SM_CYBORDER = 6,

            /// <summary>
            /// The height of a caption area, in pixels.
            /// </summary>
            SM_CYCAPTION = 4,

            /// <summary>
            /// The height of a cursor, in pixels. The system cannot create cursors of other sizes.
            /// </summary>
            SM_CYCURSOR = 14,

            /// <summary>
            /// This value is the same as SM_CYFIXEDFRAME.
            /// </summary>
            SM_CYDLGFRAME = 8,

            /// <summary>
            /// The height of the rectangle around the location of a first click in a double-click sequence, in pixels.
            /// The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider
            /// the two clicks a double-click. The two clicks must also occur within a specified time. To set the height of the double-click
            /// rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKHEIGHT.
            /// </summary>
            SM_CYDOUBLECLK = 37,

            /// <summary>
            /// The number of pixels above and below a mouse-down point that the mouse pointer can move before a drag operation begins.
            /// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
            /// If this value is negative, it is subtracted from above the mouse-down point and added below it.
            /// </summary>
            SM_CYDRAG = 69,

            /// <summary>
            /// The height of a 3-D border, in pixels. This is the 3-D counterpart of SM_CYBORDER.
            /// </summary>
            SM_CYEDGE = 46,

            /// <summary>
            /// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
            /// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
            /// This value is the same as SM_CYDLGFRAME.
            /// </summary>
            SM_CYFIXEDFRAME = 8,

            /// <summary>
            /// The height of the top and bottom edges of the focus rectangle drawn byDrawFocusRect.
            /// This value is in pixels.
            /// Windows 2000:  This value is not supported.
            /// </summary>
            SM_CYFOCUSBORDER = 84,

            /// <summary>
            /// This value is the same as SM_CYSIZEFRAME.
            /// </summary>
            SM_CYFRAME = 33,

            /// <summary>
            /// The height of the client area for a full-screen window on the primary display monitor, in pixels.
            /// To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars,
            /// call the SystemParametersInfo function with the SPI_GETWORKAREA value.
            /// </summary>
            SM_CYFULLSCREEN = 17,

            /// <summary>
            /// The height of a horizontal scroll bar, in pixels.
            /// </summary>
            SM_CYHSCROLL = 3,

            /// <summary>
            /// The default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions SM_CXICON and SM_CYICON.
            /// </summary>
            SM_CYICON = 12,

            /// <summary>
            /// The height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
            /// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CYICON.
            /// </summary>
            SM_CYICONSPACING = 39,

            /// <summary>
            /// For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels.
            /// </summary>
            SM_CYKANJIWINDOW = 18,

            /// <summary>
            /// The default height, in pixels, of a maximized top-level window on the primary display monitor.
            /// </summary>
            SM_CYMAXIMIZED = 62,

            /// <summary>
            /// The default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop.
            /// The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing
            /// the WM_GETMINMAXINFO message.
            /// </summary>
            SM_CYMAXTRACK = 60,

            /// <summary>
            /// The height of a single-line menu bar, in pixels.
            /// </summary>
            SM_CYMENU = 15,

            /// <summary>
            /// The height of the default menu check-mark bitmap, in pixels.
            /// </summary>
            SM_CYMENUCHECK = 72,

            /// <summary>
            /// The height of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
            /// </summary>
            SM_CYMENUSIZE = 55,

            /// <summary>
            /// The minimum height of a window, in pixels.
            /// </summary>
            SM_CYMIN = 29,

            /// <summary>
            /// The height of a minimized window, in pixels.
            /// </summary>
            SM_CYMINIMIZED = 58,

            /// <summary>
            /// The height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
            /// This value is always greater than or equal to SM_CYMINIMIZED.
            /// </summary>
            SM_CYMINSPACING = 48,

            /// <summary>
            /// The minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
            /// A window can override this value by processing the WM_GETMINMAXINFO message.
            /// </summary>
            SM_CYMINTRACK = 35,

            /// <summary>
            /// The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling
            /// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).
            /// </summary>
            SM_CYSCREEN = 1,

            /// <summary>
            /// The height of a button in a window caption or title bar, in pixels.
            /// </summary>
            SM_CYSIZE = 31,

            /// <summary>
            /// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
            /// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
            /// This value is the same as SM_CYFRAME.
            /// </summary>
            SM_CYSIZEFRAME = 33,

            /// <summary>
            /// The height of a small caption, in pixels.
            /// </summary>
            SM_CYSMCAPTION = 51,

            /// <summary>
            /// The recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
            /// </summary>
            SM_CYSMICON = 50,

            /// <summary>
            /// The height of small caption buttons, in pixels.
            /// </summary>
            SM_CYSMSIZE = 53,

            /// <summary>
            /// The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
            /// The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen.
            /// </summary>
            SM_CYVIRTUALSCREEN = 79,

            /// <summary>
            /// The height of the arrow bitmap on a vertical scroll bar, in pixels.
            /// </summary>
            SM_CYVSCROLL = 20,

            /// <summary>
            /// The height of the thumb box in a vertical scroll bar, in pixels.
            /// </summary>
            SM_CYVTHUMB = 9,

            /// <summary>
            /// Nonzero if User32.dll supports DBCS; otherwise, 0.
            /// </summary>
            SM_DBCSENABLED = 42,

            /// <summary>
            /// Nonzero if the debug version of User.exe is installed; otherwise, 0.
            /// </summary>
            SM_DEBUG = 22,

            /// <summary>
            /// Nonzero if the current operating system is Windows 7 or Windows Server 2008 R2 and the Tablet PC Input
            /// service is started; otherwise, 0. The return value is a bitmask that specifies the type of digitizer input supported by the device.
            /// For more information, see Remarks.
            /// Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported.
            /// </summary>
            SM_DIGITIZER = 94,

            /// <summary>
            /// Nonzero if Input Method Manager/Input Method Editor features are enabled; otherwise, 0.
            /// SM_IMMENABLED indicates whether the system is ready to use a Unicode-based IME on a Unicode application.
            /// To ensure that a language-dependent IME works, check SM_DBCSENABLED and the system ANSI code page.
            /// Otherwise the ANSI-to-Unicode conversion may not be performed correctly, or some components like fonts
            /// or registry settings may not be present.
            /// </summary>
            SM_IMMENABLED = 82,

            /// <summary>
            /// Nonzero if there are digitizers in the system; otherwise, 0. SM_MAXIMUMTOUCHES returns the aggregate maximum of the
            /// maximum number of contacts supported by every digitizer in the system. If the system has only single-touch digitizers,
            /// the return value is 1. If the system has multi-touch digitizers, the return value is the number of simultaneous contacts
            /// the hardware can provide. Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported.
            /// </summary>
            SM_MAXIMUMTOUCHES = 95,

            /// <summary>
            /// Nonzero if the current operating system is the Windows XP, Media Center Edition, 0 if not.
            /// </summary>
            SM_MEDIACENTER = 87,

            /// <summary>
            /// Nonzero if drop-down menus are right-aligned with the corresponding menu-bar item; 0 if the menus are left-aligned.
            /// </summary>
            SM_MENUDROPALIGNMENT = 40,

            /// <summary>
            /// Nonzero if the system is enabled for Hebrew and Arabic languages, 0 if not.
            /// </summary>
            SM_MIDEASTENABLED = 74,

            /// <summary>
            /// Nonzero if a mouse is installed; otherwise, 0. This value is rarely zero, because of support for virtual mice and because
            /// some systems detect the presence of the port instead of the presence of a mouse.
            /// </summary>
            SM_MOUSEPRESENT = 19,

            /// <summary>
            /// Nonzero if a mouse with a horizontal scroll wheel is installed; otherwise 0.
            /// </summary>
            SM_MOUSEHORIZONTALWHEELPRESENT = 91,

            /// <summary>
            /// Nonzero if a mouse with a vertical scroll wheel is installed; otherwise 0.
            /// </summary>
            SM_MOUSEWHEELPRESENT = 75,

            /// <summary>
            /// The least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use.
            /// </summary>
            SM_NETWORK = 63,

            /// <summary>
            /// Nonzero if the Microsoft Windows for Pen computing extensions are installed; zero otherwise.
            /// </summary>
            SM_PENWINDOWS = 41,

            /// <summary>
            /// This system metric is used in a Terminal Services environment to determine if the current Terminal Server session is
            /// being remotely controlled. Its value is nonzero if the current session is remotely controlled; otherwise, 0.
            /// You can use terminal services management tools such as Terminal Services Manager (tsadmin.msc) and shadow.exe to
            /// control a remote session. When a session is being remotely controlled, another user can view the contents of that session
            /// and potentially interact with it.
            /// </summary>
            SM_REMOTECONTROL = 0x2001,

            /// <summary>
            /// This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services
            /// client session, the return value is nonzero. If the calling process is associated with the Terminal Services console session,
            /// the return value is 0.
            /// Windows Server 2003 and Windows XP:  The console session is not necessarily the physical console.
            /// For more information, seeWTSGetActiveConsoleSessionId.
            /// </summary>
            SM_REMOTESESSION = 0x1000,

            /// <summary>
            /// Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth,
            /// but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits,
            /// or those bits can be located in different places in a pixel color value.
            /// </summary>
            SM_SAMEDISPLAYFORMAT = 81,

            /// <summary>
            /// This system metric should be ignored; it always returns 0.
            /// </summary>
            SM_SECURE = 44,

            /// <summary>
            /// The build number if the system is Windows Server 2003 R2; otherwise, 0.
            /// </summary>
            SM_SERVERR2 = 89,

            /// <summary>
            /// Nonzero if the user requires an application to present information visually in situations where it would otherwise present
            /// the information only in audible form; otherwise, 0.
            /// </summary>
            SM_SHOWSOUNDS = 70,

            /// <summary>
            /// Nonzero if the current session is shutting down; otherwise, 0. Windows 2000:  This value is not supported.
            /// </summary>
            SM_SHUTTINGDOWN = 0x2000,

            /// <summary>
            /// Nonzero if the computer has a low-end (slow) processor; otherwise, 0.
            /// </summary>
            SM_SLOWMACHINE = 73,

            /// <summary>
            /// Nonzero if the current operating system is Windows 7 Starter Edition, Windows Vista Starter, or Windows XP Starter Edition; otherwise, 0.
            /// </summary>
            SM_STARTER = 88,

            /// <summary>
            /// Nonzero if the meanings of the left and right mouse buttons are swapped; otherwise, 0.
            /// </summary>
            SM_SWAPBUTTON = 23,

            /// <summary>
            /// Nonzero if the current operating system is the Windows XP Tablet PC edition or if the current operating system is Windows Vista
            /// or Windows 7 and the Tablet PC Input service is started; otherwise, 0. The SM_DIGITIZER setting indicates the type of digitizer
            /// input supported by a device running Windows 7 or Windows Server 2008 R2. For more information, see Remarks.
            /// </summary>
            SM_TABLETPC = 86,

            /// <summary>
            /// The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
            /// The SM_CXVIRTUALSCREEN metric is the width of the virtual screen.
            /// </summary>
            SM_XVIRTUALSCREEN = 76,

            /// <summary>
            /// The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
            /// The SM_CYVIRTUALSCREEN metric is the height of the virtual screen.
            /// </summary>
            SM_YVIRTUALSCREEN = 77,
        }

        /// <summary>
        /// Returns the window currently present below the cursor. i.e.
        /// </summary>
        /// <param name="point">Structure holding X, Y coordinates for current cursor location</param>
        /// <returns>IntPtr.Zero if no window was found</returns>
        public static IntPtr ChildWindowFromPoint(Point point)
        {

            IntPtr WindowPoint = WindowFromPoint(point);
            if (WindowPoint == IntPtr.Zero)
            {
                return IntPtr.Zero;
            }

            if (ScreenToClient(WindowPoint, ref point) == false)
            {
                throw new Exception("ScreenToClient failed");
            }

            IntPtr Window = ChildWindowFromPointEx(WindowPoint, point, 0);
            if (Window == IntPtr.Zero)
            {
                return WindowPoint;
            }

            if (ClientToScreen(WindowPoint, ref point) == false)
            {
                throw new Exception("ClientToScreen failed");
            }

            if (IsChild(GetParent(Window), Window) == false)
            {
                return Window;
            }

            // create a list to hold all childs under the point
            ArrayList WindowList = new ArrayList();
            while (Window != IntPtr.Zero)
            {
                Rectangle rect = GetWindowRect(Window);
                if (rect.Contains(point))
                {
                    WindowList.Add(Window);
                }
                Window = GetWindow(Window, Convert.ToUInt32(GetWindow_Cmd.GW_HWNDNEXT));
            }

            // search for the smallest window in the list
            int MinPixel = GetSystemMetrics(SystemMetric.SM_CXFULLSCREEN) * GetSystemMetrics(SystemMetric.SM_CYFULLSCREEN);
            for (int i = 0; i <= WindowList.Count - 1; i++)
            {
                Rectangle rect = GetWindowRect((IntPtr)WindowList[i]);
                int ChildPixel = rect.Width * rect.Height;
                if (ChildPixel < MinPixel)
                {
                    MinPixel = ChildPixel;
                    Window = (IntPtr)WindowList[i];
                }
            }

            return Window;
        }

Email/Paypal: betselectiongmail.com
-- Victor

VLS

Code (csharp) Select
//' WIN32 API (Window handling)

        // Must have System.Runtime.InteropServices
        [DllImport("user32.dll")]
        extern static bool GetCursorPos(ref Point lpPoint);

        [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {

            public int Left;
            public int Top;
            public int Right;

            public int Bottom;
            public Rectangle ToRectangle()
            {
                return new Rectangle(Left, Top, Right - Left, Bottom - Top);
            }

        }

        [DllImport("user32.dll")]
        extern static IntPtr WindowFromPoint(Point point);

        [DllImport("user32.dll")]
        extern static bool ScreenToClient(IntPtr handle, ref Point point);

        [DllImport("user32.dll")]
        extern static IntPtr ChildWindowFromPointEx(IntPtr hWndParent, Point pt, uint uFlags);

        [DllImport("user32.dll")]
        extern static bool ClientToScreen(IntPtr hwnd, ref Point lpPoint);

        [DllImport("user32.dll")]
        extern static bool IsChild(IntPtr hWndParent, IntPtr hWnd);

        [DllImport("user32.dll")]
        extern static IntPtr GetParent(IntPtr hWnd);

        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        extern static IntPtr GetAncestor(IntPtr hWnd, int flags);

        public enum GetAncestor_Flags
        {
            GetParent = 1,
            GetRoot = 2,
            GetRootOwner = 3
        }

        public enum GetWindow_Cmd : uint
        {
            GW_HWNDFIRST = 0,
            GW_HWNDLAST = 1,
            GW_HWNDNEXT = 2,
            GW_HWNDPREV = 3,
            GW_OWNER = 4,
            GW_CHILD = 5,
            GW_ENABLEDPOPUP = 6
        }

        [DllImport("user32.dll")]
        extern static IntPtr GetWindow(IntPtr hWnd, uint uCmd);

        [DllImport("user32.dll")]
        extern static bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);

        [DllImport("user32.dll")]
        extern static IntPtr GetWindowDC(IntPtr hWnd);

        [DllImport("user32.dll")]
        extern static int GetWindowTextLength(IntPtr hWnd);

        [DllImport("user32.dll")]
        extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

        [DllImport("user32.dll")]
        extern public static int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

        [DllImport("user32.dll")]
        extern static Int32 ReleaseDC(IntPtr hWnd, IntPtr hdc);

        [DllImport("user32.dll", SetLastError = true)]
        private extern static int GetWindowLong(IntPtr hWnd, [MarshalAs(UnmanagedType.I4)]
WindowLongFlags nIndex);

        public enum WindowLongFlags : int
        {
            GWL_EXSTYLE = -20,
            GWLP_HINSTANCE = -6,
            GWLP_HWNDPARENT = -8,
            GWL_ID = -12,
            GWL_STYLE = -16,
            GWL_USERDATA = -21,
            GWL_WNDPROC = -4,
            DWLP_USER = 0x8,
            DWLP_MSGRESULT = 0x0,
            DWLP_DLGPROC = 0x4
        }

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        extern static bool GetWindowRect(HandleRef hWnd, ref RECT lpRect);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        // SetCursorPos
        extern static int SetCursorPos(int X, int Y);
        [DllImport("user32", EntryPoint = "mouse_event", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        // mouse_event
        extern static void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

        // mouse_event constants
        public const int MOUSEEVENTF_LEFTDOWN = 0x2;

        public const int MOUSEEVENTF_LEFTUP = 0x4;
        // Helper function returns a Rectangle object directly
        public static Rectangle GetWindowRect(IntPtr hWnd)
        {
            Debug.Assert(hWnd != IntPtr.Zero);
            RECT rect = new RECT();
            if (GetWindowRect(hWnd, ref rect) == false)
            {
                throw new Exception("GetWindowRect failed");
            }
            return rect.ToRectangle();
        }

        /// <summary>
        /// Gets window text (title) from passed window
        /// </summary>
        /// <param name="hWnd">Target window</param>
        /// <returns>String with text/title</returns>
        public static string GetWindowText(IntPtr hWnd)
        {
            Debug.Assert(hWnd != IntPtr.Zero);
            StringBuilder WindowText = new StringBuilder(GetWindowTextLength(hWnd) + 1);
            GetWindowText(hWnd, WindowText, WindowText.Capacity);
            return WindowText.ToString();
        }

        //' GDI (Graphics)

        public enum RopMode : int
        {
            R2_NOT = 6
        }

        [DllImport("gdi32.dll")]
        extern static int SetROP2(IntPtr hdc, int fnDrawMode);

        public enum PenStyles : int
        {
            PS_INSIDEFRAME = 6
        }
        [DllImport("gdi32.dll")]
        extern static IntPtr CreatePen(int fnPenStyle, int nWidth, uint crColor);

        [DllImport("gdi32.dll")]
        extern static IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);

        public enum StockObjects : int
        {
            NULL_BRUSH = 5
        }
        [DllImport("gdi32.dll")]
        extern static IntPtr GetStockObject(int fnObject);

        [DllImport("gdi32.dll")]
        extern static uint Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);

        [DllImport("gdi32.dll")]
        extern static bool DeleteObject(IntPtr hObject);


        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool IsWindow(IntPtr hWnd);

        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        extern static bool IsWindowVisible(IntPtr hwnd);
        [DllImport("user32", EntryPoint = "GetWindowTextA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int GetWindowText(int hWnd, string lpString, int nMaxCount);
        [DllImport("gdi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]


        ///'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        private static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop);
        [DllImport("gdi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        private static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight);
        [DllImport("gdi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        private static extern IntPtr CreateCompatibleDC(IntPtr hDC);
        [DllImport("gdi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]

        private static extern bool DeleteDC(IntPtr hDC);


        private const int SRCCOPY = 0xcc0020;
        public static Image CaptureWindow(IntPtr handle)
        {

            // Check if it is a window for a start
            if (IsWindow(handle) == false)
            {
                // Clear picturebox
                //fCapture.BackgroundImage = null;

                // Halt
                return null;
            }

            // get te hDC of the target window
            IntPtr hdcSrc = GetWindowDC(handle);

            // get the size
            RECT windowRect = new RECT();

            GetWindowRect(handle, ref windowRect);

            int width = windowRect.Right - windowRect.Left;

            int height = windowRect.Bottom - windowRect.Top;

            // create a device context we can copy to
            IntPtr hdcDest = CreateCompatibleDC(hdcSrc);

            // create a bitmap we can copy it to,
            // using GetDeviceCaps to get the width/height
            IntPtr hBitmap = CreateCompatibleBitmap(hdcSrc, width, height);

            // select the bitmap object
            IntPtr hOld = SelectObject(hdcDest, hBitmap);

            // bitblt over
            BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);

            // restore selection
            SelectObject(hdcDest, hOld);

            // clean up
            DeleteDC(hdcDest);

            ReleaseDC(handle, hdcSrc);

            // get a .NET image object for it
            Image img = Image.FromHbitmap(hBitmap);

            // free up the Bitmap object
            DeleteObject(hBitmap);

            return img;

        }
        //CaptureWindow

        /// <summary>
        /// Paint a rect into the given window
        /// </summary>
        /// <param name="window">Pointer/Handle identifying window on which inverted rectangle is going to be painted</param>
        ///

        public static void ShowInvertRectTracker(IntPtr window)
        {

            if (window != IntPtr.Zero)
            {
                // get the coordinates from the window on the screen
                Rectangle WindowRect = GetWindowRect(window);

                // get the window's device context
                IntPtr dc = GetWindowDC(window);

                // Create an inverse pen that is the size of the window border
                SetROP2(dc, Convert.ToInt32(RopMode.R2_NOT));

                Color cColor = Color.FromArgb(0, 255, 0);
                IntPtr Pen = CreatePen(6, GetSystemMetrics(SystemMetric.SM_CXBORDER) * 3, Convert.ToUInt32(ColorTranslator.ToWin32(cColor)));

                // Draw the rectangle around the window
                IntPtr OldPen = SelectObject(dc, Pen);
                IntPtr OldBrush = SelectObject(dc, GetStockObject(Convert.ToInt32(StockObjects.NULL_BRUSH)));
                Rectangle(dc, 0, 0, WindowRect.Width, WindowRect.Height);

                SelectObject(dc, OldBrush);
                SelectObject(dc, OldPen);

                //release the device context, and destroy the pen
                ReleaseDC(window, dc);
                DeleteObject(Pen);
            }
        }
    }
}

Email/Paypal: betselectiongmail.com
-- Victor

VLS

Holy potatoes! Near 3:00 a.m. here!!

See you tomorrow guys. Hopefully more people join as sponsor so I can devote more daytime hours.

Do leave some feedback after using.

Cheers!
Vic

Email/Paypal: betselectiongmail.com
-- Victor

weddings

The ocr is not functional yet right?



Also for the "last number rectangle" do we select the white or yellow arrow?

VLS

Quote from: weddings on August 07, 2013, 09:10:16 AMThe ocr is not functional yet right?
Right, generator's mission is to "seed" the OCR on the tracker itself. The tracker consumes whatever casino is configured by the user, hence it doesn't need to be updated by original programmer to support new casinos ever again :)

Quote from: weddings on August 07, 2013, 09:10:16 AMAlso for the "last number rectangle" do we select the white or yellow arrow?
It doesn't matter as long as all numbers are grabbed exactly from the same space without any parts of other numbers within the rectangle.

Email/Paypal: betselectiongmail.com
-- Victor

weddings

Please check I am unable to save the image of 36 tried that twice.

VLS

New version saves + recognizes numbers.


Stay tuned.

Email/Paypal: betselectiongmail.com
-- Victor