我有下面的代碼,我試圖從活動窗口中獲取選定的文本並將其打印到控制檯上。使用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