Hallo,
es gibt in vielen Formen etc. ein Input wo man Enter drücken kann und es schikt ab.
Wie kriege ich das mit AutoIt hin?
Hotkeyset ist kacke, Ispressed geht aber wiederum ist es doof weil man ja nicht weiß ob man im Input ist bzw. sogar im welchen Input man ist.
Wie bekomme ich das hin, aber OHNE Button ?
Im Input Enter anwenden
-
- [ offen ]
-
Freaky -
28. Juni 2010 um 23:57 -
Geschlossen -
Erledigt
-
-
Es ist sehr simpel (geht auch im OnEventModus), aber hier ist erstmal ein Beispiel im GuiGetMsgmode:
Spoiler anzeigen
[autoit]#include <EditConstants.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Enter im Inputfeld", 215, 100)
$Label1 = GUICtrlCreateLabel("EnterCounter:", 8, 8, 69, 17)
$Label2 = GUICtrlCreateLabel("0", 96, 8, 34, 17, $SS_CENTER)
$Input1 = GUICtrlCreateInput("Tippe irgendwas und danach Enter", 8, 40, 193, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$Label3 = GUICtrlCreateLabel("Tippe EXIT und Enter -> Beenden", 16, 72, 165, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###While 1
[/autoit] [autoit][/autoit] [autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Input1
If GUICtrlRead($Input1) = "Exit" Then Exit
GUICtrlSetData($Input1,"")
GUICtrlSetData($Label2,Execute(GUICtrlRead($Label2)+1))EndSwitch
[/autoit]
WEnd -
Wahlweise AdlibRegister und eine Function
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <WinAPI.au3>AdlibRegister("_CheckFocus", 10)
[/autoit] [autoit][/autoit] [autoit]Func _CheckFocus()
[/autoit]
$hControl = GUICtrlGetHandle($Input) ;anpassen
If _WinAPI_GetFocus() = $hControl Then
If _IsPressed('0D') Then
;tu was
EndIf
EndIf
EndFunc -
[autoit]
#include <EditConstants.au3>
[/autoit][autoit][/autoit][autoit]
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 143, 44, 192, 139)
$Input1 = GUICtrlCreateInput("Input1", 8, 8, 121, 21)
$Enter = GUICtrlCreateDummy()
Dim $Array[1][2] = [["{ENTER}", $Enter]]
GUISetAccelerators($Array)
GUISetState(@SW_SHOW)While 1
[/autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Enter
$Ctrl = ControlGetFocus($Form1)
If $Ctrl = "Edit1" Then
$Value = ControlGetText($Form1, "", $Ctrl)
MsgBox(0, "", "Die Eingabe in Input1 war: " & $Value)
EndIf
EndSwitch
WEnd -
Danke euch beiden
Das von XovoxKingdom gefält mir etwas mehr da es weniger Code ist. Aber wenn man mehrfach Enter drücken will dann muss man jedesmal den Inhalt ändern.
Und das von Pingui ist auch recht gut aber wenn ich bei ";tu was" eine msg reinmache und das ok dann mit Enter weg drücke, dann löst er wieder das Enter aus -
Warum nicht einfach so?!
[autoit]$hGUI = GUICreate("")
[/autoit][autoit][/autoit][autoit]
$cInput = GUICtrlCreateInput("",20,20,200,20)
GUISetState()While 1
[/autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $cInput
MsgBox(0,"","Bestätigt!")
EndSwitch
WEnd -
Na dann mach die Funktion halt einfach so:
Spoiler anzeigen
[autoit]Func _CheckFocus()
[/autoit]
$hControl = GUICtrlGetHandle($Input) ;anpassen
If (_WinAPI_GetFocus() = $hControl) And (WinActive($GUI)) Then ;Handle von GUI statt $GUI einsetzen!
If _IsPressed('0D') Then
;tu was
EndIf
EndIf
EndFunc -
OK danke euch allen, habe jetzt einfach das von SEuBo genommen