Hi, ich habe in einer GUI 2 Inputboxen und möchte wissen, welche gerade angeklickt wurde / auf welcher der Fokus liegt. Jemand eine Idee?
Aktiver Inputbox ermitteln
-
- [ offen ]
-
Cheater Dieter -
17. Juli 2011 um 15:23 -
Geschlossen -
Erledigt
-
-
Mit GuiCtrlGetState(handle) dürfte das gehen
-
eigene (AutoIt) Gui?
-
Hi,
ControlGetFocus ermittelt die ID des Controls was den Fokus hat, dann brauchst du nur vergleichen. -
Schnuffel: ja
Sprenger120: ControlGetFocus ("USB-Lock") gibt bei mir iwi immer nichts zurück. Ich weiß nicht, was ich falsch mache... Das ist übriges die Zusammenfassung von AutoIt Window Info:Code
Alles anzeigen>>>> Window <<<< Title: USB-Lock Class: AutoIt v3 GUI Position: 503, 186 Size: 362, 359 Style: 0x94CA0000 ExStyle: 0x00000100 Handle: 0x00000000005E063C >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle:
-
Du kannst über WM_Messages erfahren, was gerade mit Deinen Controls "passiert".
Dazu müssten wir aber ein Script von Dir sehen, damit man das als Beispiel einbauen kann -
Ok, ich poste dann einfach mal einen Scriptausschnitt:
Spoiler anzeigen
[autoit]Global $myGamePadHandle = GPExInitialize()
[/autoit] [autoit][/autoit] [autoit]
Global $myID = 0
$zeitblock = 300 ; Gibt an, wie viele Millisekunden lang das Script nach einer Controllereingabe pausiert wird
$runde = 0$Form1 = GUICreate("USB-Lock", 356, 331, -1, -1)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$Input1 = GUICtrlCreateInput("test", 8, 130, 145, 34, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 202, 130, 145, 34, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Wilkommen im Konfigurationasistenten für Spielecontroller. Bitte drücken", 8, 8, 344, 17)
$Label2 = GUICtrlCreateLabel("Sie einige Tasen auf Ihrem Controller, so dass sich das Eingabefeld mit", 8, 24, 336, 17)
$Label3 = GUICtrlCreateLabel("Punkten füllt. Wiederholen Sie dann Ihre Eingabe. Hinweis: Um", 8, 40, 302, 17)
$Label4 = GUICtrlCreateLabel("Eingabe:", 8, 112, 46, 17)
$Label5 = GUICtrlCreateLabel("Wiederholung:", 204, 112, 73, 17)
$Label6 = GUICtrlCreateLabel("Merken Sie sich die Tastenkombination auf dem Controller gut! Ohne", 8, 184, 328, 17)
$Label7 = GUICtrlCreateLabel("diese können Sie Ihren PC später nicht entsperren. Entfernen Sie dann", 8, 200, 338, 17)
$Label8 = GUICtrlCreateLabel("den Controller um sicherzustellen, dass niemand durch bloses", 8, 216, 292, 17)
$Label9 = GUICtrlCreateLabel("Ausprobieren von Tastenkombinationen Ihren PC entsperren kann.", 8, 232, 322, 17)
$Label10 = GUICtrlCreateLabel("Bitte geben Sie nichts von der Tastatur aus ein! Falls Sie keine Eingaben", 8, 56, 350, 17)
$Label11 = GUICtrlCreateLabel("täigen können, wird Ihr Controller leider nicht unterstützt. Sperren Sie", 8, 72, 350, 17)
$Label12 = GUICtrlCreateLabel("Ihren PC dann doch einfach per USB-Stick.", 8, 88, 450, 17)
$Button1 = GUICtrlCreateButton("Sperren (ich habe mir die Tastenkombination gemerkt)", 9, 256, 337, 33, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Eingabefelder leeren", 77, 296, 201, 25, $WS_GROUP)
GUISetState(@SW_SHOW)While 1
[/autoit] [autoit][/autoit] [autoit]
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
GUIDelete ()
Start ()
EndIfIf $msg = $Button1 Then
[/autoit] [autoit][/autoit] [autoit]
$tke = GUICtrlRead ($Input1)
$tkwdh = GUICtrlRead ($Input2)
If $tke <> $tkwdh Then
MsgBox (16,"USB-Lock","Die beiden eingegebenen Tastenkombinationen stimmen nicht überein.")
Else
ExitLoop
EndIf
EndIfIf $msg = $Button2 Then
[/autoit] [autoit][/autoit] [autoit]
GUIDelete ()
controller ()
Return 0
EndIf$pressedbutton = GPExGetPressed($myGamePadHandle, $myID)
[/autoit] [autoit][/autoit] [autoit]
Select
Case BitAND($pressedbutton, GPExButton(1))
Send ("1")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(2))
Send ("2")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(3))
Send ("3")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(4))
Send ("4")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(5))
Send ("5")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(6))
Send ("6")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(7))
Send ("7")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(8))
Send ("8")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(9))
Send ("9")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(10))
Send ("10")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(11))
Send ("11")
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(12))
Send ("12")
Sleep ($zeitblock)
EndSelectWEnd
[/autoit]
Ich möchte also wissen, welche Inputbox gerade angeklickt wurde und in welche per Controller "gesendet" wird, um dann später per GUICtrlSetData($DasInputfeld, 'Die jeweilige Zahl') statt mit Send die Eingaben zu tätigen.Achja, und hier die notwendige Include:
Spoiler anzeigen
[autoit]; #INDEX# =======================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Title .........: GamePadEx UDF
; UDF Version ...: 1.00
; AutoIt Version : 3.3.6.1 (Not tested on previous versions
; Language ......: English
; Description ...: Functions for receiving GamePad (almost any) inputs
; Author(s) .....: Shafayat <bitventure.x10.mx>
; Gratitude .....: Various people (or their code) influenced this UDF. They are - (from last to first)
; 1. Nologic
; 2. Adam1213
; 3. Ejoc, Monamo
; License .......: Freeware/Opensource
; ===============================================================================================================================; #CURRENT# =====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
;GPExInitialize
;GPExTerminate
;GPExButton
;GPExSwapButtons
;GPExGetPressed
;GPExGetAxis
;GPExGetAxisEx
;GPExGetPOV
;GPExGetPOVDirection
;GPExGetRawData
;GPExDebugEnable
;GPExDebugDisable
;GPExDebug
; ===============================================================================================================================; #INTERNAL_USE_ONLY# ===========================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; ___GPExDebugAuto() ; Basically an Adlib
; ===============================================================================================================================; #INCLUDES# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; #include "Array.au3" - I used this only for testing. Not required.
; ===============================================================================================================================; #GLOBAL VARS# =================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Do not bother. You'll never need to use these variables in your script.
Global $___GPExButtonsArray[13] = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
Global $___GPExAdlibParams[2] = [0, 0]
; ===============================================================================================================================; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExInitialize
; Description ...: Initialize and Return Handle to the GamePadEx Inputs
; Return values .: Success - Handle to the GamePad Inputs
; Failure - 0
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExInitialize()
Local $joy
Local $JOYINFOEX_struct = "dword[13]"
$joy = DllStructCreate($JOYINFOEX_struct)
If @error Then Return 0
DllStructSetData($joy, 1, DllStructGetSize($joy), 1) ; dwSize = sizeof(struct)
DllStructSetData($joy, 1, 255, 2) ; dwFlags = GetAll
Return $joy
EndFunc ;==>GPExInitialize; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExTerminate
; Description ...: Removes Handle to the GamePadEx Inputs
; Return values .: True
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExTerminate(ByRef $givenhandle)
$givenhandle = 0
Return True
EndFunc ;==>GPExTerminate; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExButton
; Description ...: Get the nth Button's Code Number.
; Parameters ....: $ButtonNumber - A number between 1 to 12.
; Return values .: Success - nth Button's Code Number
; Failure - -1
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExButton($ButtonNumber)
If $ButtonNumber > 0 & $ButtonNumber < 13 Then
Return $___GPExButtonsArray[$ButtonNumber]
Else
Return -1
EndIf
EndFunc ;==>GPExButton; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExSwapButtons
; Description ...: Swap 2 buttons. Good for a GamePad that uses UnOrthobox button placement.
; Parameters ....: $Button1Number - A number between 1 to 12.
; $Button2Number - A number between 1 to 12.
; Return values .: Success - 1
; Failure - -1
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExSwapButtons($Button1Number, $Button2Number)
If $Button1Number > 0 And $Button1Number < 13 And $Button2Number > 0 And $Button2Number < 13 Then
Local $b1
$b1 = $___GPExButtonsArray[$Button1Number]
$___GPExButtonsArray[$Button1Number] = $___GPExButtonsArray[$Button2Number]
$___GPExButtonsArray[$Button2Number] = $b1
Return 1
Else
Return -1
EndIf
EndFunc ;==>GPExSwapButtons; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetPressed
; Description ...: Get the pressed button code.
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: Button Code.
; Remarks .......: Use BitAnd to find out if multiple buttons are pressed. (try the example)
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetPressed($tempHandle, $tempID)
Local $tempArray = GPExGetRawData($tempHandle, $tempID)
Return $tempArray[7]
EndFunc ;==>GPExGetPressed; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetAxis
; Description ...: Get the Orientation of Axis
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; $tempAxis - The Axis, of which the value has to be returned.
; Return values .: Success - Orientation of Axis. from 0 to 65535
; Failure - -1
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetAxis($tempHandle, $tempID, $tempAxis)
Local $tempArray = GPExGetRawData($tempHandle, $tempID)
Switch $tempAxis
Case "X"
Return $tempArray[0]
Case "Y"
Return $tempArray[1]
Case "Z"
Return $tempArray[2]
Case "R"
Return $tempArray[3]
Case "U"
Return $tempArray[4]
Case "V"
Return $tempArray[5]
Case Else
Return -1
EndSwitch
EndFunc ;==>GPExGetAxis; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetAxisEx
; Description ...: Get the Orientation of Axis and more details.
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; $tempAxis - The Axis, of which the value has to be returned.
; $tolerance - Tolerance means the Threshold of orientation to be ignored.
; Return values .: Success - An Array.
; [0] - Raw data (same as GPExGetAxis)
; [1] - Direction with Zero as Middle Point. (Left < 0, Middle = 0, Right > 0 etc..)
; [2] - Percentage of Orientation. Very useful when trying to find out how much the Radars Tilted.
; Failure - -1
; Remarks .......: Higher values of Tolerance will make GamePad a less responsive/sensitive.
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetAxisEx($tempHandle, $tempID, $tempAxis, $tolerance = 6000)
If $tolerance > 65535 / 2 Or $tolerance < -65535 / 2 Then Return -2
Local $tempArray = GPExGetRawData($tempHandle, $tempID)
Local $tempArray2[3] = [0, 0, 0]
Switch $tempAxis
Case "X"
$tempArray2[0] = $tempArray[0]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case "Y"
$tempArray2[0] = $tempArray[1]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case "Z"
$tempArray2[0] = $tempArray[2]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case "R"
$tempArray2[0] = $tempArray[3]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case "U"
$tempArray2[0] = $tempArray[4]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case "V"
$tempArray2[0] = $tempArray[5]
$tempArray2[1] = $tempArray2[0] - 65535 / 2
If $tolerance > $tempArray2[1] And $tolerance * (-1) < $tempArray2[1] Then $tempArray2[1] = 0
$tempArray2[2] = Abs($tempArray2[0] - 65535 / 2) / (65535 / 2) * 100
Case Else
Return -1
EndSwitch
Return $tempArray2
EndFunc ;==>GPExGetAxisEx; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetPOV
; Description ...: Get the Point of View as Raw Data.
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: POV Data
; Remarks .......: POV is the Eight directional buttons on the Gamepad
; 65535 = Not pressed
; 0 = Up
; 4500 = Up-Right
; 9000 = Right
; Goes around clockwise increasing 4500 for each position.
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetPOV($tempHandle, $tempID)
Local $tempArray = GPExGetRawData($tempHandle, $tempID)
Return $tempArray[6]
EndFunc ;==>GPExGetPOV; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetPOVDirection
; Description ...: Get the Point of View as Directions.
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: POV Directions.
; Blank string - Not pressed
; U = Up
; UR = Up-Right
; R..
; DR..
; D..
; DL..
; L..
; UL..
; Remarks .......: POV is the Eight directional buttons on the Gamepad
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetPOVDirection($tempHandle, $tempID)
Local $tempArray = GPExGetRawData($tempHandle, $tempID)
Switch $tempArray[6]
Case 4500 * 0
Return "U"
Case 4500 * 1
Return "UR"
Case 4500 * 2
Return "R"
Case 4500 * 3
Return "DR"
Case 4500 * 4
Return "D"
Case 4500 * 5
Return "DL"
Case 4500 * 6
Return "L"
Case 4500 * 7
Return "UL"
Case 65535
Return ""
EndSwitch
EndFunc ;==>GPExGetPOVDirection; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExGetRawData
; Description ...: Returns Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos, POV and Pressed Button(s)
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos, POV and Pressed Button(s)
; Remarks .......: Try the Samples provided.
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExGetRawData($tempHandle, $tempID)
Local $coor
Dim $coor[8]
DllCall("Winmm.dll", "int", "joyGetPosEx", _
"int", $tempID, "ptr", DllStructGetPtr($tempHandle))
If Not @error Then
$coor[0] = DllStructGetData($tempHandle, 1, 3) ; X Axis
$coor[1] = DllStructGetData($tempHandle, 1, 4) ; Y Axis
$coor[2] = DllStructGetData($tempHandle, 1, 5) ; Z Axis
$coor[3] = DllStructGetData($tempHandle, 1, 6) ; R Axis
$coor[4] = DllStructGetData($tempHandle, 1, 7) ; U Axis
$coor[5] = DllStructGetData($tempHandle, 1, ; V Axis
$coor[6] = DllStructGetData($tempHandle, 1, 11) ; POV Value
$coor[7] = DllStructGetData($tempHandle, 1, 9) ; Buttons Mask
EndIf
Return $coor
EndFunc ;==>GPExGetRawData; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExDebugEnable
; Description ...: Start Debugging
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: True
; Remarks .......: Try the Samples provided.
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExDebugEnable($myGamePadHandle, $tempID)
$___GPExAdlibParams[0] = $myGamePadHandle
$___GPExAdlibParams[1] = $tempID
AdlibRegister("___GPExDebugAuto", 100)
Return True
EndFunc ;==>GPExDebugEnable; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: GPExDebugDisable
; Description ...: Stop Debugging
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: True
; Remarks .......: Try the Samples provided.
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExDebugDisable($myGamePadHandle, $tempID)
If $tempID = $___GPExAdlibParams[1] Then
$___GPExAdlibParams[0] = 0
$___GPExAdlibParams[1] = 0
AdlibUnRegister("___GPExDebugAuto")
Return True
EndIf
EndFunc ;==>GPExDebugDisableFunc ___GPExDebugAuto()
[/autoit] [autoit][/autoit] [autoit]
$myGamePadHandle = $___GPExAdlibParams[0]
$tempID = $___GPExAdlibParams[1]
Local $GamePad_1 = GPExGetRawData($myGamePadHandle, $tempID)
ConsoleWrite(@CRLF & "=======================================")
ConsoleWrite(@CRLF & "BUTTON PRESS {" & $GamePad_1[7] & "}")
ConsoleWrite(@CRLF & "X,Y AXIS {" & $GamePad_1[0] & " , " & $GamePad_1[1] & "}")
ConsoleWrite(@CRLF & "Z,R AXIS {" & $GamePad_1[2] & " , " & $GamePad_1[3] & "}")
ConsoleWrite(@CRLF & "U,X AXIS {" & $GamePad_1[4] & " , " & $GamePad_1[5] & "}")
ConsoleWrite(@CRLF & "POV {" & $GamePad_1[6] & "}")
ConsoleWrite(@CRLF & "=======================================")
EndFunc ;==>___GPExDebugAuto; #FUNCTION# ====================================================================================================================
[/autoit]
; Name...........: GPExDebug
; Description ...: Manual Debugging to Console
; Parameters ....: $tempHandle - Handle from GPExInitialize
; $tempID - ID of gamepad. (use 0 for the default one)
; Return values .: True
; Author ........: Same as Header
; ==============================================================================================================================
Func GPExDebug($myGamePadHandle, $tempID)
Local $GamePad_1 = GPExGetRawData($myGamePadHandle, $tempID)
ConsoleWrite(@CRLF & "=======================================")
ConsoleWrite(@CRLF & "BUTTON PRESS {" & $GamePad_1[7] & "}")
ConsoleWrite(@CRLF & "X,Y AXIS {" & $GamePad_1[0] & " , " & $GamePad_1[1] & "}")
ConsoleWrite(@CRLF & "Z,R AXIS {" & $GamePad_1[2] & " , " & $GamePad_1[3] & "}")
ConsoleWrite(@CRLF & "U,X AXIS {" & $GamePad_1[4] & " , " & $GamePad_1[5] & "}")
ConsoleWrite(@CRLF & "POV {" & $GamePad_1[6] & "}")
ConsoleWrite(@CRLF & "=======================================")
Return True
EndFunc ;==>GPExDebug -
mal als Beispiel...
mit Strg-a wird der Status der Inputs geprüft ...Spoiler anzeigen
[autoit]HotKeySet("^a",'_nurzumTest')
[/autoit] [autoit][/autoit] [autoit]
Global $myID = 0
$zeitblock = 300 ; Gibt an, wie viele Millisekunden lang das Script nach einer Controllereingabe pausiert wird
$runde = 0$Form1 = GUICreate("USB-Lock", 356, 331, -1, -1)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$Input1 = GUICtrlCreateInput("test", 8, 130, 145, 34);, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 202, 130, 145, 34);, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Wilkommen im Konfigurationasistenten für Spielecontroller. Bitte drücken", 8, 8, 344, 17)
$Label2 = GUICtrlCreateLabel("Sie einige Tasen auf Ihrem Controller, so dass sich das Eingabefeld mit", 8, 24, 336, 17)
$Label3 = GUICtrlCreateLabel("Punkten füllt. Wiederholen Sie dann Ihre Eingabe. Hinweis: Um", 8, 40, 302, 17)
$Label4 = GUICtrlCreateLabel("Eingabe:", 8, 112, 46, 17)
$Label5 = GUICtrlCreateLabel("Wiederholung:", 204, 112, 73, 17)
$Label6 = GUICtrlCreateLabel("Merken Sie sich die Tastenkombination auf dem Controller gut! Ohne", 8, 184, 328, 17)
$Label7 = GUICtrlCreateLabel("diese können Sie Ihren PC später nicht entsperren. Entfernen Sie dann", 8, 200, 338, 17)
$Label8 = GUICtrlCreateLabel("den Controller um sicherzustellen, dass niemand durch bloses", 8, 216, 292, 17)
$Label9 = GUICtrlCreateLabel("Ausprobieren von Tastenkombinationen Ihren PC entsperren kann.", 8, 232, 322, 17)
$Label10 = GUICtrlCreateLabel("Bitte geben Sie nichts von der Tastatur aus ein! Falls Sie keine Eingaben", 8, 56, 350, 17)
$Label11 = GUICtrlCreateLabel("täigen können, wird Ihr Controller leider nicht unterstützt. Sperren Sie", 8, 72, 350, 17)
$Label12 = GUICtrlCreateLabel("Ihren PC dann doch einfach per USB-Stick.", 8, 88, 450, 17)
$Button1 = GUICtrlCreateButton("Sperren (ich habe mir die Tastenkombination gemerkt)", 9, 256, 337, 33);, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Eingabefelder prüfen", 77, 296, 201, 25);, $WS_GROUP)
GUISetState(@SW_SHOW)While 1
[/autoit] [autoit][/autoit] [autoit]
$msg = GUIGetMsg()
If $msg = -3 Then
Exit
EndIfIf $msg = $Button1 Then
[/autoit] [autoit][/autoit] [autoit]
$tke = GUICtrlRead ($Input1)
$tkwdh = GUICtrlRead ($Input2)
If $tke <> $tkwdh Then
MsgBox (16,"USB-Lock","Die beiden eingegebenen Tastenkombinationen stimmen nicht überein.")
Else
ExitLoop
EndIf
EndIfWEnd
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _nurzumTest()
[/autoit]
Switch ControlGetFocus($Form1); hier den Variablennamen der GUI eintragen
Case 'Edit1'
MsgBox(0, '', 'Den Fokus hat der 1. Input')
Case 'Edit2'
MsgBox(0, '', 'Den Fokus hat der 2. Input')
EndSwitch
EndFunc -
Danke!!!!
-
Eine Frage noch: Was ist denn da jetzt schon wieder falsch? Ich kann eine Taste aus dem Controller drücken und das war es dann auch.
Spoiler anzeigen
[autoit]Global $myGamePadHandle = GPExInitialize() ; Get a handle. This doesn't have to be global but needs to be passed to all the other functions.
[/autoit] [autoit][/autoit] [autoit]
Global $myID = 0 ; We want to monitor the default GamePad
$zeitblock = 300 ; Gibt an, wie viele Millisekunden lang das Script nach einer Controllereingabe pausiert wird
$runde = 0$controllergui = GUICreate("USB-Lock", 356, 331, -1, -1)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$Input1 = GUICtrlCreateInput("test", 8, 130, 145, 34, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 202, 130, 145, 34, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 17, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Wilkommen im Konfigurationasistenten für Spielecontroller. Bitte drücken", 8, 8, 344, 17)
$Label2 = GUICtrlCreateLabel("Sie einige Tasen auf Ihrem Controller, so dass sich das Eingabefeld mit", 8, 24, 336, 17)
$Label3 = GUICtrlCreateLabel("Punkten füllt. Wiederholen Sie dann Ihre Eingabe. Hinweis: Um", 8, 40, 302, 17)
$Label4 = GUICtrlCreateLabel("Eingabe:", 8, 112, 46, 17)
$Label5 = GUICtrlCreateLabel("Wiederholung:", 204, 112, 73, 17)
$Label6 = GUICtrlCreateLabel("Merken Sie sich die Tastenkombination auf dem Controller gut! Ohne", 8, 184, 328, 17)
$Label7 = GUICtrlCreateLabel("diese können Sie Ihren PC später nicht entsperren. Entfernen Sie dann", 8, 200, 338, 17)
$Label8 = GUICtrlCreateLabel("den Controller um sicherzustellen, dass niemand durch bloses", 8, 216, 292, 17)
$Label9 = GUICtrlCreateLabel("Ausprobieren von Tastenkombinationen Ihren PC entsperren kann.", 8, 232, 322, 17)
$Label10 = GUICtrlCreateLabel("Bitte geben Sie nichts von der Tastatur aus ein! Falls Sie keine Eingaben", 8, 56, 350, 17)
$Label11 = GUICtrlCreateLabel("täigen können, wird Ihr Controller leider nicht unterstützt. Sperren Sie", 8, 72, 350, 17)
$Label12 = GUICtrlCreateLabel("Ihren PC dann doch einfach per USB-Stick.", 8, 88, 450, 17)
$Button1 = GUICtrlCreateButton("Sperren (ich habe mir die Tastenkombination gemerkt)", 9, 256, 337, 33, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Eingabefelder leeren", 77, 296, 201, 25, $WS_GROUP)
GUISetState(@SW_SHOW)While 1
[/autoit] [autoit][/autoit] [autoit]If ControlGetFocus($controllergui) = 'Edit1' Then
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$aktiv = $Input1
EndIfIf ControlGetFocus($controllergui) = 'Edit2' Then
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$aktiv = $Input2
EndIf$msg = GUIGetMsg()
[/autoit] [autoit][/autoit] [autoit]
If $msg = $GUI_EVENT_CLOSE Then
GUIDelete ()
Start ()
EndIfIf $msg = $Button1 Then
[/autoit] [autoit][/autoit] [autoit]
$tke = GUICtrlRead ($Input1)
$tkwdh = GUICtrlRead ($Input2)
If $tke <> $tkwdh Then
MsgBox (16,"USB-Lock","Die beiden eingegebenen Tastenkombinationen stimmen nicht überein.")
Else
ExitLoop
EndIf
EndIfIf $msg = $Button2 Then
[/autoit] [autoit][/autoit] [autoit]
GUIDelete ()
controller ()
Return 0
EndIf$pressedbutton = GPExGetPressed($myGamePadHandle, $myID)
[/autoit] [autoit][/autoit] [autoit]
Select
Case BitAND($pressedbutton, GPExButton(1))
GUICtrlSetData ($aktiv,1)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(2))
GUICtrlSetData ($aktiv,2)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(3))
GUICtrlSetData ($aktiv,3)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(4))
GUICtrlSetData ($aktiv,4)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(5))
GUICtrlSetData ($aktiv,5)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(6))
GUICtrlSetData ($aktiv,6)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(7))
GUICtrlSetData ($aktiv,7)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(8))
GUICtrlSetData ($aktiv,8)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(9))
GUICtrlSetData ($aktiv,9)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(10))
GUICtrlSetData ($aktiv,10)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(11))
GUICtrlSetData ($aktiv,11)
Sleep ($zeitblock)
Case BitAND($pressedbutton, GPExButton(12))
GUICtrlSetData ($aktiv,12)
Sleep ($zeitblock)
EndSelectWEnd
[/autoit]