http://www.perlmonks.org?node_id=1077943

vaguy has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl application that presents an icon in the system tray (Windows 8 calls it the notification area). I've seen it disappear once or twice but the app continues to run). I'm assuming this is because of an Explorer restart or crash. My research suggests I need to listed for a 'TaskbarCreated' message via a RegisterWindowMessage API call. I haven't seen any code snippets in perl that might get me going. Can anybody help me out here?

Replies are listed 'Best First'.
Re: System Tray Icon Disappears
by Anonymous Monk on Mar 12, 2014 at 00:29 UTC
      I'm using Active Perl with Tk and Win32::GUI().
      Calls are to Win32::GUI::Window->new and then to AddNotifyIcon.
      Code looks like this:
      sub SetupSystray{ $TrayIcon = new Win32::GUI::Icon('WebCam.ico'); $TrayWinHidden = Win32::GUI::Window->new( -name => 'TrayWindow', -text => 'TrayWindow', -width => 20, -height => 20, -visible => 0, ); $TrayNotify = $TrayWinHidden->AddNotifyIcon( -name => "WebCam-App", -icon => $TrayIcon, -tip => "WebCam", -balloon_icon => "info", -onRightClick => \&TrackTrayMenu, -onClick => \&ToggleProgWindow, ); $TrayMenu = Win32::GUI::Menu->new( "" => "Options", ">WebCam" => {-name => "WebCam"}, ">-" => 0, ">Open/Close" => {-name => "ToggleProg", -onClick => \&To +ggleProgWindow,-default => 1}, ">-" => 0, ">Exit" => {-name => "Exit",-onClick => \&CloseDownFrom +Tray} ) or prtFTL "Failed to create Tray Menu $!"; } sub CloseDownFromTray{ $mw->destroy; }