Resize Picture In GUI

Get help with using AutoHotkey and its commands and hotkeys
scriptor2016
Posts: 646
Joined: 21 Dec 2015, 02:34

Resize Picture In GUI

19 Feb 2020, 01:39

Hi, this might be a dumb question but hey here goes anyways:

1. create a new GUI and load an image into it.
If the GUI size is 600x600, then the image loaded into it will scale to 600x600 so the GUI is filled with the picutre

2. The GUI will have +Resize as an option.
So when the GUI is resized, the image will also resize along with it. So if we drag the GUI borders to make it very big, then the picture size scales up
along with it. And if we drag the borders and make the GUI very small, then the picture will scale down with it and also be very small.

Seems like such an easy thing to ask, but I don't know how to explain it so easily.

I haven't found anything on the forums about this.

Anyone know if this is possible?
User avatar
flyingDman
Posts: 757
Joined: 29 Sep 2013, 19:01

Re: Resize Picture In GUI

19 Feb 2020, 02:27

Have you looked at guisize (https://www.autohotkey.com/docs/commands/Gui.htm#GuiSize)?

Code: Select all

gui, -dpiscale
gui, -caption +resize
gui, add, picture, x0 y0 w200 h200 vmypic, image1.jpg
gui, show
return

guisize:
GuiControl, Move, mypic, % "w" . A_GuiWidth . " h" . A_GuiHeight
winset redraw
return
If you want to keep the aspect ratio constant, you can do something like this (assuming you have a square image)

Code: Select all

guisize:
GuiControl, Move, mypic, % "w" . A_GuiWidth . " h" . A_GuiWidth
winmove, A,,,, A_GuiWidth, A_GuiWidth
winset redraw
return
scriptor2016
Posts: 646
Joined: 21 Dec 2015, 02:34

Re: Resize Picture In GUI

19 Feb 2020, 09:37

thanks, this is AWESOME!!

I knew it was something simple but for whatever reason it's something I've never looked into over the years.

Looks like this will be exactly what I need, though :)

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Google [Bot], Xtra and 133 guests