我有下面的代码,我试图从活动窗口中获取选定的文本并将其打印到控制台上。使用C++从活动窗口中获取选定的文本
DWORD new12=0;
KEYBDINPUT* input = new KEYBDINPUT[key_count];
if(GetGUIThreadInfo(new12, lpgui))
{
target_window = lpgui->hwndFocus;
}
else
{
// You can get more information on why the function failed by calling
// the win32 function, GetLastError().
std::cout<<"error1";
}
// We're sending two keys CONTROL and 'V'. Since keydown and keyup are two
// seperate messages, we multiply that number by two.
for(int i = 0; i < key_count; i++)
{
input[i].dwFlags = 0;
//input[i].type = INPUT_KEYBOARD;
}
input[0].wVk = VK_CONTROL;
input[0].wScan = MapVirtualKey(VK_CONTROL, MAPVK_VK_TO_VSC);
input[1].wVk = 0x56; // Virtual key code for 'v'
input[1].wScan = MapVirtualKey(0x56, MAPVK_VK_TO_VSC);
我有以上的C++代码,但它似乎是给了一个错误说“error: MAPVK_VK_TO_VSC' was not declared in this scope
”在该行input[0].wScan = MapVirtualKey(VK_CONTROL, MAPVK_VK_TO_VSC);
我不知道这里有什么问题。我不认为这个错误是由于任何声明问题而出现的。你能帮我在这里吗?谢谢。
使用可访问性接口。这就是他们的目的。 – 2013-05-12 02:21:20
@Raymond Chen我正在使用jgrasp。我如何使用辅助接口? – 2013-05-12 02:30:54
这是一个比单个SO问题可涵盖的更大的话题。您可以阅读MSDN中的辅助功能文档。您可能最终会使用TextPattern.GetSelection。 – 2013-05-12 03:43:13