Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more GUI window control #18

Open
Avastgard opened this issue Nov 19, 2024 · 1 comment
Open

Allow more GUI window control #18

Avastgard opened this issue Nov 19, 2024 · 1 comment

Comments

@Avastgard
Copy link

Is it possible to make the gui window more interactive, like allowing us to move and resize it? Sometimes I'd like to keep the window open while checking other apps, but it's always stuck in the middle of the screen unable to be moved. I end up having to open notepad and pasting the output, which is bothersome.

Thanks in advance.

@wadid
Copy link

wadid commented Nov 24, 2024

@Avastgard

I am just trying to change the same. Have no experience with AHK. Especially the v2 syntax is difficult to learn as it seems ChatGPT cannot change AHKv2 Code properly. I am trying now with Claude Sonnet 3.5, which seems to give better answers.

To get a small title bar on the top of window change all occurences of -Caption to +Caption. Then you can move it I think.

Also add resize. Like this: Response_Window := Gui("+Caption +Resize", "Response")
Now you can resize the window, but the contents will not resize.

Claude said you need to add an event handler that will will resize the contents... Still trying to figure that out. It said to add after Response_Window.Add("Button", "x+30", "Close").OnEvent("Click", Close) the following:

; Register event handler for window resizing
; This allows the window to respond when user changes its size
Response_Window.OnEvent("Size", GuiResize)

; Function that handles window resizing events
; Parameters:
; - thisGui: reference to the GUI being resized
; - MinMax: window state (minimized/maximized)
; - Width: new width of window
; - Height: new height of window
GuiResize(thisGui, MinMax, Width, Height) {
    if WebView {  ; Check if WebView object exists
        try {
            ; Get reference to the text control containing WebView
            ; "Text1" is the automatic name given to first text control
            control := thisGui["Text1"]
            
            ; Resize the control to match new window size
            ; Width-40 and Height-80 provide margins around the content
            ; Empty parameters (,,) skip x,y positioning
            control.Move(,, Width-40, Height-80)
        }
    }
}

But not sure if that works, still need to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants