using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;
namespace TextSendKeys
{
class Program
{
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void Main(string[] args)
{
Process[] processes = Process.GetProcessesByName("game");
Process game1 = processes[0];
IntPtr p = game1.MainWindowHandle;
ShowWindow(p,1);
SendKeys.SendWait("{DOWN}");
Thread.Sleep(1000);
SendKeys.SendWait("{DOWN}");
}
}
}
这个程序应该在游戏窗口中发送两次向下按钮。只有当我的窗口最小化时,它才能正常工作(它会激活窗口并完成任务)。如果我的窗口被激活(没有最小化),什么都不会发生。如何解决这个问题?
谢谢!:)