怎么通过程序捕获控制台下的屏幕的内容

如何通过程序捕获控制台下的屏幕的内容?
想通过程序实现抓取控制台下的屏幕内容。
/dev下没有fb0等文件。


/dev/vcs?


可以用vcs设备,man vcs可以得到详细解释。

简单的测试:
cat /dev/vcs3
fold /dev/vcs3 (跟上面一样,只是自动回车)

下面的程序摘自vcs的man,程序显示第二个终端的光标所在位置的字符及属性,然后改变背景颜色。

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>

int main() {
int fd;
char *device = "/dev/vcsa2 ";
struct {unsigned char lines, cols, x, y;} scrn;
char ch, attrib;

fd = open(device, O_RDWR);
if (fd < 0) {
perror(device);
exit(1);
}
(void)read(fd, &scrn, 4);
(void)lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), 0);
(void)read(fd, &ch, 1);
(void)read(fd, &attrib, 1);
printf( "ch= '%c ' attrib=0x%02x\n ", ch, attrib);
attrib ^= 0x10;
(void)lseek(fd, -1, 1);
(void)write(fd, &attrib, 1);
return 0;
}

怎么通过程序捕获控制台下的屏幕的内容

相关文章:

你感兴趣的文章:

标签云: