I have an AutomationElement A (MS UI Automation), which represents a combo box. I want to select n-th item in that combo box using Windows API call

IntPtr ComboBox_SetCurSel(IntPtr hWnd, int index)

A.NativeWindowHandle contains the handle of the combo box, but in order to pass it to ComboBox_SetCurSel, I need to convert it from int to IntPtr.

How?

有帮助吗?

解决方案

Use the IntPtr(int) constructor.

IntPtr WindowHandle = new IntPtr(A.Current.NativeWindowHandle);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top