This app is used to just list the COM ports that are available. I cant get it to display the list of COM ports.
use strict; use Win32::SerialPort; use Win32::GUI(); my $comport = 1; my @list; #my $comlist; ######################## # Main Loop ######################## my $main = Win32::GUI::Window->new( -name => 'Main', -text => 'Serial Ports', -width => 110, -height => 175, ); my $desk = Win32::GUI::GetDesktopWindow(); my $dw = Win32::GUI::Width($desk); my $dh = Win32::GUI::Height($desk); my $x = $dw / 4 * 3.25; my $y = $dh / 4 * 2.5; $main->Move($x, $y); my $icon = new Win32::GUI::Icon('serialport.ico'); my $ni = $main->AddNotifyIcon( -name => "NI", -icon => $icon, -tip => "SerialPort Finder" ); $main->AddLabel (-text => 'COM Ports Active:'); my $comfield = $main->AddRichEdit( -name => "comfield", -left => 5, -top => 20, -text => "", -width => 100, -height => 100, -readonly => 1 ); $main->AddTimer( "com_list", 1000); Win32::GUI::Dialog(); ######################## # Main Window Subs ######################## sub Main_Terminate { return -1; #$main->Disable(); #$main->Hide(); #return 1; } sub Main_Minimize { $main->Disable(); $main->Hide(); return 1; #return -1; } ######################## # System Tray Events ######################## sub NI_Click { &serial_finder; #&label_create; $main->Enable(); $main->Show(); return 1; } ######################## # Make labels for # found COM ports ######################## sub com_list_Timer { print "entered\n"; &com_list_create; } sub com_list_create { print "running\n"; foreach my $comlist (@list) { print $comlist,"\n"; $comfield->SetFocus(); $comfield->ReplaceSel("COM$comlist",1); $comfield->Select(999999,999999); } } ######################## sub serial_finder { my @list; $comport=1; do { my $port = new Win32::SerialPort("COM$comport"); if (defined ($port)) { push(@list,$comport); $port->close; } $comport++; } while ($comport < 20); foreach my $comlist (@list) { print $comlist,"\n"; } }

In reply to Win32::GUI COM Port app by deadpickle

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.