Though what others have said about XY problem and no need in neither paint.net nor any GUI to process images is true, here's an example, using Win32::GuiTest. Note, that in more general (or complex) case, you may have better chances with dedicated tools.

I once had to automate a windows port of MacOS 9 (i.e. old, "Classic") app, which could only serve as a single file drop-target, a file at a time -- pinnacle of user-friendliness. No keyboard shortcuts, no CLI arguments processing (because MacOS 9), no AppleScript (because Windows) - worst of both worlds. It explains where from WM_DROPFILES is salvaged, below -- to show that "hard things are possible" -- but it's certainly overkill for such simple example. That said, it's probably fastest way to open a file in GUI. See MS docs for relevant data structures.

It's for English (non-localized) Windows 7 (Server 2008, actually) mspaint version, your shortcuts may be different.

use strict; use warnings; use feature 'say'; use Cwd 'cwd'; use File::Spec::Functions 'catfile'; use Win32::GuiTest qw( WaitWindow SendMessage AllocateVirtualBuffer WriteToVirtualBuffer FreeVirtualBuffer SetForegroundWindow SendKeys PushButton ); my $WM_DROPFILES = 0x233; my $pid = system 1, 'mspaint.exe'; my ( $h ) = WaitWindow( ' - Paint' ); for ( <*.jpg> ) { # I have a few JPGs in cwd. next if /flipped/; # Seen, skip. my $drop = pack 'LLLCCZ*x', 14, 0, 0, 0, 0, catfile cwd, $_; my $buf = AllocateVirtualBuffer( $h, length $drop ); WriteToVirtualBuffer( $buf, $drop ); SendMessage( $h, $WM_DROPFILES, $buf-> { ptr }, 0 ); FreeVirtualBuffer( $buf ); SetForegroundWindow( $h ); SendKeys( '%(hrov)' ); # Alt-Home, Rotate, Vertical_flip. # You like your pictures upside down, +don't you. SendKeys( '%(fa)' ); # Alt-File, Save As. WaitWindow( 'Save As' ); s/(?=.jpg$)/_flipped/; unlink; # Overwrite! Avoid needless idle quest +ions. SendKeys( $_, 1 ); PushButton( '&Save' ); sleep 1; # To prevent next file dropped when ap +p still # not sure if current file was saved. } SendKeys( '%{F4}' ); # Alt-F4, of course. No need to kill $ +pid. __END__

In reply to Re: Executing external programs by vr
in thread Executing external programs by Silt

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.