Pregunta

Mi perl no es muy bueno en absoluto y tengo problemas para determinar por qué este El guión impresionante de Perl sigue regresando:

Error: no se encontró una ventana en ejecución no pudo encontrar la ventana [Mozilla] en [Xwininfo -tree -Reot

He configurado estas variables:

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()

En uso dice esto:

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

El código en cuestión es este:

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

¿Cómo haría que lo anterior refleje un navegador de Firefox? En mi caparazón, si escribo Mozilla, no pasa nada, si escribo Firefox, mi navegador abre, así que debería usar esto.

Aquí está el código en cuestión que devuelve ese error:

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;

Alguien sabe cómo puedo solucionar esto, ¿qué estoy haciendo mal? ¿Es un problema que tiene que ver con la ubicación donde se instala Firefox?

Gracias a todos

Actualizar

 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

Lo anterior se obtiene cuando ejecuto esto manualmente xwininfo -tree -root

¿Fue útil?

Solución

Puedes ver desde la salida de xwininfo que su Firefox aparece en la lista de ventanas X como "Firefox": ("Firefox" "Firefox").

Ninguno de sus reglas está buscando esta combinación. Agregue este código directamente después del #Debian Mozilla Firefox líneas (o al menos en algún lugar de ese mismo while bloquear):

# my Firefox
last if (($spacing,$id,$title,$x,$y) = (/^(\s+)(0x[0-9a-f]+) "(Firefox)": \("firefox" "Firefox"\)\s*$GEOM_RE$/));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top