Тема: AHK v2: захват текста из окна cmd.
Здравствуйте,
Имеется окно командной строки (В данном случае речь идет про консоль управления плеером VLC), из которого надо бы извлечь информацию.
Пробовал при помощи ReadConsoleOutputCharacter, но так и не смог настроить под АНК v2:
#Requires AutoHotkey v2.0
dwProcessId := WinGetID("A")
bResult := DllCall("AttachConsole", "uint", dwProcessId, "int")
hConsole := DllCall("GetStdHandle", "uint", -11, "ptr")
VarSetStrCapacity(&Out, 2000)
bResult := DllCall("ReadConsoleOutputCharacter", "ptr", hConsole, "str", &Out, "uint", 1000, "ptr", 0, "uint*", 0)
ToolTip "ProcessID: " dwProcessId "`nHandle: " hConsole "`nReturn: " bResult "`nOut: " Out "`nErr: " A_LastError, 1300, 30, 5
/*
BOOL WINAPI ReadConsoleOutputCharacter(
_In_ HANDLE hConsoleOutput,
_Out_ LPTSTR lpCharacter,
_In_ DWORD nLength,
_In_ COORD dwReadCoord,
_Out_ LPDWORD lpNumberOfCharsRead
)
Parameters
hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.
lpCharacter [out]
A pointer to a buffer that receives the characters read from the console screen buffer.
nLength [in]
The number of screen buffer character cells from which to read. The size of the buffer pointed to by the lpCharacter parameter should be nLength * sizeof(TCHAR).
dwReadCoord [in]
The coordinates of the first cell in the console screen buffer from which to read, in characters. The X member of the COORD structure is the column, and the Y member is the row.
lpNumberOfCharsRead [out]
A pointer to a variable that receives the number of characters actually read.
Что я делаю не так, как делать правильно? Есть подозрение, что дело в координатах, но как их задать правильно?
Может есть альтернативные решения?