Sign in to follow this  
Followers 0
water

Catch the return key with GUIRegisterMsg

5 posts in this topic

Hi Gurus,

I use the following code to catch a double klick on a listbox entry. is it possible to use the same method to catch the return key?

Thanks in advance

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndList
    If Not IsHWnd($GUIUserList) Then $hWndList = GUICtrlGetHandle($GUIUserList)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF); Low Word
    $iCode = BitShift($iwParam, 16); Hi Word
    
    Switch $hWndFrom
        Case $GUIUserList, $hWndList
            Switch $iCode
                Case $LBN_DBLCLK; Sent when the user double-clicks a string in a list box
                ; Bringt Inhalt der ausgewählten Zeile "OrgEinheit - Name"
                    $Selected = GUICtrlRead($GUIUserList)
                    _GetGroupList()
                Case $LBN_KILLFOCUS; Sent when a list box loses the keyboard focus
                Case $LBN_SELCHANGE; Sent when the selection in a list box has changed
                    GUICtrlSetData($GUIGroupList,"")
                    GUICtrlSetData($GUIGroupLabel,$sGroupLabel)
                    If Not $IB And Not $SingleUser Then 
                        GUICtrlSetData($GUIGroupUserList,"")
                        GUICtrlSetData($GUIGroupUserLabel,$sGroupUserLabel)
                    EndIf
                Case $LBN_SETFOCUS; Sent when a list box receives the keyboard focus
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites



water

Example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 300, 200)

$hListBox = GUICtrlCreateList("", 10, 10, 280, 180)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If $wParam = 1 Then ConsoleWrite("!> Enter is pressed" & @LF)
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

Hi rasim,

works great - thanks a lot!

Thomas


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi rasim,

works great - thanks a lot!

Thomas


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Switch $hWndFrom

Case $GUIUserList, $hWndList

Switch $iCode

Case $LBN_DBLCLK; Sent when the user double-clicks a string in a list box

; Bringt Inhalt der ausgewählten Zeile "OrgEinheit - Name"

$Selected = GUICtrlRead($GUIUserList)

_GetGroupList()

Case $LBN_KILLFOCUS; Sent when a list box loses the keyboard focus

Case $LBN_SELCHANGE; Sent when the selection in a list box has changed

GUICtrlSetData($GUIGroupList,"")

GUICtrlSetData($GUIGroupLabel,$sGroupLabel)

If Not $IB And Not $SingleUser Then

GUICtrlSetData($GUIGroupUserList,"")

GUICtrlSetData($GUIGroupUserLabel,$sGroupUserLabel)

EndIf

Case $LBN_SETFOCUS; Sent when a list box receives the keyboard focus

EndSwitch

EndSwitch

Hi water,

in your select statement , you have "Case $LBN_KILLFOCUS; Sent when a list box loses the keyboard focus", in which you catch the lostFocus event on a list box. My question to you is is that event created by you or does it come with AutoIt API?? And also if possible, would you know of a way to do it with an input box, to catch whenever that input box loses the focus??

Thanks a lot I would really appreciate your help if you can.

the123punch

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
Sign in to follow this  
Followers 0