예제 #1
0
        private static void ProcessMenu(IntPtr Handler)
        {
            int MenuCount = GetMenuItemCount(Handler);

            if (MenuCount == -1)
            {
                return;
            }
            var MenuInfo = new MENUITEMINFO();

            for (int i = 0; i < MenuCount; i++)
            {
                MenuInfo = new MENUITEMINFO()
                {
                    cbSize     = MENUITEMINFO.SizeOf,
                    fMask      = MIIM_STRING | MIIM_SUBMENU,
                    fType      = MFT_STRING,
                    dwTypeData = new string(new char[1024]),
                    cch        = 1025
                };

                bool Sucess = GetMenuItemInfo(Handler, i, true, ref MenuInfo);

                string Ori = MenuInfo.dwTypeData;

                if (Replys.Contains(SimplfyMatch(Ori)))
                {
                    continue;
                }

                string Reload = StrMap(Ori, IntPtr.Zero, true);
                CacheReply(Reload);

                if (MenuInfo.hSubMenu != IntPtr.Zero)
                {
                    ProcessMenu(MenuInfo.hSubMenu);
                }

                if (!Sucess)
                {
                    continue;
                }

                if (Ori == Reload)
                {
                    continue;
                }

                MenuInfo.dwTypeData = Reload;

                Sucess = SetMenuItemInfo(Handler, i, true, ref MenuInfo);

                if (InvalidateWindow)
                {
                    ForcePaint(Handler);
                }
            }
        }
예제 #2
0
        private static bool ProcessWindow(IntPtr Handler, int Parameters)
        {
            int           Len = GetWindowTextLength(Handler);
            StringBuilder sb  = new StringBuilder(Len + 1);

            GetWindowText(Handler, sb, sb.Capacity);

            string Ori = sb.ToString();

            if (Replys.Contains(SimplfyMatch(Ori)))
            {
                return(true);
            }

            uint HandlePID;

            GetWindowThreadProcessId(Handler, out HandlePID);

            if (HandlePID == GamePID)
            {
                var CB = new CallBack(ProcessWindow);
                EnumChildWindows(Handler, CB, IntPtr.Zero);
            }
            else
            {
                return(true);
            }

            string Reload = StrMap(Ori, IntPtr.Zero, true);

            CacheReply(Reload);

            if (Ori == Reload)
            {
                return(true);
            }


            HandleRef href = new HandleRef(null, Handler);

            SendMessage(href, WM_SETTEXT, IntPtr.Zero, Reload);

            if (InvalidateWindow)
            {
                ForcePaint(Handler);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Check if a String is in the cache
        /// </summary>
        /// <param name="Str">The Reply String</param>
        internal static bool InCache(string Str)
        {
            string Reply = SimplfyMatch(Str);

            if (Replys.Contains(Reply))
            {
                return(true);
            }

            int Last = ReplyPtr - 1;

            if (Last < 0)
            {
                Last = CacheLength;
            }

            if (Replys.Count > Last && (Replys[Last].EndsWith(Reply) || Replys[Last].StartsWith(Reply)) && Replys[Last].Length >= 3)
            {
                return(true);
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Add a Reply to the Cache
        /// </summary>
        /// <param name="Str">The Reply String</param>
        internal static void CacheReply(string Str)
        {
            string Reply = SimplfyMatch(Str);

            if (Replys.Contains(Reply))
            {
                return;
            }

            if (ReplyPtr > 200)
            {
                ReplyPtr = 0;
            }

            Replys.Insert(ReplyPtr++, Reply);

#if DEBUG
            if (Debugging)
            {
                Log("\"{0}\" Added to the cache at {1}", false, Reply, ReplyPtr - 1);
            }
#endif
        }