#!/usr/local/bin/perl -w use Tk; use Win32::API; Win32::API->Import('user32', 'GetAsyncKeyState', 'I', 'I'); my $main = new Tk::MainWindow; $main->geometry('1030x740'); my $vis = 1; sub read_stuff { &switch_vis if ((GetAsyncKeyState(0x04) & 1) == 1); } $handler = $main->repeat(50, \&read_stuff); sub switch_vis { if($vis == 0) { $vis = 1; $main->deiconify; } else { $vis = 0; $main->withdraw; } } MainLoop;