TestSendInput.cpp

#include 
#include 
int main()
{
	//键盘消息
	//INPUT input[4];
	//memset(input, 0, sizeof(input));
	//input[0].type = input[1].type = input[2].type = input[3].type = INPUT_KEYBOARD; //设置键盘模式
	//input[0].ki.wVk = input[3].ki.wVk = VK_LWIN;
	//input[1].ki.wVk = input[2].ki.wVk = 'D';
	//input[2].ki.dwFlags = input[3].ki.dwFlags = KEYEVENTF_KEYUP;
	//SendInput(4, input, sizeof(INPUT));


	//鼠标消息
	//INPUT m_mouse_event;
	//m_mouse_event.type = INPUT_MOUSE;
	//m_mouse_event.mi.dx = 67 * (65536 / GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
	//m_mouse_event.mi.dy = 64 * (65536 / GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
	//m_mouse_event.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK | MOUSEEVENTF_ABSOLUTE;
	//POINT p;
	//GetCursorPos(&p);
	//printf_s("Begin X: %d | Y: %d\n", p.x, p.y);
	//UINT ret = SendInput(1, &m_mouse_event, sizeof(m_mouse_event));
	//if (0 == ret)
	//{
	//	printf_s("%d", GetLastError);
	//}
	//GetCursorPos(&p);
	//printf_s("After X: %d | Y: %d\n", p.x, p.y);

	//INPUT m_InPut[2] = { 0 };
	//m_InPut[0].type = m_InPut[1].type = INPUT_MOUSE;
	//m_InPut[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
	//m_InPut[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
	//SendInput(sizeof(m_InPut) / sizeof(m_InPut[0]), m_InPut, sizeof(INPUT));



	//键盘消息, DUILib窗口无效
	::SendMessage(HWND(0x002A030E), WM_KEYDOWN, WPARAM(VK_LEFT), 0);
	Sleep(5);
	::SendMessage(HWND(0x002A030E), WM_KEYUP, WPARAM(VK_LEFT), 0);

	::SendMessage(HWND(0x002A030E), WM_CHAR, WPARAM('G'), 0);


	//鼠标消息
	//PostMessage((HWND)0x001802D8, WM_LBUTTONDOWN, 0, 67 + 67 * 65536); //y坐标放在高16位,x坐标放在低16位,也可以用MAKELONG函数
	//PostMessage((HWND)0x001802D8, WM_LBUTTONUP, 0, MAKELONG(67, 67));


	return 0;
}