I want to move the pop-up window to the right bottom of the corner
-
- Posts: 10
- Joined: 21 May 2023, 07:43
I want to move the pop-up window to the right bottom of the corner
I've created a little pop-up program in AHK with the help of chatGPT (I have no knowledge of coding), and it works like a charm (after a lot of testing and reading myself)! Now what remains are a little improvements I want to make where ChatGPT is useless.
What I want to add:
As soon as I start the script the window/pop-up appears right at the center of the screen, and I have to move it manually every time.
Instead, I want the window to be positioned at the right bottom of the corner. And I want this to be applied to all and any screens and resolutions this program is opened on.
It seems I have created this code with AutoHotKey 1.1.36 (I installed v2, but a popup appeared said I needed 1.1).
____________________________
Examples of failed codes I tried that ChatGPT generated:
[Mod edit: Removed code. No need to post non-working ChatGPT code. Please respect the forum rules, especially about 'Inappropriate content' (4.)]
What I want to add:
As soon as I start the script the window/pop-up appears right at the center of the screen, and I have to move it manually every time.
Instead, I want the window to be positioned at the right bottom of the corner. And I want this to be applied to all and any screens and resolutions this program is opened on.
It seems I have created this code with AutoHotKey 1.1.36 (I installed v2, but a popup appeared said I needed 1.1).
____________________________
Examples of failed codes I tried that ChatGPT generated:
[Mod edit: Removed code. No need to post non-working ChatGPT code. Please respect the forum rules, especially about 'Inappropriate content' (4.)]
Re: I want to move the pop-up window to the right bottom of the corner
Please don't post non-working ChatGPT code, it's against the forum rules: please see link above.
If you have taken some AI-generated code as a starting point and worked with it or made it work, that's acceptable. In that case, you could post your current code, so that your potential helpers can build on that working code.
Generally, you can use AHK v1 and v2 side-by-side - but those versions are not very compatible. ChatGPT's learning corpus is a few years old, so it usually puts out v1 code (or something that looks more or less like it), or outdated v2 code (from the time when v2 was still in earlier development phases).
If you have taken some AI-generated code as a starting point and worked with it or made it work, that's acceptable. In that case, you could post your current code, so that your potential helpers can build on that working code.
Generally, you can use AHK v1 and v2 side-by-side - but those versions are not very compatible. ChatGPT's learning corpus is a few years old, so it usually puts out v1 code (or something that looks more or less like it), or outdated v2 code (from the time when v2 was still in earlier development phases).
-
- Posts: 10
- Joined: 21 May 2023, 07:43
Re: I want to move the pop-up window to the right bottom of the corner
Sorry about that. Thanks for both of your clarifications.
I was contemplating about whether to post the entire code (it's work related), but I figured since I really want to add a code snippet irrelevant of the actual code then someone could offer assistance regardless.
Anyway, here is the code.
I was contemplating about whether to post the entire code (it's work related), but I figured since I really want to add a code snippet irrelevant of the actual code then someone could offer assistance regardless.
Anyway, here is the code.
Code: Select all
#NoEnv
#SingleInstance force
#Persistent
; Version 3.1
; Grab active window
WinGetActiveTitle, activeWinTitle
; Create popup-window
Gui, +AlwaysOnTop
Gui, Add, Text, x18 y7 w200 h20, ID:
Gui, Add, Edit, vID x18 y30 w190 h20
Gui, Add, Button, x20 y630 w90 h30 gCopy, Copy
Gui, Show, w590 h690,
; size of main window
MainWinWidth := 320
MainWinHeight := 580
; Create popup for Draft window besides main window.
Gui, +AlwaysOnTop
Gui, Add, Edit, x%MainWinWidth%+10 y32 x260 w%MainWinWidth% h%MainWinHeight%,
return
; Function that runs when the button "Copy" is pressed
Copy:
Gui, Submit, NoHide
Clipboard =
(
ID:
%ID%
)
; show confirmation popup
MsgBox, 64, Copied, Copy successful!
return
; Function to be executed when the GUI window is closed
GuiClose:
ExitApp
return
Re: I want to move the pop-up window to the right bottom of the corner
This should do the trick...
Code: Select all
#NoEnv
#SingleInstance force
#Persistent
; Version 3.1
; Grab active window
WinGetActiveTitle, activeWinTitle
; Create popup-window
Gui, +AlwaysOnTop
Gui, Add, Text, x18 y7 w200 h20, ID:
Gui, Add, Edit, vID x18 y30 w190 h20
Gui, Add, Button, x20 y630 w90 h30 gCopy, Copy
Gui, Show, w590 h690,
; ----------------------------------
WinGetPos X, Y, Width, Height, A
MaxX := A_ScreenWidth - Width - 10 ; This will put the Gui to the right of the monitor...adjust the "10" value as needed.
MaxY := A_ScreenHeight - Height - 45 ; This will put the Gui above the taskbar...adjust the "45" value as needed.
WinMove A, ,%MaxX%, %MaxY%
; ----------------------------------
; size of main window
MainWinWidth := 320
MainWinHeight := 580
; Create popup for Draft window besides main window.
Gui, +AlwaysOnTop
Gui, Add, Edit, x%MainWinWidth%+10 y32 x260 w%MainWinWidth% h%MainWinHeight%,
return
; Function that runs when the button "Copy" is pressed
Copy:
Gui, Submit, NoHide
Clipboard =
(
ID:
%ID%
)
; show confirmation popup
MsgBox, 64, Copied, Copy successful!
return
; Function to be executed when the GUI window is closed
GuiClose:
ExitApp
return
-
- Posts: 10
- Joined: 21 May 2023, 07:43
Re: I want to move the pop-up window to the right bottom of the corner
Thank you! This worked beautifully!
I do wonder though if one can avoid/get rid of the visual effect of the window being moved from center to the right bottom corner? It's like a very quick flash that shows up on screen. I just want it to open in that position like it naturally opens there.
One other thing, I don't have my three screens setup right now to try this on, but on which of the three screens' bottom right corner will this appear on? If it's just random, can this also be adjusted in the code to choose which screen order this appears on?
Again, really appreciate your efforts!
I do wonder though if one can avoid/get rid of the visual effect of the window being moved from center to the right bottom corner? It's like a very quick flash that shows up on screen. I just want it to open in that position like it naturally opens there.
One other thing, I don't have my three screens setup right now to try this on, but on which of the three screens' bottom right corner will this appear on? If it's just random, can this also be adjusted in the code to choose which screen order this appears on?
Again, really appreciate your efforts!
RDC wrote: ↑21 May 2023, 12:00This should do the trick...
Code: Select all
; ---------------------------------- WinGetPos X, Y, Width, Height, A MaxX := A_ScreenWidth - Width - 10 ; This will put the Gui to the right of the monitor...adjust the "10" value as needed. MaxY := A_ScreenHeight - Height - 45 ; This will put the Gui above the taskbar...adjust the "45" value as needed. WinMove A, ,%MaxX%, %MaxY% ; ----------------------------------
Re: I want to move the pop-up window to the right bottom of the corner
The Gui Hide option fixes that. Then just have the Gui Show after the positioning.I do wonder though if one can avoid/get rid of the visual effect of the window being moved from center to the right bottom corner? It's like a very quick flash that shows up on screen. I just want it to open in that position like it naturally opens there.
Code: Select all
Gui, Show, Hide
; ----------------------------------
WinGetPos X, Y, Width, Height, A
MaxX := A_ScreenWidth - Width - 10 ; This will put the Gui to the right of the monitor...adjust the "10" value as needed.
MaxY := A_ScreenHeight - Height - 45 ; This will put the Gui above the taskbar...adjust the "45" value as needed.
WinMove A, ,%MaxX%, %MaxY%
; ----------------------------------
Gui, Show, w590 h690,
This only works on the primary monitor. But there is a post further down about gui positions that may help.One other thing, I don't have my three screens setup right now to try this on, but on which of the three screens' bottom right corner will this appear on? If it's just random, can this also be adjusted in the code to choose which screen order this appears on?
-
- Posts: 10
- Joined: 21 May 2023, 07:43
Re: I want to move the pop-up window to the right bottom of the corner
Sadly, this new add of "Gui, Show, Hide" didn't work well. It annulled the move to the right bottom corner and opens instead in the center like originally.
Code: Select all
Gui, Show, Hide
WinGetPos X, Y, Width, Height, A
MaxX := A_ScreenWidth - Width - 10 ; This will put the Gui to the right of the monitor...adjust the "10" value as needed.
MaxY := A_ScreenHeight - Height - 45 ; This will put the Gui above the taskbar...adjust the "45" value as needed.
WinMove A, ,%MaxX%, %MaxY%
Gui, Show, w590 h690,
-
- Posts: 10
- Joined: 21 May 2023, 07:43
Re: I want to move the pop-up window to the right bottom of the corner
Sadly this code didn't work. What happens when I run the script with this updated code is that the folder I open the file from moves its position to the right bottom corner, not the actual file I've coded (that one just opens in the center of the screen as before).
So Gui, Show, Hide undoes your first successful code snippet.
And yes, I did move Gui, Show to after the positioning.
[Mod edit: Fixed quote tags so some of the reply text is no longer inside a quoted post.]
So Gui, Show, Hide undoes your first successful code snippet.
And yes, I did move Gui, Show to after the positioning.
RDC wrote: ↑24 May 2023, 14:43The Gui Hide option fixes that. Then just have the Gui Show after the positioning.
Code: Select all
Gui, Show, Hide ; ---------------------------------- WinGetPos X, Y, Width, Height, A MaxX := A_ScreenWidth - Width - 10 ; This will put the Gui to the right of the monitor...adjust the "10" value as needed. MaxY := A_ScreenHeight - Height - 45 ; This will put the Gui above the taskbar...adjust the "45" value as needed. WinMove A, ,%MaxX%, %MaxY% ; ---------------------------------- Gui, Show, w590 h690,
Where?
[Mod edit: Fixed quote tags so some of the reply text is no longer inside a quoted post.]
Re: I want to move the pop-up window to the right bottom of the corner
Just use the search bar for "positions"...
There are many posts on this and most appear to apply to Guis.
search.php?keywords=positions&fid%5B0%5D=76
There are many posts on this and most appear to apply to Guis.
search.php?keywords=positions&fid%5B0%5D=76