Control goes off the screen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
julesverne
Posts: 42
Joined: 18 Apr 2017, 14:39
Contact:

Control goes off the screen

03 Nov 2020, 19:33

Hi all,

This issue has had me perplexed for awhile now.

Endgame: Create a GUI and a control that consistently displays correctly regardless of resolution and scale using this simple code below.

Code: Select all

Gui, Add, ActiveX, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% vWMP Center, WMPLayer.OCX
Gui, Show, % "w" A_ScreenWidth " h" A_ScreenHeight " Maximize", Player
Return
Currently, the control goes off the screen, yet the gui does not. Hardcoding a padding to the right side of the screen for the control (via wWidth) would produce different results for all the different resolutions and scales, so this isn't an option. Any suggestions?

Thanks!
jules
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Control goes off the screen

03 Nov 2020, 21:58

Code: Select all

SysGet, m, MonitorWorkArea
width := mRight - mLeft, height := mBottom - mTop
Gui, New,, Player
Gui, Add, ActiveX, x0 y0 w%width% h%height% vWMP, WMPLayer.OCX
Gui, Show
Gui, +LastFound
WinMove, 0, %mTop%
GuiControl, Move, WMP, x0 y0 w%gw% h%gh%
Return

GuiSize:
gw := A_GuiWidth, gh := A_GuiHeight
Return

F4::
GuiEscape:
GuiClose:
SoundBeep, 1500, 20
ExitApp
julesverne
Posts: 42
Joined: 18 Apr 2017, 14:39
Contact:

Re: Control goes off the screen

03 Nov 2020, 23:38

This is brilliant!! Thank you @mikeyww I honestly didn't think this would be a possibility.

I'm curious now, using your method, about two things.
  • Is there a way to have a consistent relative space between the bottom of the player and the bottom of the screen?
I'd like to put a rectangular graphic that spans most of the width of the screen but fits inside this space between the bottom of the player and the bottom of the screen probably with a slight consistent but relative padding on both top and bottom and the sides.
  • Is there a way to have a consistent relative position from both the left and right sides of the screen where the image would start and end.
Looking at the player right now I'm thinking I would like the left edge of the image to start where the audio timeline starts and the right edge of the image to end where the timeline ends. For clarity I guess I'm essentially asking for a padding on both sides of the image but with these positions being relative to whatever resolution scaling is happening.

I added the image control to the code where I'm guessing you'd put it but added question marks to those area I'd be unsure of.

In regards to the stretching of the image file, I'm not concerned about that as the image is a simple color scheme.

Thank you in advance for your insight and thank you again for solving the first problem. I was seriously banging my head on my desk.

Code: Select all

SysGet, m, MonitorWorkArea
width := mRight - mLeft, height := mBottom - mTop
Gui, New,, Player
Gui, Add, ActiveX, x0 y0 w%width% h%height% vWMP, WMPLayer.OCX
Gui, Add, Picture, xm? y? w%width% h? vImg
Gui, Show
Gui, +LastFound
WinMove, 0, %mTop%
GuiControl, Move, WMP, x0 y0 w%gw% h%gh%
GuiControl, Move, Img, xm? y? w%gw% h?
Return

GuiSize:
gw := A_GuiWidth, gh := A_GuiHeight
Return

F4::
GuiEscape:
GuiClose:
SoundBeep, 1500, 20
ExitApp
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Control goes off the screen

04 Nov 2020, 00:00

Adjust as needed. You can add more boxes, etc. and just position them wherever you like. This is an example of padding. You can adjust the spacing to meet your needs.

Code: Select all

pic = e:\data\images\Sunflower_from_Silesia2.jpg
SysGet, m, MonitorWorkArea
width := mRight - mLeft, picHeight := 100, AXheight := mBottom - mTop - picHeight, padding := 10
Gui, New,, Player
Gui, Add, ActiveX, x0 y0 w%width% h%AXheight% vWMP, WMPLayer.OCX
Gui, Add, Picture, x0 y+0 wp h-1 vImg, %pic%
Gui, Show
Gui, +LastFound
WinMove, 0, %mTop%
AXheight := gh - picHeight, picY := AXheight + padding
picX := padding * 2, picWidth := gw - 4 * padding, picHeight -= 2 * padding
GuiControl, Move, WMP, x0 y0 w%gw% h%AXheight%
GuiControl, Move, Img, x%picX% y%picY% w%picWidth% h%picHeight%
Return

GuiSize:
gw := A_GuiWidth, gh := A_GuiHeight
Return

F4::
GuiEscape:
GuiClose:
SoundBeep, 1500, 20
ExitApp
Here is some information about scaling.
julesverne
Posts: 42
Joined: 18 Apr 2017, 14:39
Contact:

Re: Control goes off the screen

04 Nov 2020, 10:23

Wow @mikeyww Thank you again! And what's even better is with your example I believe I understand it too so I can make the modifications I need to. This is awesome! Thank you! :bravo:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Bing [Bot], RickC, Spawnova and 66 guests