コード例 #1
0
        private static bool PostEnterKeyCharToProcess(IntPtr processHandle, int waitTime)
        {
            System.Threading.Thread.Sleep(waitTime);

            // 0xD:Enter
            return(Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x0000000D, 0x001C0001) != 0);
        }
コード例 #2
0
        private static bool PostSpaceKeyInputToProcess(IntPtr processHandle, int waitTime)
        {
            System.Threading.Thread.Sleep(waitTime);

            // 0x20:Space
            if (Win32Controller.PostMessage(processHandle, Win32Controller.WmKeyDown, 0x00000020, 0x00390001) != 0)
            {
                System.Threading.Thread.Sleep(waitTime);
                return(Win32Controller.PostMessage(processHandle, Win32Controller.WmKeyUp, 0x00000020, 0xC0390001) != 0);
            }

            return(false);
        }
コード例 #3
0
        private static bool PostEnterKeyInputToProcess(IntPtr processHandle, int waitTime)
        {
            System.Threading.Thread.Sleep(waitTime);

            // 0xD:Enter
            if (Win32Controller.PostMessage(processHandle, Win32Controller.WmKeyDown, 0x0000000D, 0x001C0001) != 0)
            {
                System.Threading.Thread.Sleep(waitTime);
                return(Win32Controller.PostMessage(processHandle, Win32Controller.WmKeyUp, 0x0000000D, 0xC01C0001) != 0);
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// 与えられたプロセスに対し、約waitTime[ms]後にクライアント座標(x,y)の位置にマウスクリックイベントを起こす
        /// </summary>
        /// <param name="processHandle">
        /// The process Handle.
        /// </param>
        /// <param name="waitTime">
        /// The wait Time.
        /// </param>
        /// <param name="x">
        /// The x.
        /// </param>
        /// <param name="y">
        /// The y.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private static bool PostMlbClickToProcess(IntPtr processHandle, int waitTime, ushort x, ushort y)
        {
            // wait
            System.Threading.Thread.Sleep(waitTime);

            // マウスクリックダウン
            if (Win32Controller.PostMessage(
                    processHandle,
                    Win32Controller.WmLButtonDown,
                    Win32Controller.MkLBotton,
                    Win32Controller.MakeLParam(x, y)) == 0)
            {
                return(false);
            }

            System.Threading.Thread.Sleep(waitTime);

            // マウスクリックアップ
            return(Win32Controller.PostMessage(
                       processHandle,
                       Win32Controller.WmLButtonUp,
                       0x00000000,
                       Win32Controller.MakeLParam(x, y)) != 0);
        }
コード例 #5
0
        private static bool PostKeyCharToProcess(IntPtr processHandle, string keys, int intervalTime)
        {
            foreach (var item in keys)
            {
                System.Threading.Thread.Sleep(intervalTime);

                // 0x20:Space
                if (Regex.IsMatch(item.ToString(), @"^ $"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x00000020, 0x001E0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x2E:Dot
                if (Regex.IsMatch(item.ToString(), @"^\.$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x0000002E, 0x001E0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x40:@
                if (Regex.IsMatch(item.ToString(), @"^@$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x00000040, 0x001E0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x5F:_
                if (Regex.IsMatch(item.ToString(), @"^_$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x0000005F, 0x00730001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x2D:-
                if (Regex.IsMatch(item.ToString(), @"^-$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x0000002D, 0x000C0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x21:!
                if (Regex.IsMatch(item.ToString(), @"^!$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x00000021, 0x00020001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x3F:?
                if (Regex.IsMatch(item.ToString(), @"^\?$"))
                {
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, 0x0000003F, 0x00350001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x30:0
                if (Regex.IsMatch(item.ToString(), @"^[0-9]$"))
                {
                    uint wparam = 0x00000030 + (uint)(item - '0');
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, wparam, 0x001E0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x41:A
                if (Regex.IsMatch(item.ToString(), @"^[A-Z]$"))
                {
                    uint wparam = 0x00000041 + (uint)(item - 'A');
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, wparam, 0x001E0001) == 0)
                    {
                        return(false);
                    }

                    continue;
                }

                // 0x61:a
                if (Regex.IsMatch(item.ToString(), @"^[a-z]$"))
                {
                    uint wparam = 0x00000061 + (uint)(item - 'a');
                    if (Win32Controller.PostMessage(processHandle, Win32Controller.WmChar, wparam, 0x001E0001) == 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }