基本思路为,寻找开始菜单按钮窗口,并模拟用户单击
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;
}
本文地址:http://com.8s8s.com/it/it41041.htm