Пример #1
0
        public static bool SimulateText(Process process, string value)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                char[] array = value.ToCharArray();
                for (int i = 0; i < array.Length; i++)
                {
                    char wParam = array[i];
                    if (!ProgramThread.PostMessage(mainWindowHandle, 258u, (int)wParam, 0))
                    {
                        result = false;
                        return(result);
                    }
                }
                result = true;
            }
            return(result);
        }
Пример #2
0
        public static bool SimulateClick(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                bool flag = ProgramThread.PostMessage(mainWindowHandle, 513u, 1, y << 16 | (x & 65535));
                Thread.Sleep(120);
                bool flag2 = ProgramThread.PostMessage(mainWindowHandle, 514u, 1, y << 16 | (x & 65535));
                result = (flag && flag2);
            }
            return(result);
        }