想对后台的记事本发送 Alt+E(打开编辑菜单),但一直不能成功
前台的很好办,直接SetForegroundWindow(m_hWnd);
SendMessage(m_hWnd, WM_SYSCOMMAND, SC_KEYMENU, (WPARAM)'E');
就可以,但不置前窗体的话,怎么发过去让记事本打开编辑菜单呢?
PostMessage(m_hWnd, WM_SYSKEYDOWN, VK_MENU, MakeKeyLparam(VK_MENU, WM_SYSKEYDOWN)); PostMessage(m_hWnd, WM_SYSKEYDOWN, 'E', MakeKeyLparam('E', WM_SYSKEYDOWN)); PostMessage(m_hWnd, WM_SYSCHAR, 'E', MakeKeyLparam('E', WM_SYSCHAR)); PostMessage(m_hWnd, WM_SYSKEYUP, 'E', MakeKeyLparam('E', WM_SYSKEYUP)); PostMessage(m_hWnd, WM_KEYUP, VK_MENU, MakeKeyLparam(VK_MENU, WM_KEYUP));
SetForegroundWindow(m_hWnd); SendMessage(m_hWnd, WM_SYSCOMMAND, SC_KEYMENU, (WPARAM)'E');
SetForegroundWindow(m_hWnd); PostMessage(m_hWnd, WM_SYSKEYDOWN, VK_MENU, MakeKeyLparam(VK_MENU, WM_SYSKEYDOWN)); PostMessage(m_hWnd, WM_SYSKEYDOWN, 'E', MakeKeyLparam('E', WM_SYSKEYDOWN)); PostMessage(m_hWnd, WM_SYSKEYUP, 'E', MakeKeyLparam('E', WM_SYSKEYUP)); PostMessage(m_hWnd, WM_KEYUP, VK_MENU, MakeKeyLparam(VK_MENU, WM_KEYUP));
PostMessage(m_hWnd, WM_KEYDOWN, VK_F5, MakeKeyLparam(VK_F5, WM_KEYDOWN)); PostMessage(m_hWnd, WM_KEYUP, VK_F5, MakeKeyLparam(VK_F5, WM_KEYUP));