workcat 发表于 2006-4-18 16:10:07

如何获取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?
页: [1]
查看完整版本: 如何获取command窗口中的信息?