如何获取command窗口中的信息?
如何获取command窗口中的信息?我使用如下代码, 但是失败,谁能告诉我正确应该怎么做?
# Launch DOS Command Prompt
rc = invoke_application("cmd.exe","","",SW_SHOW);
wait(1);
if ( rc != E_OK) {
tl_step("Opening cmd",FAIL,"Unable to open cmd. Error code: " & rc);
return(rc);
}
tl_step("open_cmd",PASS,"cmd opened");
# Capture the handle and create a physical description
rc = reload ("win32api", 1, 1);
hWnd = FindWindowA("ConsoleWindowClass","C:\\" & windows_type & "\\System32\\cmd.exe");
DWIN = "{ handle: " & hWnd & " }";
if (win_exists(DWIN,5) != E_OK) {
tl_step("open_cmd", FAIL,"DWIN window does not exist. Console not opened.");
return(E_OPERATION_NOT_PERFORMED);
}
win_activate(DWIN);
set_window(DWIN,1);
type("cd temp" );
wait(1);
type("<kReturn>");
win_get_text (DWIN, text);
DWIN 的获取以及set, activate 都正常,但是win_get_text信息为空
why? 不是所有窗口上的文字都可以获取下来的 因为里面的编辑栏不是个控件, CMD只能整个识别为一个对象
CMD窗口本身也不是个标准的窗口(比如基于CWnd或CDialog) 可以用Analog录制在CMD中的输入操作>右键选select all>Enter,然后打开个记事本Paste 呵呵, 这办法不错啊
页:
[1]