supersonic Posted July 26, 2018 Share Posted July 26, 2018 (edited) Hi - I need to trigger up/down in a ListView. My script does well in 32 bit, but compiling the script to 64 bit $LVN_KEYDOWN/$tagNMLVKEYDOWN doesn't work: "VKey" always returns 0. Here's a reproducer I've found ( https://www.autoitscript.com/forum/topic/165452-using-updown-in-listview/ ): expandcollapse popupAutoIt3Wrapper_UseX64=Y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> Global $bChanged = False $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Column 1", 10, 10, 200, 200) $hLV = GUICtrlGetHandle($cLV) For $i = 0 To 19 GUICtrlCreateListViewItem("Item " & $i, $cLV) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If $bChanged Then $j = _GUICtrlListView_GetSelectedIndices($hLV) ConsoleWrite($j & @CRLF) $bChanged = False EndIf WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hLV $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_KEYDOWN $tStruct = DllStructCreate($tagNMLVKEYDOWN, $lParam) $iKey = DllStructGetData($tStruct, "VKey") Switch $iKey Case 38, 40 ; Up, Down $bChanged = True EndSwitch Case $NM_CLICK $bChanged = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Any chance to work around this issue? Edited July 26, 2018 by supersonic Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 26, 2018 Share Posted July 26, 2018 @supersonic What is not working as you're expecting? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
supersonic Posted July 26, 2018 Author Share Posted July 26, 2018 If run in 64 bit up/down (in Listview) is not recognized. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 26, 2018 Share Posted July 26, 2018 (edited) https://www.autoitscript.com/trac/autoit/ticket/1130 It is fixed, but I don't know what do they fix... Edited July 26, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
supersonic Posted July 26, 2018 Author Share Posted July 26, 2018 (edited) Thank you - In AutoIt V3.3.14.5 executing 'ConsoleWrite($tagNMLVKEYDOWN)' returns as follows: 32 bit - [align 1;struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;word VKey;uint Flags] 64 bit - [align 1;struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;word VKey;uint Flags] So, is it still a bug? Is it worth to open another ticket? Edited July 26, 2018 by supersonic Link to comment Share on other sites More sharing options...
LarsJ Posted July 26, 2018 Share Posted July 26, 2018 Add this to top of _WM_NOTIFY function and it should work: Local Const $tagNMLVKEYDOWN = $tagNMHDR & ";word VKey;uint Flags" FrancescoDiMuro, JoeBar and pixelsearch 3 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
supersonic Posted July 26, 2018 Author Share Posted July 26, 2018 @LarsJ Thank you - that did the trick! Is it worth a ticket? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2018 Moderators Share Posted July 26, 2018 supersonic, Yes. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
supersonic Posted July 31, 2018 Author Share Posted July 31, 2018 (edited) Melba23, I left a comment at https://www.autoitscript.com/trac/autoit/ticket/1130 to be re-opened - or better create a new ticket? Edited July 31, 2018 by supersonic Link to comment Share on other sites More sharing options...
JoeBar Posted December 2, 2019 Share Posted December 2, 2019 (edited) On 7/26/2018 at 1:56 PM, LarsJ said: Add this to top of _WM_NOTIFY function and it should work: Local Const $tagNMLVKEYDOWN = $tagNMHDR & ";word VKey;uint Flags" I struggled for hours before reading your post for my $LVN_KEYDOWN interception. Thanks !! How have this not been solved until now ? All the examples related in this forum don't work cause this. And this too for example : _GUICtrlListView_GetHotItem : when pressing keys, vKey stays at 0 and it's the Flag which points to an adress. Can a mod explain me ? Thanks 😊 Edited December 2, 2019 by JoeBar Link to comment Share on other sites More sharing options...
Nine Posted December 3, 2019 Share Posted December 3, 2019 On 12/2/2019 at 4:20 PM, JoeBar said: I struggled for hours before reading your post for my $LVN_KEYDOWN interception. Thanks !! Well I invested many hours to understand the issue. And I must tell it is not an obvious solution. Larsj solution works but it is not perfect. MSDN says that flags in the structure should be 0. But in reality it is not the case, it changes at every key stroke (but I am still looking for the meaning of the flags). So removing the align 1 (like Larsj proposed) will work till you want to use flags. So if we really want to respect the real struct of the message it should be : $tagNMLVKEYDOWN = "align 2;" & $tagNMHDR & ";" & (@AutoItX64 ? "uint;" : "") & "word VKey;uint Flags" “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted December 8, 2019 Share Posted December 8, 2019 (edited) Ok, so today I faced the same issue as Supersonic and JoeBar described above. * A script using $tagNMLVKEYDOWN had no issue when run under AutoIt.exe on a Windows 32bits computer * Today, for the 1st time, I did run the script on a "OS:WIN_8/ CPU:X64 OS:X64" computer, the console showing that Autoit3_x64.exe was running the script. $VK_RIGHT, $VK_LEFT, nothing happened when you pressed the right or left key in the listview : it's like both keys were dead ! * Here is a list of different $tagNMLVKEYDOWN strings, found here and there : 1) Official release AutoIt 3.3.14.5 - Include file StructureConstants.au3 (file dated 15 march 2018) Global Const $tagNMLVKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags" 2) LarsJ proposal (above) at top of _WM_NOTIFY function : Local Const $tagNMLVKEYDOWN = $tagNMHDR & ";word VKey;uint Flags" 3) Nine proposal (above) $tagNMLVKEYDOWN = "align 2;" & $tagNMHDR & ";" & (@AutoItX64 ? "uint;" : "") & "word VKey;uint Flags" 4) Beta release 3.3.15.1-1 found here - Include file StructureConstants.au3 (file dated 04 april 2018) Global Const $tagNMLVKEYDOWN = $tagNMHDR & ";align 2;word VKey;uint Flags" jpm wrote this at the end of the corresponding track ticket #1130, found there : "It has been fixed for the next Beta on my birthday ..." which is April 4th (as openly indicated in his profile) and that's the same date of StructureConstants.au3 in the Beta release, well done jpm Structures #2 #3 #4 work fine on x64 (tested them all today) but for now I'll stick to jpm's structure #4 as it should be found in the include file of the next official release... if no further change happens. Also structure #4 seems ok on 32 bits computers (just tested) So if any of you share on the Forum a script running fine on your x86 computer, where $tagNMLVKEYDOWN is found, please don't forget to add the amended structure of $tagNMLVKEYDOWN to make it compatible with x64 computers running your script, for example : Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ... Case $LVN_KEYDOWN Local Static $tagNMLVKEYDOWN = $tagNMHDR & ";align 2;word VKey;uint Flags" ... = DllStructCreate($tagNMLVKEYDOWN, $lParam) I hope Static is correct in this case, so $tagNMLVKEYDOWN won't need to be re-declared each time WM_NOTIFY() is called. It seems even better to follow LarsJ's advice and place it at the very top of WM_NOTIFY() in case keypress notifications need to be checked at several places within WM_NOTIFY() Please note that in the Beta file, changes done to $tagNMLVKEYDOWN have also been applied to $tagNMTCKEYDOWN and $tagNMTVKEYDOWN Edited December 9, 2019 by pixelsearch JoeBar 1 Link to comment Share on other sites More sharing options...
Nine Posted January 4, 2020 Share Posted January 4, 2020 The right way : $tagNMLVKEYDOWN = $tagNMHDR & ";word VKey;align 2;uint Flags" “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
supersonic Posted July 12, 2023 Author Share Posted July 12, 2023 (edited) Sorry to post again in this old thread, but I needed the mentioned structure again. This time for a TreeView - and - because I used AutoIt 3.3.14.5 - ran into the same error AGAIN. 😉 I followed the thread to the end and have to note for AutoIt 3.3.16.1 that for '$tagNMLVKEYDOWN' or '$tagNMTVKEYDOWN' the following is defined: Global Const $tagNMLVKEYDOWN = $tagNMHDR & ";align 2;word VKey;uint Flags" Global Const $tagNMTVKEYDOWN = $tagNMHDR & ";align 2;word VKey;uint Flags" Is this finally correct after all? Or is: $tagNMHDR & ";word VKey;align 2;uint Flags" "more correct"? And if yes: Why resp. where can this be understood (e.g. MSDN)? Edited July 12, 2023 by supersonic Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 This code works fine on 3.3.16.1 and some alignment is done automatically. #AutoIt3Wrapper_UseX64=y Global $hMain, $hTree Global Const $tagNMHDR = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct" $hMain = GUICreate('TreeView', 400, 400) $hTree = GUICtrlCreateTreeView(10, 10, 380, 380) GUISetState(@SW_SHOW, $hMain) GUIRegisterMsg(0x004E, 'WM_NOTIFY') Do Until GUIGetMsg() = -3 Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If HWnd($tNMHDR.hWndFrom) = GUICtrlGetHandle($hTree) And $tNMHDR.Code = 0xFFFFFE64 Then ; TVN_KEYDOWN Local $tTVKEYDOWN = DllStructCreate($tagNMHDR & ';word wVKey;uint Flags;', $lParam) ConsoleWrite(DllStructGetSize($tTVKEYDOWN) & @TAB & $tTVKEYDOWN.wVKey & @CRLF) EndIf Return 'GUI_RUNDEFMSG' EndFunc If 3.3.14.5 doesn't do any alignments, probably it should be something like that; $tagNMHDR & ';align 4;word wVKey;align 2;uint Flags;' Anyway, I am not sure why StructureConstants.au3 define idFrom in NMHDR as uint_ptr when MSDN says clearly that it's a simple unsigned integer. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
pixelsearch Posted July 12, 2023 Share Posted July 12, 2023 @Andreik could you please indicate the link where MSDN says that idFrom in NMHDR is a simple unsigned integer ? Because here is what I just read on MSDN, article NMHDR structure typedef struct tagNMHDR { HWND hwndFrom; UINT_PTR idFrom; UINT code; } NMHDR; Link to comment Share on other sites More sharing options...
TheXman Posted July 12, 2023 Share Posted July 12, 2023 Here is one such reference: https://learn.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-nmhdr It is the page you are sent to when clicking on the NMHDR link, in the MEMBERS section, of the following page: https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlvkeydown CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
pixelsearch Posted July 12, 2023 Share Posted July 12, 2023 (edited) Thanks @TheXman Some infos concerning this MSDN discrepancy just found in this link, titled NMHDR definition conflict? Edit: another link related to this issue. Edited July 12, 2023 by pixelsearch Link to comment Share on other sites More sharing options...
Andreik Posted July 12, 2023 Share Posted July 12, 2023 (edited) 1 hour ago, pixelsearch said: @Andreik could you please indicate the link where MSDN says that idFrom in NMHDR is a simple unsigned integer ? Because here is what I just read on MSDN, article NMHDR structure typedef struct tagNMHDR { HWND hwndFrom; UINT_PTR idFrom; UINT code; } NMHDR; TheXman already answered this and I think it's pretty clear that a control identifier it's an integer. Looking at some macros in CommCtrl.h I saw that sometimes idFrom might be send to procedures as wparam which it's uint_ptr indeed but in fact could be cast safely as unsigned integer. However, not sure why it has to be that integer dependent on processor word size. Edited July 12, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
supersonic Posted July 13, 2023 Author Share Posted July 13, 2023 I thank you for the feedback, however it is beyond me.... Is there "the" one/correct structure (for 32 and 64 bit)? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now