获得菜单项目名称
程序员文章站
2022-07-14 18:16:22
...
while(true)
{
char _szClassName[128] = {NULL};
POINT _ptPos;
GetCursorPos(&_ptPos);
HWND _hWndCurrent = WindowFromPoint(_ptPos);
GetClassNameA(_hWndCurrent, _szClassName, sizeof(_szClassName));
// 判断该菜单是否能够获取到对应项名称
HMENU _hMenu = (HMENU) ::SendMessage(_hWndCurrent, MN_GETHMENU, 0, 0);
TCHAR _szMenuString[128] = {NULL};
GetMenuStringA(_hMenu, 0, _szMenuString, 128, MF_BYPOSITION);
// 获得combox第一项
TCHAR _szComBString[128] = {NULL};
::SendMessage(_hWndCurrent, CB_GETLBTEXT, 0, (LPARAM)_szComBString);
Sleep(500);
TRACE("_szClassName=%s,MenuItem=%s,_szComBString=%s\n", _szClassName,_szMenuString,_szComBString);
}
上一篇: 力扣题目——有效的括号(java版)