lazy win32 question 
Author Message
 lazy win32 question

This isn't really a perlTK question, but it involves Perl and GUIs.

How do I programmatically do the equivalent of a double-click on a file icon?
For instance, double clicking on "foo.html" in Windows Explorer opens the file
with Internet Explorer.

None of these work:

 system("foo.html");

 system("foo.html &");

 system("cmd.exe /c foo.html");

 system("cmd.exe /c foo.html &");

although most of these work fine at the WinXP command prompt.

The second example does nothing UNTIL the perl script exits, and then it runs
iexplorer. I think this is the infamous "fork"ing issue on Win32.

This must be trivial, but I can't figure it out! I didn't see anything obvious
in the Win32 pod.

-Mark

Mark Lakata, Staff Engineer    1225 Charleston Road       voice 650-567-5170
MIPS Technologies              Mountain View CA 94043     fax   650-567-5002

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 03:25:41 GMT  
 lazy win32 question
I wish it worked ... but it doesn't work for html files :(.  The script below
worked for the "pushme" button (a text file in notepad), but the "and me"
button just hung, until I killed the script with ^c, at which point IE came
up...

-Mark

C:\>more testgui.pl
#!perl

use Tk;

$m = new MainWindow;
$m->Button(-text=>"pushme",
           -command => sub {
               system("start statusdump.txt");
           })->pack();
$m->Button(-text=>"and me",
           -command => sub {
               system("start downloadtest.html");
           })->pack();

MainLoop;

Mark Lakata, Staff Engineer    1225 Charleston Road       voice 650-567-5170
MIPS Technologies              Mountain View CA 94043     fax   650-567-5002

Quote:

> Try system("start foo.html");

> --Toby Everett

>            -----Original Message-----

>            Sent:   Wednesday, October 09, 2002 10:27 AM
>            To:     PerlTk mailing list
>            Subject:        lazy win32 question

>            This isn't really a perlTK question, but it involves Perl
> and GUIs.

>            How do I programmatically do the equivalent of a
> double-click on a file icon?
>            For instance, double clicking on "foo.html" in Windows
> Explorer opens the file
>            with Internet Explorer.

>            None of these work:

>             system("foo.html");

>             system("foo.html &");

>             system("cmd.exe /c foo.html");

>             system("cmd.exe /c foo.html &");

>            although most of these work fine at the WinXP command
> prompt.

>            The second example does nothing UNTIL the perl script exits,
> and then it runs
>            iexplorer. I think this is the infamous "fork"ing issue on
> Win32.

>            This must be trivial, but I can't figure it out! I didn't
> see anything obvious
>            in the Win32 pod.

>            -Mark

>            Mark Lakata, Staff Engineer    1225 Charleston Road
> voice 650-567-5170
>            MIPS Technologies              Mountain View CA 94043
> fax   650-567-5002

>            -++**==--++**==--++**==--++**==--++**==--++**==--++**==
>            This message was posted through the Stanford campus mailing
> list
>            server.  If you wish to unsubscribe from this mailing list,
> send the
>            message body of "unsubscribe ptk" to


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 04:23:18 GMT  
 lazy win32 question
Use something like

    use strict ;

    use Win32::API ;

    my $shell_exec = new Win32::API("SHELL32", "ShellExecute",
                                    "NNPNNN", "N") ;

    my $file = shift ;

    if ( $file && -f $file )
    {
      $shell_exec->Call(0, 0, $file, 0, 0, 3) ;    # 3 -> maximised
    }

Hope this helps

Tom Cosgrove

Quote:
>>> Mark Lakata 9-Oct-02 19:26 >>>

This isn't really a perlTK question, but it involves Perl and GUIs.

How do I programmatically do the equivalent of a double-click on a file icon?
For instance, double clicking on "foo.html" in Windows Explorer opens the file
with Internet Explorer.

None of these work:

 system("foo.html");

 system("foo.html &");

 system("cmd.exe /c foo.html");

 system("cmd.exe /c foo.html &");

although most of these work fine at the WinXP command prompt.

The second example does nothing UNTIL the perl script exits, and then it runs
iexplorer. I think this is the infamous "fork"ing issue on Win32.

This must be trivial, but I can't figure it out! I didn't see anything obvious
in the Win32 pod.

-Mark
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 04:56:16 GMT  
 lazy win32 question
To find out what win* is doing, get to the
"Folder Options" options in one of their
file browser windows and click the "File
Types" tab. Scroll to the file type you want
and click the "Edit..." button. Select the
appropriate option (most likely "open")
from the "Actions:" area and click another
"Edit..." button. The "Application used to
perform action:" textbox will contain the
command line you want to use, and the
filename itself will be represented by a
"%1" (quotes needed for long filenames)

Click "Cancel", and "Cancel", and "Cancel"
buttons to get out of there without
messing things up.

And hopefully it will work. :-)

This isn't really a perlTK question, but it involves Perl and GUIs.

How do I programmatically do the equivalent of a double-click on a file
icon?
For instance, double clicking on "foo.html" in Windows Explorer opens
the file
with Internet Explorer.

