我通过OCR得到一串文字,想塞进键盘缓冲区,应该如何做?

weixin_42379709 2018-07-09 02:02:36
我通过OCR得到一串文字,中文或英文或日文或韩文,想将这一串文字放进缓冲区内,供其他需要文字的地方采用,请问应该如何做?
...全文
98 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_42379709 2018-07-10
  • 打赏
  • 举报
回复
引用 8 楼 schlafenhamster 的回复:
那就用 new 再 delete
多谢!我用以下方法将十个汉字塞进了编辑框。

void CAppTest123Dlg::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	m_ctrEdit.SetFocus();
	INPUT *input = new INPUT[10];
	memset(input, 0, sizeof(INPUT)*10);
	for(int i=0; i<10; i++)
	{
		input[i].type = INPUT_KEYBOARD;  //设置键盘模式  
		input[i].ki.dwFlags = KEYEVENTF_UNICODE;  //输入UNICODE汉字
		input[i].ki.wScan = 0x4e00+i;  // 具体的文字
	}
	SendInput(26, input, sizeof(INPUT));
}
schlafenhamster 2018-07-10
  • 打赏
  • 举报
回复
那就用 new 再 delete
weixin_42379709 2018-07-10
  • 打赏
  • 举报
回复
引用 4 楼 schlafenhamster 的回复:
试试

// Execute the keyboard command
void CxxxDlg::SetKBMessage(WORD wMM,UINT nChar,UINT nRepCnt,UINT nFlags)
{
	// Create the maximum number of user inputs
	std::auto_ptr<INPUT> UserInput(new INPUT[nRepCnt]);
	INPUT * pUserInput = UserInput.get();

	// Build up the keyboard input
	for (UINT iInput = 0;iInput < nRepCnt;++iInput)
	{
		// Get the keyboard input
		INPUT & KeyBoardInput = pUserInput[iInput];

		// Set the input type
		KeyBoardInput.type = INPUT_KEYBOARD;

		// Get the keyboard input structure
		KEYBDINPUT & KeyBoard = KeyBoardInput.ki;

		// Set the scan code
		KeyBoard.wScan = 0;

		// Set the ignored fields
		KeyBoard.dwExtraInfo = 0;
		KeyBoard.time = 0;

		// Test for the key being pressed or released
		KeyBoard.dwFlags = wMM == WM_KEYDOWN ? 0 : KEYEVENTF_KEYUP;

		// Set the character
		KeyBoard.wVk = nChar;
	}

	// Send the user input for the keyboard
	SendInput(nRepCnt,pUserInput,sizeof(INPUT));
}
多谢楼上! 我用的 vs2010 编译说 Error: namespace "std" 没有成员 "auto_ptr"
向立天 2018-07-10
  • 打赏
  • 举报
回复
写个临时文件不就行了
weixin_42379709 2018-07-10
  • 打赏
  • 举报
回复
引用 3 楼 zhao4zhong1 的回复:
SendInput ?
赵老师好!
schlafenhamster 2018-07-09
  • 打赏
  • 举报
回复
试试

// Execute the keyboard command
void CxxxDlg::SetKBMessage(WORD wMM,UINT nChar,UINT nRepCnt,UINT nFlags)
{
// Create the maximum number of user inputs
std::auto_ptr<INPUT> UserInput(new INPUT[nRepCnt]);
INPUT * pUserInput = UserInput.get();

// Build up the keyboard input
for (UINT iInput = 0;iInput < nRepCnt;++iInput)
{
// Get the keyboard input
INPUT & KeyBoardInput = pUserInput[iInput];

// Set the input type
KeyBoardInput.type = INPUT_KEYBOARD;

// Get the keyboard input structure
KEYBDINPUT & KeyBoard = KeyBoardInput.ki;

// Set the scan code
KeyBoard.wScan = 0;

// Set the ignored fields
KeyBoard.dwExtraInfo = 0;
KeyBoard.time = 0;

// Test for the key being pressed or released
KeyBoard.dwFlags = wMM == WM_KEYDOWN ? 0 : KEYEVENTF_KEYUP;

// Set the character
KeyBoard.wVk = nChar;
}

// Send the user input for the keyboard
SendInput(nRepCnt,pUserInput,sizeof(INPUT));
}
赵4老师 2018-07-09
  • 打赏
  • 举报
回复
SendInput ?
vnking 2018-07-09
  • 打赏
  • 举报
回复
OCR后自动塞进去,不能手工操作
满衣兄 2018-07-09
  • 打赏
  • 举报
回复
可以使用剪切板

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