Keypress event

  • Hallo Zusammen

    Ich habe ein AutoIt gui kreiert (will also nicht eine Fremdapplikation steuern) und will nun, dass wenn man etwas in eine edit box schreibe, gewisse Controls disabeln.

    Ich habe versucht einen event zu registrieren. Natürlich habe ich auch eine mydisable funktion gebaut.

    Code
    ;Textbox kreieren 
    $myeditfrom = GUICtrlCreateEdit("c035701", 10, 30, 80, 20, $ES_AUTOHSCROLL) 
    GUICtrlSetOnEvent(-1, "mydisable")

    Leider wird die Funktion nie ausferufen.

    Hat jemand ein Tipp, wie ich ein Keypress event registrieren und abfangen kann?

    Gruss RogerSt

    Einmal editiert, zuletzt von RogerSt (19. März 2009 um 16:07)

  • Hey Roger!
    Einfacher geht es so:

    Zuerst:

    [autoit]

    GUIRegisterMsg($WM_COMMAND, <Funtkionsname>)

    [/autoit]

    - In dem Musterbeispiel ist meine Funktion "WM_COMMAND"

    Dann:

    Spoiler anzeigen
    [autoit]

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    If Not IsHWnd($edit1) Then $hWndEdit = GUICtrlGetHandle($edit1)
    If Not IsHWnd($edit2) Then $hWndEdit2 = GUICtrlGetHandle($edit2)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord ($iwParam)
    $iCode = _WinAPI_HiWord ($iwParam)
    Switch $hWndFrom
    Case $edit1, $hWndEdit
    Switch $iCode
    Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control

    [/autoit] [autoit][/autoit] [autoit]

    ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
    ; inserted would exceed the width of the edit control.
    ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
    ; from a text insertion would exceed the height of the edit control
    Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
    Case $EN_UPDATE ; Sent when an edit control is about to redraw itself

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_VSCROLL ; Sent when the user clicks an edit control's vertical scroll bar or when the user scrolls the mouse wheel over the edit control

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    Case $edit2, $hWndEdit2
    Switch $iCode
    Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control

    Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control

    [/autoit] [autoit][/autoit] [autoit]

    ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
    ; inserted would exceed the width of the edit control.
    ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
    ; from a text insertion would exceed the height of the edit control
    Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
    Case $EN_UPDATE ; Sent when an edit control is about to redraw itself

    [/autoit] [autoit][/autoit] [autoit]

    Case $EN_VSCROLL
    EndSwitch

    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]

    -Ich gehe einfach mal von 2 editboxen aus ($edit1, $edit2)...Einfach deine Funktionen hinter die entsprechende Events schreiben und feddisch ;)

    2 Mal editiert, zuletzt von ChaosKeks (19. März 2009 um 15:33)