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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |