C++版:

void RefreshTray()
{
	CPoint ptOld;
	GetCursorPos(&ptOld);

	int x=GetSystemMetrics(SM_CXSCREEN);
	int y=GetSystemMetrics(SM_CYSCREEN);

	for (int posX=x-500;posX<=x;posX+=5)
	{
		SetCursorPos(posX,y-15);
		Sleep(1);
	}

	SetCursorPos(ptOld.x,ptOld.y);
}

mouse_event不太好用,直接用SetCursorPos模拟了。

C#版本:

private void RefreshTray()
{
	Point ptOld = Cursor.Position;
	int ScrWidth = SystemInformation.VirtualScreen.Width;
	int ScrHeight = SystemInformation.VirtualScreen.Height;

	for (int posX = ScrWidth - 500; posX <= ScrWidth; posX += 4)
	{
		Cursor.Position = new Point(posX,ScrHeight-15);
		Thread.Sleep(1);
	}

	Cursor.Position = ptOld;
}

 


本文链接地址: 模拟鼠标清除托盘无效图标
https://blog.qingfengju.com/index.asp?id=316

上一篇: 在FCKeditor中使用syntaxhighlighter显示高亮代码
下一篇: .Net程序的崩溃日志与自动重启

分类:Win32/C++ 查看次数:4810 发布时间:2013/2/1 22:05:46