MS PAIN - AUTOMATION OF REPEATED TASK

Get help with using AutoHotkey and its commands and hotkeys
subinpv85
Posts: 3
Joined: 18 Oct 2018, 11:54

MS PAIN - AUTOMATION OF REPEATED TASK

18 Oct 2018, 12:18

I AM QUITE NEW TO AUTOHOTKEY.
I HAVE GOT 100 IMAGE FILES. I NEED TO OPEN EACH OF THEM AND RESIZE TO 100X100 PIXELS. CAN ANYONE HELP ME TO GET A SCRIPT TO DO THE SAME USING AUTOHOTKEY.
ACTUALLY I NEED TO MAKE A PHOTO MOSAIC WITH THE RESIZED IMAGES.
swagfag
Posts: 1372
Joined: 11 Jan 2017, 17:59

Re: MS PAIN - AUTOMATION OF REPEATED TASK

18 Oct 2018, 12:46

u can do it with imagemagick:
  • put all ur images in a folder
  • open a terminal in that folder/navigate to it
  • mkdir outdir
  • mogrify -path outdir -resize 100x100! * (delete !, if u wanna preserve aspect ratio)
imagemagick can probably do the mosaic part too, but i trust ull be able to google that urself
subinpv85
Posts: 3
Joined: 18 Oct 2018, 11:54

Re: MS PAIN - AUTOMATION OF REPEATED TASK

19 Oct 2018, 09:23

thanks for your reply....
it helps....
but can i do the same using autohotkey scripts....? just want to learn the scripting techniques..
swagfag
Posts: 1372
Joined: 11 Jan 2017, 17:59

Re: MS PAIN - AUTOMATION OF REPEATED TASK

19 Oct 2018, 19:11

but can i do the same using autohotkey scripts....?
uh, yes, i suppose u could. with moderate success, u could also use a flappy dildo as a makeshift hammer to bludgeon nails in a piece of 2x4. ...but why though? why would u do any of that?

anyways, i recommend u make a backup of ur imgs elsewhere as well

Code: Select all

#NoEnv
#SingleInstance Force
SendMode Input
SetWorkingDir %A_ScriptDir%

/*
folder structure should be

some_folder
  - src
    - img1.png
    - img2.png
    - etc...
  - dest
  - script.ahk
*/

FileCopyDir src, dest, 1

Loop Files, dest\*.png
	ResizeWithPaint(A_LoopFileFullPath)

ResizeWithPaint(fileFullPath) {
	static CMD := A_ComSpec " /c mspaint ""{}"""

	Run % Format(CMD, fileFullPath) ; run paint with file
	Sleep 300
	Send !fe100{Tab}100{Enter}!{F4}s ; properties -> change dims 100x100 -> ok -> altf4 -> confirm save
}
subinpv85
Posts: 3
Joined: 18 Oct 2018, 11:54

Re: MS PAIN - AUTOMATION OF REPEATED TASK

20 Oct 2018, 17:24

Thank you very much for your help.
It works ….
I googled for all the keywords, that u used in the script and understood the basics of script writing. Im really excited.
There was a small issue….while resizing it always gives the top left 100x100 pixel area only. My intention was to resize the entire image …so i just replaced !fe with !hre with opens a different menu for resizing and some minor adjustments based on the new menu. And i inserted some sleeps in between. Now it works perfectly for me….
Once again thanks.....

Return to “Ask For Help”

Who is online

Users browsing this forum: Gh0sTG0, Mipha, Scr1pter, SOTE, wryyymuda and 32 guests