Jump to content

Catch the return key with GUIRegisterMsg


water
 Share

Recommended Posts

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

Hi rasim,

works great - thanks a lot!

Thomas

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi rasim,

works great - thanks a lot!

Thomas

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...