HWND vsWin = ::GetForegroundWindow();
HWND mdiClient = ::FindWindowEx(vsWin, NULL, "MDIClient", NULL);
HWND mdiContainer = ::FindWindowEx(mdiClient, NULL, "EzMdiContainer", NULL);
HWND dockingView = ::FindWindowEx(mdiContainer, NULL, "DockingView", NULL);
HWND genericPane = ::FindWindowEx(dockingView, NULL, "GenericPane", NULL);
HWND splitterRoot = ::FindWindowEx(genericPane, NULL, "VsSplitterRoot", NULL);
HWND editPane = ::FindWindowEx(splitterRoot, NULL, "VsEditPane", NULL);
HWND textEditPane = ::FindWindowEx(editPane, NULL, "VsTextEditPane", NULL);
if (textEditPane == NULL) cout << "null\n";
else {
DWORD tid = ::GetWindowThreadProcessId(textEditPane, NULL);
::AttachThreadInput(::GetCurrentThreadId(), tid, true);
BYTE ks[256];
::GetKeyboardState(&ks[0]);
ks[VK_RCONTROL] = 129;
ks[VK_LCONTROL] = 129;
::SetKeyboardState(ks);
::PostMessage(textEditPane, WM_KEYDOWN, 'A', 0);
::AttachThreadInput(::GetCurrentThreadId(), tid, false);
}
PostMessage and simulating Ctrl + A
I'm attempting to hook into Visual Studio and inject a keypress for Ctrl + A. So far I'm able to inject any single key press, but I am unable to simulate the pressing and holding down of any of the special keys: Control, Shift, Alt, ect...
Here's my code so far, does anybody know how to properly do this?
A useful tool: MessageSender
Possibly useful discussions:
How to send a CTRL+X key to another window?
Big problem with simulating keypresses
Have you looked at WM_SYSKEYDOWN?
Possibly useful discussions:
How to send a CTRL+X key to another window?
Big problem with simulating keypresses
Have you looked at WM_SYSKEYDOWN?
I dont't know what you try to accomplish, but I think that writing a plug-in for Visual Studio might be the better solution.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement