0

我的 Perl 一点也不好,我无法确定为什么这个很棒的 perl 脚本会不断返回:

错误:未找到正在运行的窗口在 [xwininfo -tree -root] 中找不到窗口 [Mozilla]

我已经设置了这些变量:

my $PROGNAME = $0;
$PROGNAME =~ s|.*/||;
my $GRAB = 'xwd -silent -nobdrs -id %id | convert -quality 85 - %out';
my $XINFO = 'xwininfo -tree -root';
my $BROWSER = 'firefox';    # Must match find_window() code - see usage()

在使用中它是这样说的:

- Requires "Mozilla" or "Opera" browser
    (update find_window() code for other browsers)

有关的代码是这样的:

# I'm using mozilla..
sub find_window {
  $BROWSER eq "opera" ?
    opera_find_window(@_) :
    mozilla_find_window(@_);
}

我将如何获得上述内容以反映 Firefox 浏览器。在我的 shell 中,如果我输入 mozilla 什么都不会发生,如果我输入 firefox - 我的浏览器会打开,所以我应该使用它。

这是返回该错误的相关代码:

sub mozilla_find_window {
  open(XINFO,"$XINFO|") || die("Couldn't run: [$XINFO]\n");

  # Pick the first mozilla window.  It's got the title in it, but
  # we have no way of knowing if that matches the URL, so we'll
  # hope this is the right one..
  my ($spacing,$id,$title,$x,$y);
  while(<XINFO>) {
    # This could easily break and is very mozilla specific (works on firefox)
    # Looks for [...("Mozilla" "navigator:browser") ..]
    # I've had this reported:     0x80002f "TITLE - Mozilla": ("Gecko" "Mozilla-bin")  889x687+0+22  +136+44
    last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla.*": \("Mozilla" "navigator:browser"\)\s*$GEOM_RE$/));

    last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla.*": \("mozilla-bin" "Mozilla-bin"\)\s*$GEOM_RE$/));
    # Mozilla Firefox 1.0.4
    last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla Firefox.*": \("Gecko" "Firefox-bin"\)\s*$GEOM_RE$/));
        # Debian Mozilla Firefox
        last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(.*)\s*-\s*Mozilla Firefox.*": \("firefox-bin" "Firefox-bin"\)\s*$GEOM_RE$/));
  }
  die("Couldn't find window [Mozilla] in [$XINFO]\n") unless $title && $x && $y;

任何人都知道我该如何解决这个问题,我做错了什么?这是与安装firefox的位置有关的问题吗?

谢谢大家

更新

 0x140529c "Firefox": ()  10x10+-100+-100  +-100+-100
 0x14051b9 "Firefox": ()  10x10+-100+-100  +-100+-100
 0x14038c9 "Firefox": ("firefox" "Firefox")  1x1+-100+-100  +-100+-100
    1 child:
    0x14038ca (has no name): ()  1x1+-1+-1  +-101+-101
 0x14002bd "Firefox": ()  1x1+0+0  +0+0
    1 child:
    0x14002be (has no name): ()  1x1+-1+-1  +-1+-1
 0x1400210 "Firefox": ()  10x10+-100+-100  +-100+-100
 0x14000ea "Firefox": ("firefox" "Firefox")  200x200+0+0  +0+0
    1 child:
    0x14000eb (has no name): ()  1x1+-1+-1  +-1+-1
 0x14000a6 "Firefox": ("firefox" "Firefox")  200x200+0+0  +0+0
    2 children:
    0x14000a9 (has no name): ()  1x1+-1+-1  +-1+-1
       1 child:
       0x14000aa (has no name): ()  1x1+2+2  +1+1
          1 child:
          0x14000ab (has no name): ()  1x1+0+0  +1+1
             4 children:
             0x140519f (has no name): ()  1x1+-1+-1  +0+0
             0x140519e (has no name): ()  1x1+-1+-1  +0+0
             0x1400286 (has no name): ()  1x1+-1+-1  +0+0
             0x14000ad (has no name): ()  1x1+-1+-1  +0+0
    0x14000a7 (has no name): ()  1x1+-1+-1  +-1+-1
 0x140008d "Firefox": ("firefox" "Firefox")  200x200+0+0  +0+0

以上是我手动运行时获得的xwininfo -tree -root

4

1 回答 1

4

您可以从输出中xwininfo看到您的 Firefox 在 X 窗口列表中显示为"Firefox": ("firefox" "Firefox")

您的正则表达式目前都没有在寻找这种组合。直接在行之后添加此代码#Debian Mozilla Firefox(或至少在同while一块中的某处):

# my Firefox
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(Firefox)": \("firefox" "Firefox"\)\s*$GEOM_RE$/));
于 2009-12-29T03:25:44.967 回答