AltSubmit for ListView will break onExit() function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

AltSubmit for ListView will break onExit() function

29 Jan 2019, 04:06

I have a ListView that I want to respond to when the user selects a different item/row.
Help (G-Label Notifications (Secondary)) tells me to use AltSubmit and go looking for A_GuiEvent = "I".
So I did and it works: I can respond to user selection in my script.

Problem: using AltSubmit breaks the OnExit("ExitFunc") behaviour.

Here is a the left-overs of my original script to illustrate the bare core problem:
as soon as I include the AltSubmit option, I no longer get a MsgBox from ExitFunc
I tested for MsgBoxes by clicking the [x]-button in title of the window.

Code: Select all

; Expected Behaviour: Script will execute the ExitFunc when exiting.

    ; AltSubmit will break expected behaviour :(
    ; tested by clicking [x]-button in title




#NoEnv
#SingleInstance Force

    Gui, Add, ListView, gLV_onChange ;AltSubmit
    Gui, Add, Button, wp, Reload
    Gui, Add, Button, wp, Exit
    Gui, Show

    OnExit("ExitFunc")

return ; end of auto-execute section

GuiClose: ; click [x]-button in title
    ExitApp
return

LV_onChange:
return

ButtonReload:
    Reload
return

ButtonExit:
    ExitApp
return



;-------------------------------------------------------------------------------
ExitFunc() { ; ExitFunc
;-------------------------------------------------------------------------------
    Gui, +LastFound
    WinGetPos, WinX
    MsgBox,, ExitFunc, %WinX%, 1
}
This took me longer to figure out than I would ever admit, so please bear with me ...

I hope to have made clear what I did and what I want. Here it is again:
  • I want to reliably write Window position on each and every exit of the script. I do not want to loose onExit function.
  • I want to use AltSubmit for my Listview.
I can have either, no problem, but can I have both in the same script?

Does anyone have a suggestion as how to achieve my goal (respond in script to item changes) while keeping the function onExit functional :?:
Thanks for reading. :)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: AltSubmit for ListView will break onExit() function

29 Jan 2019, 04:23

u can have the MsgBox and no AltSubmit or no MsgBox and AltSubmit
something about the interaction between these two bugs it, infinite loop, 100% cpu
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AltSubmit for ListView will break onExit() function

29 Jan 2019, 04:27

Thanks, I noticed some "Lag" where I expected msgbox too. Bug confirmed?
Waiting for more responses before reporting the bug.
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AltSubmit for ListView will break onExit() function  Topic is solved

29 Jan 2019, 05:42

Here on Win 10 the MsgBox is not shown but the timeout of 1 second is processed.

Workaround:

Code: Select all

; Expected Behaviour: Script will execute the ExitFunc when exiting.

    ; AltSubmit will break expected behaviour :(
    ; tested by clicking [x]-button in title




#NoEnv
#SingleInstance Force

    Gui, Add, ListView, vLV gLV_onChange AltSubmit ; <<<<<
    Gui, Add, Button, wp, Reload
    Gui, Add, Button, wp, Exit
    Gui, Show

    OnExit("ExitFunc")

return ; end of auto-execute section

GuiClose: ; click [x]-button in title
    ExitApp
return

LV_onChange:
return

ButtonReload:
    Reload
return

ButtonExit:
    ExitApp
return



;-------------------------------------------------------------------------------
ExitFunc() { ; ExitFunc
;-------------------------------------------------------------------------------
    Gui, +LastFound
    GuiControl, -g, LV ; <<<<<
    WinGetPos, WinX
    MsgBox,, ExitFunc, %WinX%, 1
}
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AltSubmit for ListView will break onExit() function

29 Jan 2019, 08:46

@just me: Thanks for the workaround! That's just brilliant. :bravo:
I applied and found no problems with it. Would you agree there is a problem worth reporting?
I personally settle for "seems to work" but wish for a "robust solution".
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: AltSubmit for ListView will break onExit() function

30 Jan 2019, 05:52

Hi wolf_II,

I'm not sure whether it is 'worth reporting'. AHK has some problems with ListViews and TreeViews. They send lots of notifications to the parent window and activate own message loops under certain circumstances. Some of the issues cannot be solved without massive changes in the message processing of AHK.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: AltSubmit for ListView will break onExit() function

30 Jan 2019, 08:45

fine, but then figure out whats causing it and document it at least

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 250 guests