首页 > 编程语言 > 详细

C++刷新托盘程序

时间:2021-01-20 23:26:24      阅读:60      评论:0      收藏:0      [点我收藏+]

C++刷新托盘程序

托盘程序在非正常被关闭的情况下,就会出现托盘图标不消失的情况,需要鼠标移到上面才会消失。这里就模拟鼠标事件来处理。但是对于缩到托盘里面的图标则没有办法刷新,待找...

#include <windows.h>
#include <iostream>

int main() {
	HWND shell_tray_wnd_handle = FindWindow(L"Shell_TrayWnd", NULL);
	HWND tray_notify_wnd_handle = FindWindowEx(shell_tray_wnd_handle, 0, L"TrayNotifyWnd", NULL);
	HWND sys_paper_handle = FindWindowEx(tray_notify_wnd_handle, 0, L"SysPager", NULL);

	HWND tool_bar_handle = NULL;
	if (sys_paper_handle != NULL) {
		tool_bar_handle = FindWindowEx(sys_paper_handle, 0, L"ToolbarWindow32", NULL);
	}
	else {
		tool_bar_handle = FindWindowEx(tray_notify_wnd_handle, 0, L"ToolbarWindow32", NULL);
	}

	if (tool_bar_handle == NULL) {
		return 0;
	}

	RECT rect;
	GetWindowRect(tool_bar_handle, &rect);
	int width = rect.right - rect.left;
	int height = rect.bottom - rect.top;

	for (int x = 1; x < width; x += 2) {
		for (int y = 1; y < height; y += 2) {
			SendMessage(tool_bar_handle, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
		}
	}

	return 0;
}

C++刷新托盘程序

原文:https://www.cnblogs.com/zzr-stdio/p/14304658.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!