Andy Pastuszak wrote:
I am trying to create a simple input box. I created a window, added a text area and an Ok and Cancel button.
So you're most of the way there.
In my vbScript days I would simply use the InputBox function and it did all the work for me.
This isn't VB!
Is there some way to do this in perl using win32::gui or another module?
In Win32::GUI #!perl -w use strict; use warnings; my $userinput = InputBox->GetUserInput(); if(defined $userinput and length $userinput) { print "Got text: '$userinput'\n"; } else { print "No Text\n"; } exit(0); package InputBox; use strict; use warnings; use Win32::GUI(); # Display a window with an edit control and # returns text if OK button pressed, undef on cancel # Full Keyboard navigation (TAB, SHIFT+TAB, ENTER, ESC) sub GetUserInput { my $text = undef; my $mw = Win32::GUI::DialogBox->new( -caption => "Enter text ...", -pos => [100,100], -size => [300,90], -helpbox => 0, ); my $tf = $mw->AddTextfield( -pos => [10,10], -size => [$mw->ScaleWidth() - 20, 20], -tabstop => 1, ); $mw->AddButton( -text => 'Ok', -ok => 1, -default => 1, -tabstop => 1, -pos => [$mw->ScaleWidth()-156,$mw->ScaleHeight()-30], -size => [70,20], -onClick => sub { $text = $tf->Text(); return -1; }, ); $mw->AddButton( -text => 'Cancel', -cancel => 1, -tabstop => 1, -pos => [$mw->ScaleWidth()-80,$mw->ScaleHeight()-30], -size => [70,20], -onClick => sub { return -1; }, ); $mw->Show(); $tf->SetFocus(); Win32::GUI::Dialog(); return $text; } Regards, Rob. -- Robert May Win32::GUI, a perl extension for native Win32 applications http://perl-win32-gui.sourceforge.net/