Well it seems this can't be don't that easily. Windows WMI doesn't provide a userlogout event via wmi, seems via .net though. So change of plans. Can a service running with the system account control the win32:gui window running as the current logged in user? Like grab the win32::gui handle? examples? Got this bit of perl win32::gui code working and would like to either have the code once running in the systray poll a stat file and if the stat file exists then open its diallog for user input. OR have the system service control the diallog popup. New to the win32:gui and not sure where to put the code to run while the gui is sitting there waiting for the user.
#!perl -w use strict; use warnings; use Win32::GUI; my $DOS = Win32::GUI::GetPerlWindow(); Win32::GUI::Hide($DOS); # Get text to diaply from the command line my $text = defined($ARGV[0]) ? $ARGV[0] : "Software Update Notificatio +n"; # Create a font to diaply the text my $font = Win32::GUI::Font->new( -name => "Comic Sans MS", -size => 24, ); my $main = Win32::GUI::Window->new( -name => 'Main', -text => 'CTG Updates', -width => 300, -height => 200 ); # Add the text to a label in the window my $label = $main->AddLabel( -text => $text, -font => $font, -foreground => 0x0000FF, ); my $icon = new Win32::GUI::Icon('GUIPERL.ICO'); my $ni = $main->AddNotifyIcon( -name => "NI", -id => 1, -icon => $icon, -tip => "CTG Updater" ); $main->AddRadioButton( -name => 'Default', -text => 'Apply updates now', -default => 1, # Give button darker border -ok => 1, # press 'Return' to click this button -width => 125, -height => 20, -left => $main->ScaleWidth() - 200, -top => $main->ScaleHeight() - 100, ); $main->AddRadioButton( -name => 'Cancel', -text => 'Update Another time', -cancel => 1, # press 'Esc' to click this button -width => 125, -height => 20, -left => $main->ScaleWidth() - 200, -top => $main->ScaleHeight() - 80, ); my $textfield = $main->AddTextfield( -name => "Textfield", -text => "have fun and more", -left => 75, -top => 150, -width => 200, -height => 40, -readonly => 1, ); #Win32::GUI::Dialog(); #sleep 30; $main->Show(); Win32::GUI::Dialog(); exit(0); sub Main_Terminate { return -1; } sub Main_Minimize { $main->Disable(); $main->Hide(); return 1; } sub NI_Click { $main->Enable(); $main->Show(); return 1; } sub Default_Click { print "Default button clicked\n"; $main->Hide(); return 0; } sub Cancel_Click { print "Cancel button clicked\n"; $main->Hide(); return 0; }

In reply to Re^2: Catching system events, via WMI by freebsdboy
in thread Catching system events, via WMI by freebsdboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.