Jump to content
Sign in to follow this  
Diana (Cda)

Way to get AI as intermediary - open multiple files at once in MS Paint?

Recommended Posts

Diana (Cda)

Does anyone know of a way, esp. for someone like me who is okay writing in AI but is not an expert even after many years, to get something like MS Paint to open many files at once. It natively doesn't do that and you have to open files manually one by one.

Perhaps a box one can dump all the selected files into that then AI has MS Paint open one by one ... ???!???

Thx.

Share this post


Link to post
Share on other sites
water

Which part gives you problems? The file selection part or the MS Paint part? Do you want one MS Paint process opening all files or could there be many processes?

Is MS Paint just an example (means you need to use Word or Excel or ...) or do you use MS Paint in real life?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tripredacus

MS Paint is a simple type program that doesn't allow you to have multiple files open in one instance, so you would need to evoke MS Paint each time. So you can get your image list, stick it into an array and then have MS Paint open each. This cmd example I used ends up opening 2 MS Paints ...

C:\Users\LioKaiser>mspaint d:\tyler.jpg

C:\Users\LioKaiser>mspaint d:\mushi.jpg

Share this post


Link to post
Share on other sites
Diana (Cda)

MS Paint is a simple type program that doesn't allow you to have multiple files open in one instance, so you would need to evoke MS Paint each time. So you can get your image list, stick it into an array and then have MS Paint open each. This cmd example I used ends up opening 2 MS Paints ...

C:\Users\LioKaiser>mspaint d:\tyler.jpg

C:\Users\LioKaiser>mspaint d:\mushi.jpg

Yes, no problems with the SDI nature of MS Paint. The goal would be to hopefully be able to open more than one file at one time. It's rather tedious working in Paint because of that; but that's the only option available at work as computers are locked down.

I've never managed to get a handle on arrays, though. Also, the nature of the example above doesn't help save time, either. By the time I would write the code above, I'd have opened the files, so that method above defeats the purpose.I do work screenshot tutorials all the time, and for years I've been forced to live with the limited functionality of Paint in this manner.

Would there be an easier way to do this? What would be ideal, although I shudder at the coding involved, is to have an AI box we open and then dump selected image files into that then get opened one-by-one by Paint. That's the best scenario I can think of. But I must admit that I'm hoping it'll be simple enough to do as I have limited coding skills. However, I do write GUIs up fairly well.

Any comments re this type of workaround?

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites
Diana (Cda)

Which part gives you problems? The file selection part or the MS Paint part? Do you want one MS Paint process opening all files or could there be many processes?

Is MS Paint just an example (means you need to use Word or Excel or ...) or do you use MS Paint in real life?

Hi, thanks.

File opening part is the problem in Paint. It's an SDI program and won't open multiple files at once.

No, just Paint is the issue.

Cheers.

Share this post


Link to post
Share on other sites
kylomas

Diana,

have an AI box we open and then dump selected image files into that then get opened one-by-one by Paint

Here' a simple example of the above...

; *** Start added by AutoIt3Wrapper ***
#include <EditConstants.au3>
; *** End added by AutoIt3Wrapper ***

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

local $gui010   =   guicreate('',600,600)
local $aSize    =   wingetclientsize($gui010)
                    guisetfont(8.5,600)
                    guictrlcreatelabel('Folder',            020,020,050,20)
local $inp010   =   guictrlcreateinput('',                  070,020,470,20)
local $btn010   =   guictrlcreatebutton('...',              560,020,20,20)
                    guictrlcreatelabel('Files Selected',    020,050,200,20)
local $edt010   =   guictrlcreateedit('',                   020,070,$asize[0]-40,200,$es_readonly)
                    guictrlcreatelabel('Log',               020,290,200,20)
local $edt020   =   guictrlcreateedit('',                   020,310,$asize[0]-40,200,$es_readonly)
local $btn020   =   guictrlcreatebutton('Start an Instance of Paint For Each File Listed',20,$asize[1]-30,$asize[0]-40,20)
                    guisetstate()

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
        case $inp010
            guictrlsetdata($edt010,chk_folder(guictrlread($inp010)))
        case $btn010
            guictrlsetdata($edt010,chk_folder('?'))
        case $btn020
            if stringlen(guictrlread($inp010)) = 0 then
                guictrlsetdata($edt010,chk_folder(guictrlread($inp010)))
            Else
                do_paint(guictrlread($edt010))
            endif
    EndSwitch
WEnd


func chk_folder($str)

    if stringlen(stringstripws($str,3)) = 0 then
        guictrlsetdata($edt020,'Enter a folder name' & @crlf,1)
        guictrlsetstate($inp010,$gui_focus)
        Return ''
    endif

    if stringright($str,1) <> '\' then $str = $str & '\'

    local $folder

    guictrlsetdata($edt020,'Processing folder = ' & $str & @crlf,1)

    if not fileexists($str) then

        guictrlsetdata($edt010,'Folder = ' & $str & ' does not exist - starting folder selection dialog' & @crlf,1)
        $folder = FileSelectFolder("Choose a folder.", $str)
        if @error = 1 then
            if $str <> '?' then
                guictrlsetdata($edt020,'Folder Selection terminated' & @crlf,1)
                guictrlsetdata($inp010,'')
                guictrlsetstate($inp010,$gui_focus)
                Return ''
            endif
        endif

        guictrlsetdata($inp010,$folder)

    endif

    return get_files($folder)

endfunc

func get_files($str)

    if stringright($str,1) <> '\' then $str = $str & '\'

    local $files, $afiles
    $files = FileOpenDialog('My Paint Files',$str,'Paint (*.gif)',4)

    if stringinstr($files,'|') = 0 then
        $afiles = stringsplit($files,'\')
        return $afiles[ubound($afiles) - 1]
    else
        $afiles = stringsplit($files,'|')
        return _arraytostring($afiles,@crlf,2,ubound($afiles) - 1)
    endif

endfunc

func do_paint($str)

    ; here's where you do your thing...

    $afiles = stringsplit($str,@crlf,1)

    for $1 = 1 to $afiles[0]

        ; I'm just displaying the files as they are found in the array...do whatever you want

        guictrlsetdata($edt020,'I just did something for file = ' & $afiles[$1] & @crlf,1)
    Next

endfunc

kylomas

edit: added check for blank folder name

edit2: added more checks and changed edit controls to readonly

edit3: fixed button to drive folder select dialog

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×