nacerbaaziz Posted July 26, 2019 Posted July 26, 2019 good morning all. first lit me give you all a thinks to your help you're help me allot thank you all. sirs today i've a new problem it's not a problem but thing i want to add it to blind accessability. the ListBox can send a notification when the user send a double click on it items but as we know that the blind users can't use the mouse for that they use the keybord to navigate. as we know that the enter replace the double click on the keybord for that i need when the user send a inter above any listBox item the list send a double click notification. i know some of you tell me that i can use the GUISetAccelerators function but the enter has a other tasks such as leav a blanc line on edits and activate the defaultButton and other tasks. that what i need and i hope that you can help me this is a simple example. expandcollapse popup#include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <ListBoxConstants.au3> Example() Func Example() Local $sMESSAGE = "The following buttons have been clicked" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) global $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $sMESSAGE) global $DummyList = GUICtrlCreateDummy() GUICtrlSendToDummy($DummyList, 1) Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUIRegisterMsg($WM_command, "WM_command") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton_Add GUICtrlSetData($idMylist, "You clicked button No1|") Case $idButton_Clear GUICtrlSetData($idMylist, "") Case $idButton_Close MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit case $DummyList $g_iTemp = GUICtrlRead($DummyList) if $g_iTemp = $LBN_DBLCLK then ;$LBN_DBLCLK then msgBox(64, "", "") endIf GUICtrlSendToDummy($DummyList, 0) EndSwitch WEnd EndFunc ;==>Example Func WM_command($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = $lParam $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case GUICtrlGetHandle($idMylist) Switch $iCode Case $LBN_SELCHANGE, $LBN_DBLCLK, $LBN_SELCANCEL, $LBN_SETFOCUS GUICtrlSendToDummy($DummyList, $iCode) case else ;GUICtrlSendToDummy($DummyTreeview, 1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
nacerbaaziz Posted July 26, 2019 Author Posted July 26, 2019 I'm afraid there's no solution to this. Waiting for your responses, you wonderful people.
pixelsearch Posted July 27, 2019 Posted July 27, 2019 8 hours ago, nacerbaaziz said: I'm afraid there's no solution to this. There are many solutions to this... if you take time and google on Listbox, Enter, Double click etc... Then you'll find answers and examples from Melba23, Valuater, Mikell (to name the few) You'll have to study them and create simple examples to see how they work, adapt them to your "links store" listbox, all this requires time and patience. Based on the GUICtrlCreateList() help file example, I just tried a personal way, using HotKeySet to manage the Enter key and see where it would lead. It seems to give good results but it needs to be tested more : expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <MsgBoxConstants.au3> HotKeySet("{ENTER}", "_Enter") Global $idMylist, $hMylist Example() Func Example() Local $sMESSAGE = "The following buttons have been clicked" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) $hMylist = GUICtrlGetHandle($idMylist) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $sMESSAGE) Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton_Add GUICtrlSetData($idMylist, "You clicked button No1|") Case $idButton_Clear GUICtrlSetData($idMylist, "") Case $idButton_Close MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit EndSwitch WEnd EndFunc ; ==>Example Func _Enter() HotKeySet("{ENTER}") ; deactivate Hotkey Local $hFocus = _WinAPI_GetFocus() MsgBox($MB_TOPMOST, "Handle List Control = " & $hMylist, _ "Handle 'window' focused on = " & $hFocus) If $hFocus = $hMylist Then MsgBox($MB_TOPMOST, "ListBox got focus", _ "Current selection : line " & _GUICtrlListBox_GetCurSel($idMylist)) Else Send("{ENTER}") EndIf HotKeySet("{ENTER}", "_Enter") ; reactivate Hotkey EndFunc ; ==>_Enter 1st msgbox showing the 2 handles is there just for info and should be commented out in the final script. What's interesting is the 2nd msgbox indicating the line of the listbox that got focus (that should help you to launch your associated url). And when this 2nd msgbox indicates -1 , it means that the listbox is empty Concerning the double-click on a line of the listbox, you could use WM_COMMAND or WM_NOTIFY to manage it, exiting the GUIRegisterMsg() function as quick as possible (Melba23's recommandation in Wiki) using a flag or a dummy control. There too, you'll be able to know what line of the listbox was double-clicked on etc... Valuater proposed an "_Ispressed" approach during the While... Wend loop to check if the Enter Key was pressed while focus was on the listbox, so it's another approach which you could use. Good luck ! "I think you are searching a bug where there is no bug... don't listen to bad advice."
nacerbaaziz Posted July 27, 2019 Author Posted July 27, 2019 thank you very much sir @pixelsearch but here the same problem the other enter tasks will be disable that my problem
nacerbaaziz Posted July 27, 2019 Author Posted July 27, 2019 when i searched on web i found some examples about double click on listBox, but the enter didn't work on list View i used the LV_KeyDown to get the notification and is_Pressed to get the pressed enter but on listBox their is no keyDown notification
pixelsearch Posted July 27, 2019 Posted July 27, 2019 1 hour ago, nacerbaaziz said: the other enter tasks will be disable Why will the other Enter tasks disable ? Just comment out the 1st MsgBox as I explained in the precedent message, because it was here for debug : ; MsgBox($MB_TOPMOST, "Handle List Control = " & $hMylist, _ ; "Handle 'window' focused on = " & $hFocus) After that, you will be able to key Enter wherever you like, in any Window outside "My Gui list" and on any button ("Add", "Clear", "my close button") in the window "My Gui list" As you see in the function _Enter, there is a Send("{ENTER}") each time you key Enter when the focus is not on the listbox of the GUI. Just comment out the 1st message box and try, ok ? By the way, I am writing this message while the GUI is opened and I key a lot of Enter's, see how it works ? "I think you are searching a bug where there is no bug... don't listen to bad advice."
nacerbaaziz Posted July 27, 2019 Author Posted July 27, 2019 their isn't any thing in listBox similar to lVN_KEYDOWN on ListView?
pixelsearch Posted July 27, 2019 Posted July 27, 2019 (edited) I don't know about that, but why not using a ListView control instead of the List control It seems much more complete for what you want to do... especially if you're used to LVN_KEYDOWN Please answer my precedent question : after you comment out the 1st MsgBox, all your Enters are enabled anywhere, right ? Edited July 27, 2019 by pixelsearch "I think you are searching a bug where there is no bug... don't listen to bad advice."
nacerbaaziz Posted July 27, 2019 Author Posted July 27, 2019 i have an other question if not exist i'll use the list View can remove the WS_TabStop from the button i want the button when the user press tab in keyBord the button isn't focus but it stay show on screen can we do that? i want to do that because the button has 0x01 style that set it defaultButton if i do that the blind users can't find the link using the keybord but when press enter on the list the link will open
pixelsearch Posted July 27, 2019 Posted July 27, 2019 (edited) If you want to remove the forced style $WS_TABSTOP from a Button control (so it wont be tabbable when the user tabs through the controls) then you have to do this : 1) Retrieve all styles of the control with _WinAPI_GetWindowLong() 2) Remove the style you don't want with _WinAPI_SetWindowLong() expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> HotKeySet("{ENTER}", "_Enter") Global $idMylist, $hMylist Example() Func Example() GUICreate("My GUI list") Local $idButton_Add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $idButton_Clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idButton_Close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $hButton_Close = GUICtrlGetHandle($idButton_Close) Local $iStyle_Button_Close = _WinAPI_GetWindowLong($hButton_Close, $GWL_STYLE) If BitAND($iStyle_Button_Close, $WS_TABSTOP) = $WS_TABSTOP Then _WinAPI_SetWindowLong($hButton_Close, $GWL_STYLE, BitXOR($iStyle_Button_Close, $WS_TABSTOP)) Endif $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) $hMylist = GUICtrlGetHandle($idMylist) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, "The following buttons have been clicked") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton_Add GUICtrlSetData($idMylist, "You clicked button No1|") Case $idButton_Clear GUICtrlSetData($idMylist, "") Case $idButton_Close MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit EndSwitch WEnd EndFunc ; ==>Example Func _Enter() HotKeySet("{ENTER}") ; deactivate Hotkey Local $hFocus = _WinAPI_GetFocus() ;MsgBox($MB_TOPMOST, "Handle List Control = " & $hMylist, _ ; "Handle 'window' focused on = " & $hFocus) If $hFocus = $hMylist Then MsgBox($MB_TOPMOST, "ListBox got focus", _ "Current selection : line " & _GUICtrlListBox_GetCurSel($idMylist)) Else Send("{ENTER}") ; >>>>> Keyboard Enter when ListBox hasn't got focus <<<<< EndIf HotKeySet("{ENTER}", "_Enter") ; reactivate Hotkey EndFunc ; ==>_Enter In this script, when you use the Tab key, it won't reach the "my closing button" because the button doesn't have anymore the $WS_TABSTOP style. You can do same for all other buttons if needed. Ok, I have to go now. Hope it will help you and have a great evening Edited July 27, 2019 by pixelsearch "I think you are searching a bug where there is no bug... don't listen to bad advice."
nacerbaaziz Posted July 27, 2019 Author Posted July 27, 2019 sir @pixelsearch that what i need thank you very much to your help accept my greetings please
TheRRDon Posted August 18, 2019 Posted August 18, 2019 I am very new to AutoIT, and was looking for a good "Double Click" snippet. I ran across this. It proved to be easy to read and understand, with extensive explanation. It looks like it may be exactly what you are asking for. Script Function: Testing way to detect left double click in a ListView in x86 & x64. Also testing way to detect [Enter] key pressed in x86 and x64 mode.
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