win api发送键盘消息
It is simple for basic use. Just the example code. It is clear enough.
基本用途很简单。 只是示例代码。 很清楚。
int SendMsgToOtherWindow( )
{
// find window by name
HWND wnd = FindWindow( 0, "计算器" );
if ( wnd == 0 )
return 0;
// print the child window text
HWND cwd = GetWindow( wnd, GW_CHILD );
while ( cwd ) {
char buf[1024];
GetWindowText( cwd, buf, 1024 );
cout << buf << endl;
int id = GetDlgCtrlID( cwd );
cout << id << endl;
cwd = GetNextWindow( cwd, GW_HWNDNEXT );
}
// close the window
SendMessage( wnd, WM_CLOSE, 0, 0 );
return 0;
}
翻译自: https://www.systutorials.com/send-messages-to-other-windows/
win api发送键盘消息