Jump to content
nacerbaaziz

question about listBox double click items

Recommended Posts

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.

#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

 

Share this post


Link to post
Share on other sites
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 :

#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 !

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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 ? :)

 

Share this post


Link to post
Share on other sites
Posted (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 by pixelsearch

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
Posted (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()

#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 by pixelsearch

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By TheAutomator
      I'm working on a script that needs to work with a huge database inside a combobox.
      I'm looking for the best way to link a multidimensional array to that data to load that data on to textfields.

      example:
      combo item 0 = "A", data = [index linked to combo item 0] [1,0,5,4,87,9,"xyz"]
      combo item 1 = "B", data = [index linked to combo item 1] [1,6,5,4,87,9,"zzz"]
      combo item 3 = "A", data = [index linked to combo item 3] [1,6,4,4,87,9,"aaa"] ; yes also double items!
      Would also like to be able to delete and add items on the fly btw..
      Local $INDEX[0][10] ; ubound wil be resized like a stack while loading from a textfile ;inside gui: local $Combo = GUICtrlCreateCombo('...', 10, 10, 290, 25) ;gui loop: While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Combo display() ; how do i link my array index to the combo labels to know what to show in the textfields? ; NOTE: (there are duplicate items in the combobox!) EndSwitch WEnd Any toughs are welcome.
      I was thinking about using _GUICtrlComboBox_GetCurSel($Combo) and use that integer to refer to the index (dimension 1) of the array 
      Thanks, TheAutomator
       
    • By _leo_
      Hey there!
      I am having a problem with clicking a button in IE. As you can see in the code, there would be a class name to click it, but since this button exists several times with exactly the same code, I can only use the "Noch nicht veröffentlicht" to separate it from the others. But this part is just pure text without any classification. 
      "<div class="checkmark" data-v-1e5b1f70=""><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 16 16" data-v-1e5b1f70=""><circle cx="8" cy="8" r="8" data-v-1e5b1f70="" /></svg></div>Noch nicht veröffentlicht"
      I was trying to click it with:
      #include <IE.au3> local $oNNVs = _IEFormGetCollection($oIE2) For $oNNV in $oNNVs If String($oNNV.innertext) = "Noch nicht veröffentlicht" Then _IEAction($oNNV, "click") EndIf Next and:
      $inputs = $oIE2.document.getElementsByTagName("div") For $input In $inputs If $input.innertext == "Noch nicht veröffentlicht" then $input.click() EndIf Next But nothing seems to work. Thanks for the help!
    • By XinYoung
      Greetings!
      I am in need of your guidance once again. I searched the forums for clicking in span, clicking by class, clicking without an ID or Name, etc., but I am unable to find a solution for my problem.
      I am trying to expand this tree in IE. There is an arrow ( > ) that i need to click, but I can't find a way to do it . Alternatively, I can double-click the text "Servers", but that seems to be even more troublesome. I will have to do this 2-3 more times as the tree expands.
      There appears to be an ID for the tree, simply called "tree", but that isn't working when I send a click to it.

      ;Open an IE session and navigate to pgAdmin. Global $oIE = _IECreate($pgAdmin) ;Maximize the IE window. WinSetState(_IEPropertyGet($oIE, "hwnd"), "", @SW_MAXIMIZE) Sleep(2000) ;Expand the tree $oTree = _IEGetObjById($oIE, "tree") _IEAction($oTree, "click") Any ideas?  
    • By Jeep
      Here is a small library (UDF) that I use all the time. Not transcendent, it’s just to simplify my life.
      When I use the ConsoleWrite function, more than 99.99 percent, I go to the line (Newline), more than 99.99 %, parameters à the same except information that i exam. _CW is born.
      The second one _CW_Fmt allows to display marks (Fmt for Formatting) and allows to evaluate the format the length of a variable and the position of some characters without counting too much :-).
      For the functions derived from MsgBox () again the same observation, always the same parameters following the context: Info, Error or Warning. Thus were born _MB_Info, _MB_Error and _MB_Warning.
      As for _MB_IsOk, the same observation about the logical answer we are interested in a question with two choices: agree or disagree and not much else (True or False).
      All your remarks, suggestions and constructive criticism are welcome.
      JPD_Simply.au3
      JPD_Simply_Demo.au3
    • By XinYoung
      Quick question: How can I click this "Select All" button in IE? There's no ID, and the href is "#"  
      Am I looking at the wrong html code?
      Am I looking
      Thank you all in advance!
×
×
  • Create New...