SetInputFocus doesnt work

Help
2006-04-12
2013-04-25
  • Felix Brandt

    Felix Brandt - 2006-04-12

    I have some problems to handle multiple windows/programs. It seems that SetInputFocus isnt working :(

    Here is a little sample-script. I start gedit and kwrite and want to rotate between the to windows, while writing 'A's into gedit and 'B's into kwrite.

    > #!/usr/bin/perl
    > use X11::GUITest qw/
    >     :ALL
    > /;
    > my $MyWinId = GetInputFocus();
    > StartApp("gedit");
    > my ($GeditWinId) = WaitWindowViewable('gedit');
    > StartApp("kwrite");
    > my ($KwriteWinId) = WaitWindowViewable('KWrite');
    >
    > while (1) {
    >     select(undef, undef, undef, 1);
    >     print "error gedit\n" unless SetInputFocus($GeditWinId);
    >     SendKeys("A");
    >     select(undef, undef, undef, 1);
    >     print "error kwrite\n" unless SetInputFocus($KwriteWinId);
    >     SendKeys("B");
    > }

    The result is that all characters are sent to kwrite and after closing it, all characters are sent to gedit.

    I'm already thinking about a work-around (moving the mouse and pressing buttons :) but I still hope there's a better solution.

    Any ideas or suggestions?
    Thx Felix

     
    • Felix Brandt

      Felix Brandt - 2006-04-15

      it's not a bug, it's a feature :-)

      Kde's (3.3.2) focus stealing prevention did simply not allow these actions.
      After setting (right click on titlebar)->Advanced->Special Window Settings->Workarounds->Focus Stealing Prenvention to  "Force" and "none" for both programs (gedit,kwrite) everything went well.

      Happy Easter :)

       

Log in to post a comment.