Hello All! So I have a particularly vexing situation. I am running a dual monitor setup (different sized monitors too), and since I'm usually using my main application on my second (and larger) monitor, I would like my AHK Gui's to show up on that monitor. I finally developed a way to force popup's to appear centered on top of the last active window, but it requires that the popup (my Gui in this case) to be shown before it's moved, which looks bad.
So my question is this: with GUI's, is there a way to move them after they're created, but before they're shown?
Alternatively, is there a way I could use an expression in the Gui, Show line to determine it's location? use expressions for the X and Y coordinates, along with the width/height of the GUI to center it on a window?
Thanks!
Paul
Moving a Gui Window before it's shown
- PaulLeavitt
- Posts: 58
- Joined: 21 Oct 2014, 10:04
Re: Moving a Gui Window before it's shown
it's simple, see if this helps:is there a way to move them after they're created, but before they're shown?
use Gui, Show, Hide ; the window is hidden
then
Get the window itself position by means of WinGetPos; you way want to use DetectHiddenWindows
and move it as you want, with Gui, Show or WinMove
NO, but use the method aboveis there a way I could use an expression in the Gui, Show line to determine it's location
same as above, except get the position of the window in question, and make your math to center your GUI ituse expressions for the X and Y coordinates, along with the width/height of the GUI to center it on a window?
if by expressions you mean expression
one more thing, your approach is a bit strange, and I'm not sure if it is 100% accurate, if so and if you can, post your sample code for that specific taskBy contrast, the expression method omits the percent signs around variable names, but encloses literal strings in quotes. Thus, the following are the expression equivalents of the previous examples:
MsgBox % "The value in the variable named Var is " . Var . "." ; A period is used to concatenate (join) two strings.
CopyOfVar := Var
Re: Moving a Gui Window before it's shown
"Gui, Show" has as part of it coordinates to show. You could have it show on the other monitor I am assuming. You might need to use some kind of DllCall to find out which monitor or something, not sure of the syntax on that myself, but I am sure you can find it on the forum. If that doesn't work, set in the gui options, +LastFound and then use the WinMove command as though the Gui was last found. 2 options for you.
Re: Moving a Gui Window before it's shown
You can use the SysGet command to get the coordinates of a monitor.
Re: Moving a Gui Window before it's shown
Oh yeah forgot about that one.
Re: Moving a Gui Window before it's shown
Code: Select all
WinGetPos,X,Y,Width,Height,A
Xpos:=X+Width/2-50
Ypos:=Y+Height/2-50
Gui, Add, Button, x8 y8 w100 h100
Gui, Show, x%Xpos% y%Ypos%
Re: Moving a Gui Window before it's shown
I am pretty sure that you only need to set the Gui position in "Gui, Show" parameters, pardon the mis-nomer.
Who is online
Users browsing this forum: mstrauss2021, peter_ahk, Spawnova, zephyrus2706 and 351 guests