Scale a Picture GUI control in proportion to Desktop and Window size and positions

Get help with using AutoHotkey and its commands and hotkeys
JasonDavisFL
Posts: 9
Joined: 12 Jan 2018, 13:05
Facebook: JasonDavis83
GitHub: JasonDavisFL

Scale a Picture GUI control in proportion to Desktop and Window size and positions

09 Feb 2018, 09:57

Hello I am new to AHK but I have some amazing projects in development I will share as progress is made.

The 1 I am working on now is a Windows Manager GUI app
One of the features I am working on is to use a AHK Slide GUI control to:

- resize a window from the left edge of windo, right edge, top, and bottom edge
- Move a window right, left, up, down using Slider GUI controls
- Show a Picture GUI representing the size and shape of the desktop resized down but in proportion
- On top of the Desktop GUI picture, show a Picture GUI control representing a Window on the Desktop scaled down to the same scale as desktop picture and positioned on the GUI to also represent the correct scaled down Xpos and Ypos that the real window is on the desktop so the GUI shows a preview of the window how it is sized and positioned on the desktop
- With the preview Picture GUI controls I can then resize and move the window picture GUI on top of the desktop Picture GUI as the Sliders are moved

What I need help with:

1) Figure out what scale/percent a 200px width picture GUI control is compared to the selected desktop screens Width and Height
2) Using the above scale/percent, Get the selected Windows width/height and Xpos/Ypos and use that scale to resize the Window Picture GUI to be at the same scale as the desktop picture GUI and position it X/Y on the image at the correct location to reflect the real window on desktop

I am not sure how to do the Math to determine these, any help appreciated.

Any help aprreciated


Image


Here is the basic starter demo for playing with the slider to resize/move the picture controls

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Gui, Add, Slider, gshow_result w500 vMySlider Range1-100 TickInterval1, 50
Gui Add, Picture, x1 y100 w455 h355 vMyEdit, F:\My Photos\Web_Dev_Photos\Inspiration\draft_biogrify_mockups.png
gui, show

GuiControlGet, MyEdit, Pos
return


show_result:
global MyEdit
GuiControlGet, result , , MySlider, 
final_result:=result
tooltip % final_result

MsgBox The X coordinate is %MyEditX%. The Y coordinate is %MyEditY%. The width is %MyEditW%. The height is %MyEditH%.
picWidthPercent := MyEditW/100
newPicWidth := picWidthPercent * final_result
MsgBox, %newPicWidth%
GuiControl, MoveDraw, MyEdit, % "x" MyEditX "y" MyEditY "w"newPicWidth "h220" ; Uses an expression via "% " prefix.

return
JasonDavisFL
Posts: 9
Joined: 12 Jan 2018, 13:05
Facebook: JasonDavis83
GitHub: JasonDavisFL

Re: Scale a Picture GUI control in proportion to Desktop and Window size and positions

09 Feb 2018, 10:39

Update I think I got it figured out now, will post my answer soon

Return to “Ask For Help”

Who is online

Users browsing this forum: autohotkeycool, hasantr, Jose Hidalgo, mikeyww, the_body, wineguy and 44 guests