None of these work:

 system("foo.html");

 system("foo.html &");

 system("cmd.exe /c foo.html");

 system("cmd.exe /c foo.html &");

although most of these work fine at the WinXP command prompt.

The second example does nothing UNTIL the perl script exits, and then
it runs
iexplorer. I think this is the infamous "fork"ing issue on Win32.

This must be trivial, but I can't figure it out! I didn't see anything
obvious
in the Win32 pod.

-Mark

Mark Lakata, Staff Engineer    1225 Charleston Road       voice
650-567-5170
MIPS Technologies              Mountain View CA 94043     fax  
650-567-5002

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 05:11:43 GMT  
 lazy win32 question

Quote:

> This isn't really a perlTK question, but it involves Perl and GUIs.

> How do I programmatically do the equivalent of a double-click on a file icon?
> For instance, double clicking on "foo.html" in Windows Explorer opens the file
> with Internet Explorer.

> None of these work:

>  system("foo.html");

>  system("foo.html &");

>  system("cmd.exe /c foo.html");

>  system("cmd.exe /c foo.html &");

> although most of these work fine at the WinXP command prompt.

> The second example does nothing UNTIL the perl script exits, and then it runs
> iexplorer. I think this is the infamous "fork"ing issue on Win32.

> This must be trivial, but I can't figure it out! I didn't see anything obvious
> in the Win32 pod.

> -Mark

Maybe

        system("start foo.html")

?

Regards,
        Slaven

--

    tkrevdiff - graphical display of diffs between revisions (RCS or CVS)
    http://ptktools.sourceforge.net/#tkrevdiff
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 07:32:24 GMT  
 lazy win32 question
Okay. I have done some more digging. The problem seems to occur with DDE --
because Tk doesn't hang without it.

Here is my test program:

use Tk;
use strict;

my $file="C:/test.html";

my $mw=tkinit;
$mw->Button(
 -text=>'Launch',
 -command=>sub{
  system("start $file");
 })->pack;
MainLoop;

...yes, this hangs. Make some changes as below (but look at my #3 observation
first!!):

Double Click on My Computer.
View->Options->File Types TAB
Scroll to HTML Document and highlight it
Click Edit
Highlight Open
Click Edit
Uncheck Use DDE
In my application box it says:
"C:\PROGRA~1\INTERN~1\iexplore.exe" -nohome

Run the program again...and it does not hang.

Some observations:
1. It seems as if the 'start' call gets routed through the MS DOS window which
is controlling your Tk script. I say this because as soon as the Launch button
is clicked the titlebar in the DOS window changes to the system call string.

2. Which is easier...ask all users to change their File Type associations, or
ask them to download and install Win32::Shell?

3. In turning off DDE, all options are lost. A search on the web will bring many
answers on how to reset this if needed. (I'm not sure if or how this affects my
surfing power -- :-) I'm definitely going to try it without this DDE stuff...

Jack
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 12:11:21 GMT  
 lazy win32 question

Quote:

> Okay. I have done some more digging. The problem seems to occur with DDE --
> because Tk doesn't hang without it.

> Here is my test program:

> use Tk;
> use strict;

> my $file="C:/test.html";

> my $mw=tkinit;
> $mw->Button(
>  -text=>'Launch',
>  -command=>sub{
>   system("start $file");
>  })->pack;
> MainLoop;

> ..yes, this hangs. Make some changes as below (but look at my #3 observation
> first!!):

> Double Click on My Computer.
> View->Options->File Types TAB
> Scroll to HTML Document and highlight it
> Click Edit
> Highlight Open
> Click Edit
> Uncheck Use DDE
> In my application box it says:
> "C:\PROGRA~1\INTERN~1\iexplore.exe" -nohome

> Run the program again...and it does not hang.

> Some observations:
> 1. It seems as if the 'start' call gets routed through the MS DOS window which
> is controlling your Tk script. I say this because as soon as the Launch button
> is clicked the titlebar in the DOS window changes to the system call string.

Maybe the behavior changes if you start the Perl/Tk program with
wperl.exe instead of perl.exe.

Quote:
> 2. Which is easier...ask all users to change their File Type associations, or
> ask them to download and install Win32::Shell?

The latter, because it can be automated.

Quote:
> 3. In turning off DDE, all options are lost. A search on the web will bring many
> answers on how to reset this if needed. (I'm not sure if or how this affects my
> surfing power -- :-) I'm definitely going to try it without this DDE stuff...

Regards,
        Slaven

--

Tk-AppMaster: a perl/Tk module launcher designed for handhelds
        http://tk-appmaster.sf.net
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 28 Mar 2005 17:31:56 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Nonmember submission: RE: lazy win32 question

2. ANNOUNCE: Lazy.pm (Lazy evaluation)

3. Lazy question..

4. Lazy Linking

5. general Lazy Evaluation implemented with tie

6. Pack an Array (the lazy way)

7. Non lazy "or"?

8. Looking for template with lazy (on-demand) data insertion

9. I'm being lazy and need a unregexpifier

10. Emacs cperl-mode.el vs font-lock/lazy-lock

11. Flushing output to lazy sockets

12. Pack an Array (the lazy way)

 

 
Powered by phpBB® Forum Software