von einem GUICtrlCreateInput zum nächsten GUICtrlCreateInput mit der <Enter>-Taste durchhangeln ... wie macht man das ? Eigentlich kann man ja nur mit der TAB-Taste die Elemente in der GUI durchgehen. Ich möchte aber mit der <Enter>-Taste durch die Input-Felder in der GUI gehen ... hat jemand ein Beispiel ?
drücken der <ENTER> - Taste in einem GUICtrlCreateInput abfangen
-
Schmunke -
24. Januar 2020 um 11:35 -
Erledigt
-
-
Brauchst du denn eine spezielle Reihenfolge oder so? Ansonsten könntest du ja einfach mit Accelerators die Enter-Taste abfragen und dann durchhüpfen, etwa so:
C
Alles anzeigen#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 303, 309, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 80, 24, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 80, 80, 121, 21) $Input3 = GUICtrlCreateInput("Input3", 80, 144, 121, 21) $Input4 = GUICtrlCreateInput("Input4", 80, 208, 121, 21) $hDummy = GUICtrlCreateDummy() Local $aAcc[1][2] = [ ["{ENTER}", $hDummy] ] GUISetAccelerators($aAcc, $Form1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hDummy ControlSend($Form1, "", "", "{TAB}") EndSwitch WEnd
-
Hhhmmm .Habs mir einfacher vorgestellt ...
Ist natürlich ne Lösung. Aber ich habe 2 GUIs mit 20 GuiCtrlCreateInput und 6 Buttons im ersten GUI; sowie 15 GuiCtrlCreateInput und 4 Buttons im zweiten GUI. Demnach müßte ich immer in Erfahrung bringen auf welchem GuiCtrlCreateInput ich gerade stehe und bei einem <Enter> den Fokus auf das nächste GuiCtrlCreateInput setzen ... was passiert dann eigentlich bei den Buttons ?
... in der Summe doch sehr aufwendig ... find ich; oder ?
Könnte man der Funktion GuiCtrlCreateInput nicht eine Liste mitgeben, mit welchen Tasten die Funktion verlassen werden darf ... z.Bsp. Enter, TAB, Escape, die 4 Cursortasten ... ?
Um deine Frage zu beantworten : ja - ich bräuchte ne bestimmte Reihenfolge.
-
Hallo Schmunke
Ich sehe jetzt ehrlich gesagt nicht den Aufwand, von dem du schreibst..
Bei deinen GUI's wäre jetzt doch nur neu:CodeLocal $aAcc[1][2] = [ ["{ENTER}", $hDummy] ] GUISetAccelerators($aAcc, $Form1) ... Case $hDummy ControlSend($Form1, "", "", "{TAB}") ..
Da gehst du die Reihe ganz normal durch, wie wenn du Tab drücken würdest.
Wenn du eine andere Reihenfolge willst, oder Controls auslassen willst, könntest du sie in einem Array speichern und eigene Regeln programmieren. -
- Offizieller Beitrag
Oder wie hier gepostet: Von Input zu Input
-
autoiter ... ah - da hab ich mich vertan. Ich sehe's gerade. Ich dachte ich muss ein Array über alle GuiCtrlCreateInput machen.
Aber das muss ich ja gar nicht ... ich muss ja nur den TAB senden.
BugFix ... das ist was 'Globales' ... das sieht gut aus. Probier ich mal dieses WE aus ...
Danke erstmal für die Tips
-
hhhmmm ... hab die paar Zeilen jetzt mal eingefügt ... aber klappt nicht.
Mach ich was falsch ?
C
Alles anzeigen#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPISys.au3> #include <Array.au3> #include <Excel.au3> #include <GuiListView.au3> ; Hauptfenster Global $HF_Form1, $HF_Group2, $HF_Group3, $HF_Group4, $HF_Group5, $HF_Group6, $HF_Group7, $HF_Group8, $HF_Group9, $HF_Radio1, $HF_Radio2 Global $HF_Button1, $HF_Button2, $HF_Button3, $HF_Button4, $HF_Button5, $HF_Button6, $HF_Button7, $HF_Button8 Global $HF_Inp_DP, $HF_Inp_SS, $HF_Inp_LHR, $HF_Inp_LMR, $HF_Inp_Masse, $HF_Inp_VNENN, $HF_Inp_FAB, $HF_Inp_BEMERK, $HF_Inp_PBAR, $HF_Inp_XD Global $HF_Inp_DD1, $HF_Inp_NG1, $HF_Inp_DD2, $HF_Inp_NG2, $HF_Inp_DD3, $HF_Inp_NG3, $HF_Inp_DD4, $HF_Inp_NG4, $HF_Inp_NS, $HF_Inp_SO, $HF_Inp_LA Global $HF_Inp_NA, $HF_Inp_LZ, $HF_Inp_NZ Global $HF_Label1, $HF_Label2, $HF_Label3, $HF_Label4, $HF_Label5, $HF_Label6, $HF_Label7, $HF_Label8, $HF_Label9, $HF_Label10, $HF_Label11, $HF_Label12 Global $HF_Label13, $HF_Label14, $HF_Label15, $HF_Label16, $HF_Label17, $HF_Label18, $HF_Label19, $HF_Label20, $HF_Label21, $HF_Label22, $HF_Label23 Global $HF_Label24, $HF_Label25, $HF_Label26, $HF_Label27, $HF_Label28, $HF_Label29, $HF_Label30, $HF_Label31, $HF_Label32, $HF_Label33, $HF_Label34 Global $HF_Label35, $HF_Label36, $HF_Label37, $HF_Label38, $HF_Label39, $HF_Label40, $HF_Label41, $HF_Label42, $HF_Label43, $HF_Label44, $HF_Label45 Global $HF_Label46, $HF_Label47, $HF_Label48, $HF_Label49, $HF_Label50, $HF_Label51, $HF_Label52, $HF_Label53, $HF_Label54, $HF_Label55 Const $Pi4 = 0.7853981633975 Const $G0 = 9.81 ; Erdbeschleunigung Const $RHO = 890 ; Öldichte 890 kg/m3 (Liste mit verschiedenen Dichten ?) Const $NPOL = 1.35 ; Polytropenexponent (wovon abhängig ?) Const $ZETA = 1.55 ; Drosselbeiwert (woher kommt der ? was bedeutet er ?) Const $ETA = 0.95 ; mech. Wirkungsgrad (temperaturabhängig ?) Const $K = 1.25 ; Kurvenformfaktor (woher kommt der ? was bedeutet er ?) Const $VFAKT = 1.15 ; Aufprallgeschwindigkeit = 115% der Nenngeschwindigkeit nach EN 81 (wird bezweifelt !) Const $EERSATZ = 1515 ; Ersatz E-Modul in N/mm2 Const $sVersion = "Version 3.0.0 vom 19.12.2019" Const $DATEINAME = "LP 211 - FS-Verlauf.txt" Const $sDatenbank = "Liftpuffer Typ LP.xlsx" Dim $hFile, $boBerechnen, $boSpeichern, $sDummy, $nMsg_HF, $nMsg_NF, $sText, $DKZ, $sBOBI Dim $sDatum, $DP, $SS, $SM, $LHR, $LMR, $D1, $A1, $A2, $D2, $D3, $DKS, $COFF, $CHR, $V0KOPF, $HGAS Dim $XI, $XI2, $XD, $XDNEU, $X, $SX, $SO, $SA, $SZ, $PRJN, $XPR, $DXPR, $VPXP, $VPX, $FPX1P, $FPX1, $AXIP, $AXI, $TP, $T Dim $ADX, $ADU, $S, $DAD, $SX, $NS, $ADO, $LA, $ADA, $LZ, $ADZ, $P1X, $ZRA, $P2X, $V0, $AKS, $P0, $FRANF, $FRUECK, $AMITTLS, $AMITTLT Dim $A1, $FC, $CON, $FPX1, $FPX2, $FVX, $B0, $B1, $B2, $DFP, $FPMAXI, $XFPMAX, $XFPMAXI, $Masse, $AMAX, $XAMAX, $EUM, $VPX2Q, $VPX2 Dim $VP, $VNENN, $FAB, $BEMERK, $EKIN, $EPOT, $EGES, $FPMAX, $PBAR, $P0, $FDYN, $EKINX1, $ANSTFL, $XSCHWING, $SCHWING, $VGAS Dim $SYSTEM, $ADERF, $DDERF, $NGERF, $NG, $DD, $DD1, $NG1, $AD1, $DD2, $NG2, $AD2, $ADVOR, $ADPRO Dim $NA, $NZ, $NEUXD, $FU, $FO, $NR, $NE Dim $SS_2, $LHR_2, $Masse_2, $VNENN_2, $PBAR_2, $DD1_2, $NG1_2, $DD2_2, $NG2_2, $NS_2, $SO_2, $LA_2, $NA_2, $LZ_2, $NZ_2, $B0_2, $B1_2, $B2_2, $VP_2, $VGAS_2, $FU_2, $FO_2 Dim $ADERF_2, $DDERF_2, $NGERF_2, $EGES_2, $FPMAX_2, $SM_2, $D1_2, $D2_2, $D3_2, $A1_2, $A2_2, $AKS_2, $DKS_2, $COFF_2, $CHR_2, $V0KOPF_2 Dim $CON_2, $EKIN_2, $EPOT_2, $EGES_2, $FPMAX_2, $P0_2, $FDYN_2, $XD_2, $SCHWING_2, $VFAKT_2 Dim $hEnterDummy, $aAcc[1][2] = [["{ENTER}", $hEnterDummy]] #Region ### START Koda GUI section ### $HF_Form1 = GUICreate("Liftpuffer", 624, 666, -1, -1) GUISetFont(10, 400, 0, "MS Sans Serif") $HF_Group2 = GUICtrlCreateGroup(" Pufferdaten ", 8, 8, 249, 124, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label1 = GUICtrlCreateLabel("Pufferdurchmesser in mm", 16, 32, 154, 20) $HF_Inp_DP = GUICtrlCreateInput($DP, 192, 30, 57, 24) $HF_Label2 = GUICtrlCreateLabel("Pufferhub in mm", 16, 56, 98, 20) $HF_Inp_SS = GUICtrlCreateInput($SS, 192, 54, 57, 24) $HF_Label3 = GUICtrlCreateLabel("Länge Hydraulikrohr in mm", 16, 80, 163, 20) $HF_Inp_LHR = GUICtrlCreateInput($LHR, 192, 78, 57, 24) $HF_Label4 = GUICtrlCreateLabel("Länge Mantelrohr in mm", 16, 104, 146, 20) $HF_Inp_LMR = GUICtrlCreateInput($LMR, 192, 102, 57, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group4 = GUICtrlCreateGroup(" Auslegungsdaten des Puffers ", 264, 8, 345, 100, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label5 = GUICtrlCreateLabel("aufprallende Masse in kg", 272, 32, 154, 20) $HF_Inp_Masse = GUICtrlCreateInput($Masse, 448, 30, 57, 24) $HF_Label6 = GUICtrlCreateLabel("Nenngeschwindigkeit in m/s", 272, 56, 170, 20) $HF_Inp_VNENN = GUICtrlCreateInput($VNENN, 448, 54, 57, 24) $HF_Label11 = GUICtrlCreateLabel("Gasdruck in bar", 272, 80, 98, 20) $HF_Inp_PBAR = GUICtrlCreateInput($PBAR, 448, 78, 57, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group6 = GUICtrlCreateGroup(" Energie ", 8, 144, 249, 76, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label9 = GUICtrlCreateLabel("Pufferenergie E in Nm", 16, 168, 133, 20) $HF_Label44 = GUICtrlCreateLabel($EGES, 194, 168, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label10 = GUICtrlCreateLabel("max. Pufferkraft FPmax in Nm", 16, 192, 176, 20) $HF_Label45 = GUICtrlCreateLabel($FPMAX, 194, 192, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group5 = GUICtrlCreateGroup(" Bezeichnung ", 264, 120, 345, 76, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label7 = GUICtrlCreateLabel("Fabrik-Nummer", 272, 144, 97, 20) $HF_Inp_FAB = GUICtrlCreateInput($FAB, 376, 142, 81, 24) $HF_Label8 = GUICtrlCreateLabel("Bemerkung", 272, 168, 73, 20) $HF_Inp_BEMERK = GUICtrlCreateInput($BEMERK, 376, 166, 225, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group7 = GUICtrlCreateGroup(" Auslegung des Bohrbilds ", 8, 232, 249, 424, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label12 = GUICtrlCreateLabel("a) gem. Pufferdefinition", 16, 256, 139, 20) $HF_Label13 = GUICtrlCreateLabel("erf. Fläche in mm²", 32, 280, 108, 20) $HF_Label46 = GUICtrlCreateLabel($ADERF, 192, 280, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label14 = GUICtrlCreateLabel("Durchmesser in mm", 32, 304, 122, 20) $HF_Label47 = GUICtrlCreateLabel($DDERF, 192, 304, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label15 = GUICtrlCreateLabel("Anzahl Bohrungen in mm", 32, 328, 150, 20) $HF_Label48 = GUICtrlCreateLabel($NGERF, 192, 328, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label16 = GUICtrlCreateLabel("b) eigene Definition", 16, 364, 119, 20) $HF_Label17 = GUICtrlCreateLabel("b1) Durchmesser D1 in mm", 16, 388, 164, 20) $HF_Inp_DD1 = GUICtrlCreateInput($DD1, 192, 386, 57, 24) $HF_Label18 = GUICtrlCreateLabel("Anzahl Bohrungen mit D1", 40, 412, 152, 20) $HF_Inp_NG1 = GUICtrlCreateInput($NG1, 192, 410, 57, 24) $HF_Label19 = GUICtrlCreateLabel("Fläche zu D1 in mm²", 40, 436, 123, 20) $HF_Label49 = GUICtrlCreateLabel($AD1, 192, 436, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label20 = GUICtrlCreateLabel("b2) Durchmesser D2 in mm", 16, 460, 164, 20) $HF_Inp_DD2 = GUICtrlCreateInput($DD2, 192, 458, 57, 24) $HF_Label21 = GUICtrlCreateLabel("Anzahl Bohrungen mit D2", 40, 484, 152, 20) $HF_Inp_NG2 = GUICtrlCreateInput($NG2, 192, 482, 57, 24) $HF_Label22 = GUICtrlCreateLabel("Fläche zu D2 in mm²", 40, 508, 123, 20) $HF_Label50 = GUICtrlCreateLabel($AD2, 192, 508, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label29 = GUICtrlCreateLabel("c) Ergebnis", 16, 544, 72, 20) $HF_Label30 = GUICtrlCreateLabel("Gesamtfläche (b1 + b2)", 32, 568, 141, 20) $HF_Label53 = GUICtrlCreateLabel($ADVOR, 192, 568, 57, 18) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label31 = GUICtrlCreateLabel("entspricht", 32, 592, 61, 20) $HF_Label54 = GUICtrlCreateLabel($ADPRO, 94, 592, 34, 18, $ES_RIGHT) GUICtrlSetBkColor(-1, 0x00FFFF) $HF_Label32 = GUICtrlCreateLabel("% der erf. Fläche.", 130, 592, 107, 20) $HF_Button1 = GUICtrlCreateButton("Bohrbild berechnen", 64, 620, 139, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group8 = GUICtrlCreateGroup(" Drosselkurvenexponent ", 264, 208, 345, 100, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Label33 = GUICtrlCreateLabel("Drosselkurvenexponent (0.5 ... 0.6)", 272, 232, 206, 20) $HF_Inp_NS = GUICtrlCreateInput($NS, 528, 230, 65, 24) $HF_Label34 = GUICtrlCreateLabel("norm. Wegendpunkt der Kurve (ca. 0.95)", 272, 256, 240, 20) $HF_Inp_SO = GUICtrlCreateInput($SO, 528, 254, 65, 24) $HF_Label55 = GUICtrlCreateLabel("Schrittweite (0.0001 ... 1.000 mm)", 272, 280, 191, 20) $HF_Inp_XD = GUICtrlCreateInput($XD, 528, 278, 65, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Group9 = GUICtrlCreateGroup(" Anstiegsflanke ", 264, 320, 345, 172, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT)) $HF_Radio1 = GUICtrlCreateRadio("Anstriegsflanke berücksichtigen", 272, 344, 225, 17) $HF_Radio2 = GUICtrlCreateRadio("KEINE Anstiegsflanke berücksichtigen", 272, 368, 249, 17) $HF_Label35 = GUICtrlCreateLabel("Länge der Anstiegsflanke in mm", 288, 392, 194, 20) $HF_Inp_LA = GUICtrlCreateInput($LA, 528, 392, 65, 24) $HF_Label36 = GUICtrlCreateLabel("Anzahl Bohrungen in Anstiegsflanke", 288, 416, 216, 20) $HF_Inp_NA = GUICtrlCreateInput($NA, 528, 414, 65, 24) $HF_Label37 = GUICtrlCreateLabel("Länge der Zwischenflanke in mm", 288, 440, 198, 20) $HF_Inp_LZ = GUICtrlCreateInput($LZ, 528, 438, 65, 24) $HF_Label38 = GUICtrlCreateLabel("Anzahl Bohrungen in Zwischenflanke", 288, 464, 220, 20) $HF_Inp_NZ = GUICtrlCreateInput($NZ, 528, 462, 65, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) $HF_Button2 = GUICtrlCreateButton("Puffer berechnen", 264, 500, 115, 25) $HF_Button8 = GUICtrlCreateButton("Standardpuffer laden", 392, 500, 135, 25) ;$HF_Button3 = GUICtrlCreateButton("Speichern", 264, 688, 75, 25) $HF_Button4 = GUICtrlCreateButton("Felder löschen", 414, 530, 103, 25) $HF_Button5 = GUICtrlCreateButton("Kennlinie berechnen", 264, 530, 135, 25) $HF_Button6 = GUICtrlCreateButton("Ende", 532, 530, 75, 25) ;$HF_Button7 = GUICtrlCreateButton("Laden", 346, 688, 75, 25) $HF_Label39 = GUICtrlCreateLabel("Berechnung der Drosselkennlinie", 272, 562, 202, 20) $HF_Label40 = GUICtrlCreateLabel("von Hydraulikpuffern Typ LP", 272, 582, 172, 20) $HF_Label41 = GUICtrlCreateLabel("Nur für Aufzugspuffer in stehender Anordnung !!!", 272, 602, 329, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $HF_Label42 = GUICtrlCreateLabel("Copyright 2019 by R.Schmidt, D-58332 Schwelm", 272, 622, 286, 20) $HF_Label43 = GUICtrlCreateLabel($sVersion, 272, 642, 174, 20) $hEnterDummy = GUICtrlCreateDummy() GUISetAccelerators($aAcc, $HF_Form1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Vorgabe : KEINE Anstiegsflanke If (GUICtrlRead($HF_Radio1) = $GUI_UNCHECKED) And (GUICtrlRead($HF_Radio2) = $GUI_UNCHECKED) Then GUICtrlSetState($HF_Radio2, $GUI_CHECKED) GUICtrlSetState($HF_Radio1, $GUI_UNCHECKED) GUICtrlSetState($HF_Inp_LA, $GUI_DISABLE) GUICtrlSetState($HF_Inp_NA, $GUI_DISABLE) GUICtrlSetState($HF_Inp_LZ, $GUI_DISABLE) GUICtrlSetState($HF_Inp_NZ, $GUI_DISABLE) EndIf While 1 $nMsg_HF = GUIGetMsg() Switch $nMsg_HF Case $GUI_EVENT_CLOSE Exit ;ProgrammEnde_HF() Case $HF_Radio1 ;MitAnstiegsflanke() Case $HF_Radio2 ;OhneAnstiegsflanke() Case $HF_Button8 ;StandardpufferLaden() Case $HF_Button1 ;BohrbildBerechnen() Case $HF_Button2 ;PufferBerechnen() Case $HF_Button3 ; Speichern() Case $HF_Button4 ;FelderLoeschen_HF() Case $HF_Button5 ;KennlinieBerechnen() ; Kennlinie berechnen und als txt-Datei speichern ;GUISetState(@SW_DISABLE, $HF_Form1) ; Hauptfenster deaktivieren ;KennlinieZeichnen() ; Grafikfenster aufrufen ... ;GUISetState(@SW_ENABLE, $HF_Form1) ; Hauptfenster wieder aktivieren Case $HF_Button6 ;ProgrammEnde_HF() Case $HF_Button7 ; Laden() Case $hEnterDummy ControlSend($HF_Form1, "", "", "{TAB}") EndSwitch WEnd
-
Du deklarierst die Variable $hEnterDummy und packst sie direkt ins Acceleratorarray, jedoch nicht als Referenz sondern einfach nur als Wert.
Der Dummy wurde aber noch nicht erzeugt, folglich steht im Array nur eine 0, darfst den Wert des Controls im Acceleratorarray erst zuweisen wenn du das Control auch definiert hast.
-
ups ... ja - hast Recht ... jetzt gehts
Danke