Tastendruck in Input-Box anzeigen

  • moin moin,

    Wie bekommt man es hin das ein Tastendruck z.B. " F9 " in einer Input-Box ( eins in der Gui) angezeigt wird ?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 662, 366, 192, 124)
    $Label1 = GUICtrlCreateLabel("Tasten Kombinationen", 178, 11, 277, 33)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    $Hauptmpro = GUICtrlCreateButton("Zurück", 518, 297, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $beenden = GUICtrlCreateButton("Beenden", 518, 327, 107, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Einstellungen Sichern", 156, 303, 275, 33)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Group1 = GUICtrlCreateGroup("", 34, 163, 585, 129)
    $List1 = GUICtrlCreateList("", 42, 179, 569, 97)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $eins = GUICtrlCreateInput("eins", 34, 75, 57, 24, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Drücke eine Taste", 74, 51, 109, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Enter", 106, 73, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Löschen", 106, 109, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Gewählte Tastenkombination", 40, 148, 168, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $zwei = GUICtrlCreateInput("zwei", 272, 74, 121, 24, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("Pfadangaben", 352, 50, 79, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button4 = GUICtrlCreateButton("Enter", 400, 72, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button5 = GUICtrlCreateButton("Löschen", 400, 108, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Oder für die " Pfeil runter " Taste soll dann " down " da erscheinen usw.

    Gibt es da eine Möglichkeit bei Autoit ?

    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

    3 Mal editiert, zuletzt von oh-ha (8. Mai 2010 um 08:57)

  • Das geht komischerweise nicht bei mir.
    Zeigt gar nichts an weder die 1.6 noch die 1.7beta
    Habe die Autoit Version v3.3.4.0

    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

  • jepp das war genau das was ich gesucht habe. Danke dir :thumbup:

    Was die Suche bei Google angeht.
    Habe ein arges Problem wenn es ums Englische geht.
    Liegt 30Jahre zurück und selbst da war es ein Buch mit sieben Siegeln für mich.


    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

  • joa ich habs ja auch nur gefunden weil ichs schon kannte. und selbst so musste ich nochmal 5 minuten googeln :D

    hast ja gesehn dass der erste link nich gepasst hat.
    aber die udf ist eine meiner lieblings-udf's :)

  • Jepp gebe ich dir recht könnte auch die meinige werden, wenn ich denn mal in ferner Zukunft Autoit verstehen werde.
    Stehe da noch am Anfang mit Autoit aber das Ende buddelt schon ein Loch für mich.
    Mal schauen wer erster ist.

    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

  • moin moin,

    muss das noch mal rauskramen.
    Der Link zum Skript.http://www.autoitscript.com/forum/index.php?showtopic=96492
    Bekomme immer eine fehlermeldung von dem Skript

    Code
    C:\Program Files\AutoIt3\Include\hotkeys.au3(230,21) : WARNING: $hWnd: possibly used before declaration.


    Meine Autoit Version v3.3.4.0 falls es mit der nicht gehen sollte.
    Selbst wenn ich " $hWnd " als Global setze macht es das noch.
    komme da nicht weiter.

    Edit: Habe mir mal die Autoit Version v3.3.6.1 drauf gemacht aber leider mit dem selben Ergebnis

    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

    2 Mal editiert, zuletzt von oh-ha (8. Mai 2010 um 07:12)

  • Ähm habe ich mich wohl was falsch ausgedrückt.
    Das macht es auch mit dem Beispielskript das auf der Seite angeboten wird.
    Also egal ob mit dem meinigen oder sonst einen.
    Das ist ja das komische dabei.


    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

  • Kommt das selbige bei raus.

    Code
    C:\Program Files\AutoIt3\Include\hotkeys.au3(230,21) : WARNING: $hWnd: possibly used before declaration.
    		_SendMessage($hWnd,
    		~~~~~~~~~~~~~~~~~~^

    mfg
    oh-ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

    • Offizieller Beitrag

    Im Sctipt ist auch ein Fehler in Zeile 230 das sollte so aussehen:

    [autoit]

    _SendMessage($hHotkey, $HKM_SETHOTKEY)

    [/autoit]
  • OK, danke dir das war es.
    Hat dann zwar noch in Zeile 272 den selben Fehler angezeigt

    Code
    Zeile272 	_SendMessage($hWnd, $HKM_SETRULES,$invalid_combination,$modifiers)


    Das habe ich dann auch so ersetzt :

    Code
    Zeile272	_SendMessage($hHotkey, $HKM_SETRULES,$invalid_combination,$modifiers)


    und nun geht das ganze.
    Da sieht man mal wieder das es da noch so einiges zu Lernen gibt. :rolleyes:

    mfg
    oh ha

    Es gibt drei Wahrheiten: deine Wahrheit, meine Wahrheit und die Wahrheit

    • Offizieller Beitrag

    Doch, ist er. Hab es doch auch gedownloadet.

    Hier mal der Code des Downloades:

    Spoiler anzeigen
    [autoit]

    #include-once
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    ; #CURRENT# =====================================================================================================================
    ;_GuiCtrlHotKey_Create
    ;_GuiCtrlHotKey_GetFullInfo
    ;_GuiCtrlHotKey_GetHotkey
    ;_GuiCtrlHotKey_SetHotkey
    ;_GuiCtrlHotKey_GetFormat
    ;_GuiCtrlHotKey_SetRules
    ; ===============================================================================================================================

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

    Global Const $HKM_SETHOTKEY = $WM_USER + 1
    Global Const $HKM_GETHOTKEY = $WM_USER + 2
    Global Const $HKM_SETRULES = $WM_USER + 3

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

    Global Const $HOTKEYF_SHIFT = 0x01
    Global Const $HOTKEYF_CONTROL = 0x02
    Global Const $HOTKEYF_ALT = 0x04
    Global Const $HOTKEYF_EXT = 0x08; Extended(Extra) key

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

    ; invalid key combinations
    Global Const $HKCOMB_NONE = 0x1; Unmodified keys
    Global Const $HKCOMB_S = 0x2; SHIFT
    Global Const $HKCOMB_C = 0x4; CTRL
    Global Const $HKCOMB_A = 0x8; ALT
    Global Const $HKCOMB_SC = 0x10; SHIFT+CTRL
    Global Const $HKCOMB_SA = 0x20; SHIFT+ALT
    Global Const $HKCOMB_CA = 0x40; CTRL+ALT
    Global Const $HKCOMB_SCA = 0x80; SHIFT+CTRL+ALT

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_Create
    ; Description ...: Create a HotKey control
    ; Syntax.........: _GuiCtrlHotKey_Create($hWnd, $iX, $iY[, $iWidth = 150[, $iHeight = 20[, $iBold=0]]])
    ; Parameters ....: $hWnd - Handle to GUI window
    ; $iX - The left side of the control
    ; $iY - The top of the control
    ; $iWidth - The width of the control
    ; $iHeigth - The height of the control
    ; $iBold - Sets bold style for the font
    ; Return values .: Success - Handle to the HotKey control
    ; Failure - 0
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_Create($hWnd, $iX, $iY, $iWidth = 150, $iHeight = 20, $iBold=0)
    Local $hHotkey = _WinAPI_CreateWindowEx (0, 'msctls_hotkey32', '', BitOR($WS_CHILD, $WS_VISIBLE, $WS_TABSTOP), $iX, $iY, $iWidth, $iHeight, $hWnd)
    If NOT $iBold Then _SendMessage($hHotkey, 0x0030, 0x018A0029) ; sets normal font for hotkey control (non-bold)
    return $hHotkey
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_GetHotkey
    ; Description ...: Get number identifying pressed keys in HotKey control
    ; Syntax.........: _GuiCtrlHotKey_GetHotkey($hHotKey)
    ; Parameters ....: $hWnd - Handle to GUI window
    ; Return values .: Success - Returns HotKey number
    ; Failure - 0
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_GetHotkey($hHotKey)
    Local $hotkey=_SendMessage($hHotKey, $HKM_GETHOTKEY)
    return $hotkey
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_SetHotkey
    ; Description ...: Set Hotkey in HotKey Control
    ; Syntax.........: _GuiCtrlHotKey_SetHotkey($hHotKey, $value)
    ; Parameters ....: $hHotKey - Handle to HotKey Control
    ; $value - Number identifying pressed keys in HotKey control
    ; Return values .: Success - 1
    ; Failure - 0
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_SetHotkey($hHotKey,$value)
    Local $result=_SendMessage($hHotKey, $HKM_SETHOTKEY,$value)
    return $result
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_GetFormat
    ; Description ...: Get Normal and HotKey format from unique HotKey number
    ; Syntax.........: _GuiCtrlHotKey_GetFormat($i_HotKeyFull)
    ; Parameters ....: $i_HotKeyFull - Number identifying pressed keys in HotKey control
    ; Return values .: Success - Array with the following format:
    ; [0] - HotKey format
    ; [1] - Normal format
    ; Failure - -1
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_GetFormat($i_HotKeyFull)
    Local $n_Flag = BitShift($i_HotKeyFull, 8); high byte
    Local $i_HotKeyReal = BitAND($i_HotKeyFull, 0xFF); low byte
    Local $normal_format,$hotkey_format,$chr_hotkey,$chr_normal,$i_HotKeyCut

    If BitAnd($n_Flag, $HOTKEYF_CONTROL) Then
    $hotkey_format&= "^"
    $normal_format&="Ctrl+"
    Endif
    If BitAnd($n_Flag, $HOTKEYF_SHIFT) Then
    $hotkey_format&="+"
    $normal_format&="Shift+"
    Endif
    If BitAnd($n_Flag, $HOTKEYF_ALT) Then
    $hotkey_format&="!"
    $normal_format&="Alt+"
    Endif

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

    If BitAnd($n_Flag, $HOTKEYF_EXT) Then
    $chr_hotkey=""
    Switch $i_HotKeyReal
    Case 33
    $chr_hotkey="PGUP"
    $chr_normal="Page Up"
    Case 34
    $chr_hotkey="PGDN"
    $chr_normal="Page Down"
    Case 35
    $chr_hotkey="End"
    $chr_normal="End"
    Case 36
    $chr_hotkey="Home"
    $chr_normal="Home"
    Case 37
    $chr_hotkey="Left"
    $chr_normal="Left"
    Case 38
    $chr_hotkey="Up"
    $chr_normal="Up"
    Case 39
    $chr_hotkey="Right"
    $chr_normal="Right"
    Case 40
    $chr_hotkey="Down"
    $chr_normal="Down"
    Case 45
    $chr_hotkey="Ins"
    $chr_normal="Insert"
    Case 111
    $chr_hotkey="NUMPADDIV"
    $chr_normal="Num /"
    Case 144
    $chr_hotkey="NumLock"
    $chr_normal="Num Lock"
    EndSwitch
    If $chr_hotkey="" Then return -1
    $hotkey_format&="{" & $chr_hotkey & "}"
    $normal_format&=$chr_normal
    Else
    $i_HotKeyCut=$i_HotKeyReal
    If StringRegExp($i_HotKeyCut,"\b(45|35|40|34|37|12|39|36|38|33)\b") Then return -1 ;Remove Numpad 0-9 hotkeys when NumLock is off.
    Switch $i_HotKeyReal
    Case 186
    $i_HotKeyCut-=127
    Case 187
    $i_HotKeyCut-=126
    Case 128 to 191
    $i_HotKeyCut-=144
    Case 192
    $i_HotKeyCut-=96
    Case 222
    $i_HotKeyCut-=183
    Case 193 to 255
    $i_HotKeyCut-=128
    EndSwitch

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

    Switch $i_HotKeyReal
    Case 112 to 123
    $chr_hotkey="F" & ($i_HotKeyReal-111)
    $chr_normal=$chr_hotkey
    Case 96 to 105
    $chr_hotkey="NUMPAD" & ($i_HotKeyReal-96)
    $chr_normal="Num " & $i_HotKeyReal-96
    Case 106
    $chr_hotkey="NUMPADMULT"
    $chr_normal="Num *"
    Case 107
    $chr_hotkey="NUMPADADD"
    $chr_normal="Num +"
    Case 109
    $chr_hotkey="NUMPADSUB"
    $chr_normal="Num /"
    Case 110
    $chr_hotkey="NUMPADDOT"
    $chr_normal="Num ."
    Case 145
    $chr_hotkey="SCROLLLOCK"
    $chr_normal="Scroll Lock"
    Case 20
    $chr_hotkey="CAPSLOCK"
    $chr_normal="Caps Lock"
    Case Else
    $chr_hotkey=Chr($i_HotKeyCut)
    $chr_normal=$chr_hotkey
    EndSwitch
    $hotkey_format&="{" & StringLower($chr_hotkey) & "}"
    $normal_format&=$chr_normal
    Endif

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

    If $i_HotKeyReal>0 Then
    Local $ret_format[3]
    $ret_format[0]=$hotkey_format
    $ret_format[1]=$normal_format
    return $ret_format
    Else
    return -1
    Endif
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_GetFullInfo
    ; Description ...: Get Normal and HotKey format and also HotKey number from HotKey Control
    ; Syntax.........: _GuiCtrlHotKey_GetFullInfo($hHotkey)
    ; Parameters ....: $hHotkey - Handle to HotKey Control
    ; Return values .: Success - Array with the following format:
    ; [0] - HotKey format
    ; [1] - Normal format
    ; [2] - Hotkey number
    ; Failure - -1
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_GetFullInfo($hHotkey)
    Local $hotkey=_GuiCtrlHotKey_GetHotkey($hHotkey)
    Local $hotkey_format=_GuiCtrlHotKey_GetFormat($hotkey)
    If $hotkey_format=-1 Then
    _SendMessage($hWnd, $HKM_SETHOTKEY)
    return -1
    Else
    Local $info[3]
    $info[0]=$hotkey_format[0]
    $info[1]=$hotkey_format[1]
    $info[2]=$hotkey
    return $info
    Endif
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GuiCtrlHotKey_SetRules
    ; Description ...: Set rules for HotKey control
    ; Syntax.........: _GuiCtrlHotKey_SetRules($hHotkey, $invalid_combination[, $modifiers=0])
    ; Parameters ....: $hHotkey - Handle to HotKey Control
    ; $invalid_combination - this combination will block
    ; $modifiers - this modifiers are established when pressed $invalid_combination
    #cs
    -----------Flags for rules:-----------
    $invalid_combination:
    $HKCOMB_NONE - Unmodified keys; it is blocked nothing, it is used only for "Modifiers"
    $HKCOMB_S - SHIFT
    $HKCOMB_C - CTRL
    $HKCOMB_A - ALT
    $HKCOMB_SC - SHIFT+CTRL
    $HKCOMB_SA - SHIFT+ALT
    $HKCOMB_CA - CTRL+ALT
    $HKCOMB_SCA - SHIFT+CTRL+ALT

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

    $modifiers:
    $HOTKEYF_SHIFT - SHIFT
    $HOTKEYF_CONTROL - CTRL
    $HOTKEYF_ALT - ALT
    $HOTKEYF_EXT - Extra key
    ----------------------------------------------
    #ce
    ; Return values .: Success - 1
    ; Failure - 0
    ; ===============================================================================================================================

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

    Func _GuiCtrlHotKey_SetRules($hHotkey,$invalid_combination,$modifiers=0)
    _SendMessage($hWnd, $HKM_SETRULES,$invalid_combination,$modifiers)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Keine Ahnung warum das bei dir funzt. Aber die 2 Fehler sind definitiv vorhanden. Beim Beispielscript wurde z.B. nur der 1. bemängert.

    • Offizieller Beitrag

    Wenn du die Fehler Ignorierst und die Funktionen mit den Fehlern nicht aufgerufen werden dann schon. Aber Warnungen sollte man nie ignorieren, sonst sucht man sich bei einem Fehler den Wolf.