In v1 there were checks that could be used with a GUI ListView to detect a keypress and check the key that was pressed as shown below:
MyListView:
If ((A_GuiEvent="K" AND Chr(A_EventInfo)=" "))
DoSomething()
In the v1 code above, A_EventInfo was used to see if Space was pressed on the ListView (in this example a Space, or more generically, for whatever key is of interest to check for), and this is code is located in the gosub routine setup via the GUI Add statement (e.g., Gui, Add, ListView, ... gMyListView).
Is there recommended replacement code for this in v2?
I couldn't find any v2 events available, either for the ListView control, or for the GUI itself, that would catch this. So I'm wondering if the recommended replacement code would be to use something like a generic hotkey, in conjunction with a check to see if the ListView control is active, focused or was focused (or something similar).
GUI ListView KeyPress Detect in v2 Topic is solved
Re: GUI ListView KeyPress Detect in v2 Topic is solved
https://learn.microsoft.com/en-us/windows/win32/controls/bumper-list-view-control-reference-notifications
Code: Select all
MyGui := Gui()
LV := MyGui.Add("ListView", , ["Column1"])
LV.Add(, 'Row1')
LVN_FIRST := 0 - 100
LVN_KEYDOWN := LVN_FIRST - 55
LV.OnNotify(LVN_KEYDOWN, LV_OnKeyDown)
LV_OnKeyDown(LV, lParam) {
NMHDR_hwndFrom := NumGet(lParam, 0, 'Ptr')
NMHDR_idFrom := NumGet(lParam, A_PtrSize, 'UInt')
NMHDR_code := NumGet(lParam, 2 * A_PtrSize, 'UInt')
LVKEYDOWN_wVKey := NumGet(lParam, 3 * A_PtrSize, 'UShort')
; LVKEYDOWN_flags ; is always 0
ToolTip(GetKeyName(Format('vk{:X}', LVKEYDOWN_wVKey)))
}
MyGui.Show()
-
- Posts: 204
- Joined: 24 Jun 2015, 23:38
Re: GUI ListView KeyPress Detect in v2
This worked great for me, thanks!