基本思路为,寻找开始菜单按钮窗口,并模拟用户单击
void pop()
{
User32.EnumWindows(new EnumProc(Enum), 0);
}
private bool Enum(IntPtr hWnd, uint param)
{
User32.STRINGBUFFER buffer=new User32.STRINGBUFFER();
User32.GetClassName(hWnd, ref buffer, 256);
if (buffer.szText == "Shell_TrayWnd")
{
User32.EnumChildWindows(hWnd, new EnumProc(Enum2), 0);
return false;
}
else return true;
}
IntPtr lastForeGroundWindow;
private bool Enum2(IntPtr hWnd, uint param)
{
User32.STRINGBUFFER buffer = new User32.STRINGBUFFER();
User32.GetClassName(hWnd, ref buffer, 256);
if (buffer.szText == "Button")
{
if (User32.SendMessage(hWnd, WndMsg.BM_GETSTATE, 0, 0) == User32.BST_PUSHED)
{
User32.SetForegroundWindow(lastForeGroundWindow);
}
else
{
lastForeGroundWindow = User32.GetForegroundWindow();
User32.SetForegroundWindow(hWnd);
User32.PostMessage(hWnd, WndMsg.BM_CLICK, 0, 0);
}
return true;
}
else
return false;
}
新闻来自: 新客网(www.xker.com) 详文参考:http://www.xker.com/page/e2007/0116/10539.html