Jump to content
  • Advertisement
Sign in to follow this  

PostMessage and simulating Ctrl + A

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?
        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];
		ks[VK_RCONTROL] = 129;
		ks[VK_LCONTROL] = 129;

		::PostMessage(textEditPane, WM_KEYDOWN, 'A', 0);

                ::AttachThreadInput(::GetCurrentThreadId(), tid, false);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!