Tasten werden doppelt angezeigt mit GetKeyboardInput...Function

  • moin moin,

    Habe da ein Problem mit meinen Skript.
    Es werden zum teil Tastenklicks doppelt angezeigt mit der GetKeyboardInput...Function von Faweyr.

    Skript
    [autoit]

    #include <GuiDateTimePicker.au3>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <ComboConstants.au3>
    #include <DateTimeConstants.au3>
    #include <EditConstants.au3>
    #include <Excel.au3>
    #include <Array.au3>
    #include <File.au3>
    #include <GuiComboBox.au3>
    #include <Date.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <DateTimeConstants.au3>
    #include <string.au3>
    #include <hotkeys.au3>
    #include <Misc.au3>

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

    Global $klick, $Inputtaste, $List1

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

    #RequireAdmin

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

    Opt("GUIOnEventMode", 1)
    Tastenkombination()
    Func Tastenkombination()
    $Tastenkombi = GUICreate("Tastenkombi", 810, 472, 405, 119)
    GUISetBkColor(0x3399FF)
    $Label1 = GUICtrlCreateLabel("Tasten Kombinationen", 280, 104, 277, 33)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    $Hauptmpro = GUICtrlCreateButton("Zurück", 620, 390, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $beenden = GUICtrlCreateButton("Beenden", 620, 420, 107, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Einstellungen Sichern", 258, 396, 275, 33)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Group1 = GUICtrlCreateGroup("", 136, 256, 585, 129)
    $List1 = GUICtrlCreateEdit("", 144, 272, 569, 105, BitOR($ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Inputtaste = GUICtrlCreateInput("", 80, 168, 120, 24, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Drücke eine Taste", 176, 144, 109, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $button = GUICtrlCreateButton("Neu",208, 166, 107, 25)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("Löschen", 208, 202, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("Gewählte Tastenkombination", 142, 241, 168, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateInput("", 374, 167, 121, 21)
    $Label4 = GUICtrlCreateLabel("Pfadangaben", 454, 143, 79, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button4 = GUICtrlCreateButton("Enter", 502, 165, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Button5 = GUICtrlCreateButton("Löschen", 502, 201, 107, 25, BitOR($BS_FLAT,$WS_GROUP))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    GUICtrlSetOnEvent($beenden, "endmain")
    GUICtrlSetOnEvent($button, "tastenklick")
    While 1
    Sleep(50)
    WEnd
    EndFunc ;==>Tastenkombinationen
    #cs
    Autor der GetKeyboardInput...Function: Faweyr
    Site : http://www.autoit.de/index.php?page=Thread&threadID=20071
    #ce
    Func tastenklick()
    $klick = $klick + 1
    GUICtrlSetData($Inputtaste,"neue Taste bitte")
    $result = GetKeyInput() ;5s warten, gibt Array zurück!
    GUICtrlSetData($Inputtaste,$result[1]) ;den Name der Taste als Buttontext setze
    $abc = GUICtrlRead ($Inputtaste)
    ;MsgBox(0,"", $abc)
    IniWrite(@WindowsDir & "\system\meine.ini", "Tastenklicks", $klick, $abc)
    $po = IniRead(@WindowsDir & "\system\meine.ini", "Tastenklicks", $klick, "")
    GUICtrlSetData($List1, $po & " - ", "|" )
    EndFunc ;==>tastenklick

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

    Func GetKeyInput($sTime = 4000,$sBack = 0)
    $sTimer = TimerInit()
    $sDll = DllOpen("user32.dll")
    Local $sList[111][3] = [ [08,"{BACKSPACE}","Backspace"], [09,"{TAB}","Tab"], [0&"D","{ENTER}","Enter"], ["A"&0,"{LSHIFT}","Left Shift"], ["A"&1,"{RSHIFT}","Right Shift"], _
    [13,"{Pause}","Pause"], [14,"{CAPSLOCK}","Caps Lock"], [1&"B","{ESC}","Esc"], [20,"{SPACE}","Spacebar"], [21,"{PGUP}","Page Up"], [22,"{PGDN}","Page Down"], [23,"{End}","End"], _
    [24,"{Home}","Home"], [25,"{Left}","Left Arrow"], [26,"{UP}","Up Arrow"], [27,"{Right}","Right Arrow"], [28,"{Down}","Down Arrow"], [12,"{ALT}","Alt"], [5&"C","{RWIN}","Right Windows"], _
    [2&"C","{PRINTSCREEN}","Print Screen"], [2&"D","{INS}","Ins"], [2&"E","{DELETE}","Del"], [30,0,"0"], [31,1,"1"], [32,2,"2"], _
    [33,3,"3"], [34,4,"4"], [35,5,"5"], [36,6,"6"], [37,7,"7"], [38,8,"8"], [39,9,"9"], _
    [41,"a","A"], [42,"b","B"], [43,"c","C"], [44,"d","D"], [45,"e","E"], [46,"f","F"], [47,"g","G"], _
    [48,"h","H"], [49,"i","I"], [4&"A","j","J"], [4&"B","k","K"], [4&"C","l","L"], [4&"D","m","M"], [4&"E","n","N"], _
    [4&"F","o","O"], [50,"p","P"], [51,"q","Q"], [52,"r","R"], [53,"s","S"], [54,"t","T"], [55,"u","U"], _
    [56,"v","V"], [57,"w","W"], [58,"x","X"], [59,"y","Y"], [5&"A","z","Z"], [60,"{NUMPAD0}","Keypad 0"], [61,"{NUMPAD1}","Keypad 1"], _
    [62,"{NUMPAD2}","Keypad 2"],[63,"{NUMPAD3}","Keypad 3"], [64,"{NUMPAD4}","Keypad 4"], [65,"{NUMPAD5}","Keypad 5"], [66,"{NUMPAD6}","Keypad 6"], [67,"{NUMPAD7}","Keypad 7"], [68,"{NUMPAD8}","Keypad 8"], _
    [69,"{NUMPAD9}","Keypad 9"],[6&"A","{NUMPADMULT}","Multiply"], [6&"B","{NUMPADADD}","Add"], [6&"C","{NUMPADENTER}","Separator"],[6&"D","{NUMPADSUB}","Subtract"], [6&"E","{NUMPADDOT}","Decimal"], [6&"F","{NUMPADDIV}","Divide"], _
    [70,"{F1}","F1"], [71,"{F2}","F2"], [72,"{F3}","F3"], [73,"{F4}","F4"], [74,"{F5}","F5"], [75,"{F6}","F6"], [76,"{F7}","F7"], _
    [77,"{F8}","F8"], [78,"{F9}","F9"], [79,"{F10}","F10"], [7&"A","{F11}","F11"], [7&"B","{F12}","F12"], [90,"{NUMLOCK}","Num Lock"], [91,"{SCROLLLOCK}","Scroll Lock"], _
    ["A"&2,"{LCTRL}","Left Control"], ["A"&3,"{RCTRL}","Right Control"], ["A"&4,"{LALT}","Left Menu"], ["A"&5,"{RALT}","Right Menu"], [5&"B","{LWIN}","Left Windows"] ]

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

    do
    for $i = 0 to UBound($sList)-1 step 1
    If _IsPressed($sList[$i][0], $sDll) then
    DllClose($sDll)
    If $sBack <> 0 then
    Return $sList[$i][$sBack]
    else
    Local $sResult[3] = [$sList[$i][0],$sList[$i][1],$sList[$i][2]]
    Return $sResult
    endif
    endif
    Next
    until $sTime <= TimerDiff($sTimer)
    DllClose($sDll)
    SetError(1)
    EndFunc

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

    Func endmain()
    Exit
    EndFunc ;==>endmain

    [/autoit]


    Bei der " Enter " Taste kommt es fast immer vor das sie im Input-Fenster doppelt angezeigt wird aber auch die " SPACE " Taste und sporadisch auch bei den "F* " Tasten.
    Was muss ich da ändern das die tasten auch wirklich nur einmal in der Input-Box angezeigt werden ?


    mfg
    oh-ha

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

    Einmal editiert, zuletzt von oh-ha (12. Mai 2010 um 08:39)

  • Wenn man auf den button klickt erhält dieser ja den fokus. und mit Enter und Space drückt man fokusierten button.
    das problem sollte also weg sein wenn du bei buttonclick den focus auf das Input legst

    aber wo das problem mit den F* tasten liegt weiß ich nicht.

  • Verstanden habe ich das so weit, hoffe ich mal, nur wie bekomme ich den Fokus auf das Input ?
    Beim durchlaufen geht der doch immer wieder auf den button.


    mfg
    oh-ha

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

  • Jepp, bei mir auch.
    Danke dir, :thumbup:
    werde das auch so lassen und den rest fertigmachen.
    Da das mit den " F* " Tasten nur sporadisch auftaucht werde ich es erst einmal vernachlässigen.

    Auf das mit den " $GUI_FOCUS " bin ich nicht gekommen.


    mfg
    oh-ha

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