Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Win32::SysTray Issue ( Win32::GUI::DoEvents )

by jcb (Vicar)
on Oct 21, 2020 at 01:16 UTC ( #11123024=note: print w/replies, xml ) Need Help??


in reply to Re^4: Win32::SysTray Issue ( Win32::GUI::DoEvents )
in thread Win32::SysTray Issue

I forgot to mention setting $| = 1; before the first print to turn off line-buffering on STDOUT. Oops.

Preventing the icon feature from blocking the main program is exactly why there is a Win32::GUI::DoEvents call in the loop in the Prompt sub.

Replies are listed 'Best First'.
Re^6: Win32::SysTray Issue ( Win32::GUI::DoEvents )
by PilotinControl (Pilgrim) on Oct 21, 2020 at 19:36 UTC

    The changes I made based on your suggestions did not work...I do have the changes in the correct places right? Thanks for the help.

    ::ANSIScreen; use Win32::Console; use Win32::SysTray; no warnings 'numeric'; $| = 1; # ADDED tray(); begin(); sub begin { # START BEGIN print "-------------------------------------------\n"; print "Please Choose One of the Following Options:\n"; print "-------------------------------------------\n\n\n"; print "(1) EMPLOYEE MANAGEMENT \n\n"; print "(Q) QUIT \n\n"; print " \n\n\n\n"; my $input = Prompt("? "); # ADDED if ($input){ if ( $input == 1 ){ sleep(3); begin(); } if ( $input eq "q" ) { sleep 3; exit; } } # END INPUT } # END BEGIN sub tray { my $stray = new Win32::SysTray ( 'name' => 'TEST', 'icon' => 'C:\images\logo.ico', 'single' => 1, ) or exit 0; $stray->setMenu ( "> &Test" => sub { print "Hello from the Tray\n"; }, ">-" => 0, "> E&xit" => sub { exit; }, ); } sub Prompt { my $prompt = shift; print "\n$prompt "; my $response = ''; my $rsel = ''; my $rrdy; vec($rsel,fileno(STDIN),1) = 1; CHAR: while (1) { die "user quit" if -1 == Win32::GUI::DoEvents(); while (select($rrdy=$rsel, undef, undef, 0.10)) { sysread(STDIN, $response, 1, length $response) == 1 or die "read error"; } last CHAR if chomp($response); } return $response; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11123024]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2020-11-29 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?