我的C#代码有点问题。我有的脚本,找到一个特定的窗口标题弹出,然后关闭它。它们是两个独立的脚本,我想将它们合并为一个。 (不能添加图像,因为还没有足够的代表。)
我的问题所在的代码如下:
public void Main()
{
foreach (KeyValuePair<IntPtr, string> window in OpenWindowGetter.GetOpenWindows())
{
IntPtr handle = window.Key;
string title = window.Value;
// Console.WriteLine("{0}: {1}", handle, title);
if (title == Dts.Variables["User::WindowText"].Value.ToString())
{
// close window
MessageBox.Show(title);
SendMessage(title, WM_SYSCOMMAND, SC_CLOSE, 0);
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
在发送消息时错误显示:
The best overloaded method match for '*NameSpace*.ScriptMain.SendMessage(int, uint, int, int) has some invalid arguments.
关闭错误的原始代码位于http://www.codeproject.com/Articles/22257/Find-and-Close-the-Window-using-Win-API