我正在尝试获取Outlook C#外接程序,以便使用SendMessage滚动左侧导航窗格。这似乎没有效果。外接程序是否在比Outlook更低的权限级别下运行,因此由于UIPI而阻止SendMessage工作?
我使用EnumChildWindows (它是递归的)迭代来查找左侧导航窗格的子窗口的句柄,就像使用Spy++标识的那样,使用GetWindowText通过类名查找它。"workerBeeFunc“是由EnumChildWindows调用的委托。Spy++告诉我导航窗格窗口是第二个窗口的子窗口,第二个窗口的类名是"NUIDocumentWindow“(我把所有的WinAPI DLLImport语句都留在这里了):
private const int WM_VSCROLL = 277; // Vertical scroll
private const int SB_PAGEDOWN = 3; // Scrolls one page down
static StringBuilder childWindowNames = new StringBuilder();
private int NUIWindowCounter = 0;
private stopIterating as bool = false;
public delegate int EnumChildProc(IntPtr hWnd, IntPtr lParam); //Declare the delegate
public int workerBeeFunc(IntPtr hwndChild, IntPtr Param) //The function the delegate of EnumChildWindows goes to to get the work done.
{
int a;
a = WinAPIs.GetWindowText(hwndChild, childWindowNames, 100); //childWindowNames gets cleared on each iteration of this function
if (childWindowNames.ToString() == "NUIDocumentWindow")
{
NUIWindowCounter++;
if (NUIWindowCounter == 2) //The NEXT window is the Navigation Pane
{
stopIterating = true;
}
return 1; //Keep iterating
}
if (stopIterating == true)
{
SendMessage(hwndChild, WM_VSCROLL, (IntPtr)SB_PAGEDOWN, IntPtr.Zero);
return 0; //Stop iterating
}
}SendMessage会因为UIPI而静默失败吗?
谢谢。
发布于 2014-08-15 12:05:52
外接程序在与Outlook本身相同的安全上下文中运行。
任何控件都不需要使用WM_VSCROLL消息。你真的在Spy++中看到它了吗?
https://stackoverflow.com/questions/25320794
复制相似问题