示例#1
0
        public void Initialize()
        {
            Log($"Initialize");
            initilialized = false;
            hwnds         = new List <IntPtr>();
            List <IntPtr> ids = new List <IntPtr>();

            IntPtr tempId = FindWindow(null, "play ngu idle, a free online game on kongregate");

            if (tempId != null && tempId != new IntPtr(0x00000000))
            {
                ids.Add(tempId);
            }

            AddHawndDelegate myCallBack = new AddHawndDelegate(addHawndCallback);

            EnumWindows(myCallBack, IntPtr.Zero);

            foreach (IntPtr hwnd in hwnds)
            {
                StringBuilder sb = new StringBuilder();
                try
                {
                    int length = GetWindowTextLength((IntPtr)hwnd);
                    sb = new StringBuilder(length + 1);
                    GetWindowText((IntPtr)hwnd, sb, sb.Capacity);
                }
                catch { }
                if (sb.ToString().ToLower().Contains("play ngu idle"))
                {
                    ids.Add((IntPtr)hwnd);
                }
            }

            Point point = new Point();

            foreach (IntPtr id in ids.Distinct().ToList())
            {
                if (PixelSearch(out point, Color.FromArgb(0, 4, 8), NGUIdleMasterWindowConstants.rectBase, true, id))
                {
                    Log($"{id,8} - Found - Point.X: {point.X} - Point.Y: {point.Y}");
                    this.id       = id;
                    this.point    = point;
                    initilialized = true;
                    break;
                }
                else
                {
                    Log($"{id, 8} - Not Found");
                }
            }

            Log($"Point.X: {point.X} - Point.Y: {point.Y}");
        }
示例#2
0
 private static extern bool EnumWindows(AddHawndDelegate dg, IntPtr lParam);