【发布时间】:2013-03-30 18:49:29
【问题描述】:
我在 .Net 中通过 UIAuomation Clients API 并且必须使用 C++ 而不是 C#。这是因为 SendInput 函数仅在 C++ 中可用,并且似乎是将鼠标点击发送到任何应用程序的最可靠方法(与此问题相同:How to manipulate a control without any pattern implemented?)。
由于缺少有关 msdn 的文档,现在我正在努力使用 C++ 版本的 UIAutomation API。有人可以告诉如何使用CreatePropertyCondition、UIA_NamePropertyId 和“Windows Media Player”创建 PropertyCondition。
char *name = new char[30];
strcpy(name, "Windows Media Player");
VARIANT vt;
vt.vt = VT_CARRAY; // This is probably wrong
vt.pcVal = name;
hr = g_pAutomation->CreatePropertyCondition(UIA_NamePropertyId, vt, &condition);
if(!SUCCEEDED(hr)){
printf("Cannot createpropertycondition in getWMP\n");
return hr;
}
我总是进入if 条件。 g_pAutomation 变量工作正常,我能够很好地获取 RootElement。
还有一个简单教程/示例(C++ 语言)的链接将非常有用。
谢谢
【问题讨论】:
-
有点离题,但是...你看过类似inputsimulator.codeplex.com或白色的东西吗?
-
我尽量不使用任何第三方代码,只坚持 .NET 的能力。我也确实看到了其他一些开源的东西。谢谢