我正在尝试编写一个程序,它将获取一行数据并将其传递到另一个窗口/进程.
这是我到目前为止的代码,但我还没有弄清楚如何将键盘命令发送到OUTLOOK进程.
我希望能够使用Tab命令/键和Enter命令/键.
这是我到目前为止所尝试的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Forms;
namespace Config
{
class Program
{
[STAThread]
static void Main(string[] args)
{
System.Threading.Thread.Sleep(30);//300000
TextReader tr = new StreamReader("config.txt");
Clipboard.SetText(tr.ReadLine());
tr.Close();
var proc = Process.GetProcessesByName("OUTLOOK").FirstOrDefault();
if (proc != null && proc.MainWindowHandle != IntPtr.Zero)
{
SetForegroundWindow(proc.MainWindowHandle);
//SendKeys.Send("{ENTER}");
// Clipboard.GetText();
}
}
[DllImport("user32")]
private static extern bool SetForegroundWindow(IntPtr hwnd);
}
}
Run Code Online (Sandbox Code Playgroud) 我一直在 microsoft visual studio 2013 中乱搞,我制作了一个控制台应用程序,但我想知道是否有办法为其设置固定大小(高度/宽度),这意味着它无法调整大小?如果有人知道这是否可行,如果您能帮助我,我将不胜感激。谢谢!