2013-03-27 103 views
2

我正在通過.net中的UIAuomation Clients API進行操作,並且必須使用C++而不是C#。這是因爲SendInput函數僅在C++中可用,並且似乎是向任何應用程序發送鼠標點擊最可靠的方法(與此問題相同的問題:How to manipulate a control without any pattern implemented?)。.net UIAutomation C++中的簡單示例

現在我正在苦於CIA版本的UIAutomation API,因爲缺少msdn文檔。有人可以告訴如何使用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++)的鏈接將非常有用。

感謝

+0

點點offtopic,但......有你看着像http://inputsimulator.codeplex.com/或白色的東西? – Offler 2013-03-27 14:10:51

+0

我試圖不使用任何第三方代碼,只堅持.NET的能力。我也看到了其他一些開源的東西。謝謝 – vegeta 2013-03-27 14:17:53

回答