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 45 46 47 48 49 50
use strict; use warnings; use Tk; use Win32::Process; use Tk::Schedule; my ($EntryMan, $TL, $Process); my $Command = "C:\\Perl\\bin\\perl.exe"; my $Inherit = 0; my $Dir = "."; my $mw = MainWindow->new; $mw->title("MainWindow"); $mw->Entry(-selectbackground=>'white',-selectforeground=>'black',-textvariable=>\$EntryMan)->pack(); $mw->Button(-text=>"Schedule",-command=>\&doTopLevel)->pack(); MainLoop; sub doTopLevel { if(!Exists($TL)) { $TL=$mw->Toplevel(); $TL->title("Schedule-Modul"); $TL->Schedule( -interval => 30, -repeat => "once", -command => sub { print("Schedule is running\n"); # [\&getProcess, $EntryMan]; }, -comment => "Do an activity")->pack(); } else { $TL->deiconify(); $TL->raise(); } } sub getProcess { my $MyArg = "perl test.pl -a $EntryMan"; Win32::Process::Create($Process, $Command, $MyArg, $Inherit, NORMAL_PRIORITY_CLASS, $Dir) or die Win32::FormatMessage(Win32::GetLastError()); }
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
# Script Schedule.pl use Tk; use Win32::Process; use Tk::Schedule; my ($EntryMan, $TL, $Process); my $Command = "C:\\Perl\\bin\\perl.exe"; my $Inherit = 0; my $Dir = "."; my $mw = MainWindow->new; $mw->title("MainWindow"); $mw->Entry(-selectbackground=>'white',-selectforeground=>'black',-textvariable=>\$EntryMan)->pack(); $mw->Button(-text=>"Schedule",-command=>\&doTopLevel)->pack(); MainLoop; sub doTopLevel { if(!Exists($TL)) { $TL=$mw->Toplevel(); $TL->title("Schedule-Modul"); $TL->Schedule( -interval => 30, -repeat => "once", -command =>[\&getProcess, $EntryMan], -comment => "Do an activity")->pack(); } else { $TL->deiconify(); $TL->raise(); } } sub getProcess { my ($EntryTest) = shift; my $MyArg = "perl test.pl -a $EntryTest"; Win32::Process::Create($Process, $Command, $MyArg, $Inherit, NORMAL_PRIORITY_CLASS, $Dir) or die Win32::FormatMessage(Win32::GetLastError()); }
1 2 3 4 5 6
# Script test.pl use vars qw{ $opt_a }; use Getopt::Std; getopts('a:') or finish(1); system("echo String: $opt_a\n");
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 45 46 47 48 49 50
use strict; use warnings; use Tk; use Win32::Process; use Tk::Schedule; my ($EntryMan, $TL); my $RefEntryMan = \$EntryMan; my $mw = MainWindow->new; $mw->title("MainWindow"); $mw->Entry(-textvariable=>\$EntryMan)->pack(); $mw->Button(-text=>"Schedule",-command=>\&doTopLevel)->pack(); MainLoop; sub doTopLevel { if(!Exists($TL)) { $TL=$mw->Toplevel(); $TL->title("Schedule-Modul"); $TL->Schedule( -interval => 30, -repeat => "once", -command =>[\&getProcess, $RefEntryMan], -comment => "Do an activity")->pack(); } else { $TL->deiconify(); $TL->raise(); } } sub getProcess { my $Process; my $Inherit = 0; my $Dir = "."; my $Command = "C:\\Perl\\bin\\perl.exe"; my ($GetProcess) = @_; my $FwdProcess = ${$GetProcess}; my $MyArg = "perl test.pl -a $FwdProcess"; Win32::Process::Create($Process, $Command, $MyArg, $Inherit, NORMAL_PRIORITY_CLASS, $Dir) or die Win32::FormatMessage(Win32::GetLastError()); }