Thread Globales Tasten-Event abfangen (win) (20 answers)
Opened by GoodFella at 2007-02-28 12:24

GoodFella
 2007-03-01 13:09
#74666 #74666
User since
2007-01-09
192 Artikel
BenutzerIn
[default_avatar]
[quote=esskar,01.03.2007, 11:47]focus hat nix mit top-window zu tun.[/quote]
Danke, das Stichwort habe ich gebraucht:

Code (perl): (dl )
1
2
use Tk::StayOnTop;
$main->stayOnTop if ($vis == 1);


funktioniert perfekt.

Hier nochmal das ganze Programm falls jemand sowas auch braucht:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/local/bin/perl -w

use Tk;
use Win32::API;
use Tk::JPEG;
use Tk::StayOnTop;

my $boss_key = 0x04;
#my $boss_key = 0x1b;


my $main =  new Tk::MainWindow( -title => 'IDEAL' );
$main->geometry('1030x740');
my $image = $main->Photo('-format' => 'jpeg', -file => 'boss.jpg');
$main->Label(-image => $image)->pack(); 

Win32::API->Import('user32', 'GetAsyncKeyState', 'I', 'I');

my $vis = 1;

sub read_stuff
{
 $main->stayOnTop if ($vis == 1);
 $main->focus if ($vis == 1);
 &switch_vis if ((GetAsyncKeyState($boss_key) & 1) == 1);
}
$main->repeat(50, \&read_stuff);


sub switch_vis
{
  if($vis == 0)
   {
    $vis = 1;
    $main->deiconify;
   }
  else
   {
    $vis = 0;
    $main->withdraw;
   }
}

MainLoop;

View full thread Globales Tasten-Event abfangen (win)