Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to control MS Paint

Status
Not open for further replies.

snotmare

Programmer
Jan 15, 2004
262
US
Hello all!

Does anyone know how to control MS Paint via a script? I'm trying to accomplish a task that will process all pictures in a given folder, and basically resize each picture to 1/2 its origional size. I can handle the FSO process fine, I'm just not sure how to handle the resizing of the pictures.

Any ideas?

Thanks all!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
If you know how to do it by hand then you can use script with the SendKeys function.

here is an example that will open a command promot. Type in it and start calculator.

Code:
'==========================================================================
'
' NAME: SendKeysStartApplication.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 12/1/2004
'
' COMMENT: <comment>
'
'==========================================================================

Set WshShell = CreateObject("WScript.Shell")
' zero makes window hidden, one makes it normal, false makes it run without waiting to close the application
WshShell.Run "cmd.exe", 1, false
wscript.sleep 200
'Setting focus to the window you want
WshShell.AppActivate "cmd"
'wait for it......
wscript.sleep 200
WshShell.SendKeys "Start calc.exe"
wscript.sleep 200
'the tilde is the same as the ENTER key
WshShell.SendKeys "~"

I hope you find this post helpful.

Regards,

Mark
 
Thanks for the response markdmac! I try to use the send keys method as a last ditch effort to get something done. If there is no other way, then I guess that'll be route I need to take. I've posted this question to Microsoft's scripting guys, and haven't seen my post yet. I post the response here if I ever get one.

In the meantime, anyone have any other ideas?

Thanks!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top