JasonDavis
JasonDavis

Reputation: 48933

Close a GUI window from button in AutoHotKey GUI window not working

I have the AutoHotKey EnterPad Keyboard/Pad with 120 Programmable Keys

enter image description here

It works by sending a Hotkey press for each key to an AutoHotKey script which has a Label function for each key named 001 through 120

Below is my AHK Label function called when key 115 is pressed.

My code allows me to select rows in any Windows Listview component and it will show a popup GUI window with a textbox filled in with the data from the selected rows with each column separated with a TAB space. I can then copy or save it or view it whatever I like.

;---------------------------------------------------------------------115-----
; Copy Selected Windows Listview Items to Tab Spaced Text - Show popup Window Gui
; https://superuser.com/questions/814831/copy-to-clipboard-from-table-list-in-a-program-on-windows
115:
    Gui, SelectedListRowsTextGui:Destroy
    MouseGetPos, , , , ListView_hwnd, 2     ;2 means return HWND
    ControlGet, selected_row_text, List, Selected, , ahk_id %ListView_hwnd%
    Gui, SelectedListRowsTextGui: +ToolWindow +AlwaysOnTop -Caption
    Gui, SelectedListRowsTextGui:Add, Edit, vUnused_variable x11 y15 w950 h66, %selected_row_text%
    Gui, SelectedListRowsTextGui:Add, Button, x62 y84 w140 h30 +Center, Close
    Gui, SelectedListRowsTextGui:Show, ,
    return

    ButtonClose:
    Gui, SelectedListRowsTextGui:Destroy
    return

Return

Problem

My issue is that once the popup window is opened from my AHK GUI, my CloseButton label dose not get called when I click the close button.

I realize it likely has something to do with it being nested under the key 115s label function. How can I best achieve the desired result?

I tried moving the CloseButton label outside of the 115 label however it still is not called from the GUI's Close button click.

You can see I have named the GUI SelectedListRowsTextGui this is to allow this Enterpad.ahk script to contain many GUI windows for different actions it will perform.


Preview of the GUI window this script creates when listview items are selected and this Label function is called:

enter image description here

Upvotes: 0

Views: 2981

Answers (1)

JasonDavis
JasonDavis

Reputation: 48933

I got it now....

Since my GUI is named SelectedListRowsTextGui I had to add that name in front of my CloseButton label name so it is now SelectedListRowsTextGuiButtonClose and works great

Upvotes: 1

Related Questions