Ich weiß, dass das nichts besonderes ist aber vielleicht kann ja irgendjemand etwas daraus verwenden.
Ein PIN Pad mit Zeitlimit und einer Wartezeit für die Eingabe. Komplett in GDI+ gezeichnet ohne externe Grafiken.
Spoiler anzeigen
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
$GUIColorBG = 0xFFFFFFFF ;Hintergrundfarbe der GUI
$PadColor = 0xFF000000 ;Farbe der Pads
$PadTextColor = 0xFFFFFFFF ;Farbe des Textes auf den Pads
$ColorActive = 0xFF00FF00 ;Farbe der Pads, wenn aktiviert
$PadSize = 35 ;Größe der Pads
$Space = 5 ;Distanz zwischen den Pads
$GUIWidth = ($Space + $PadSize) * 3 + $Space ;GUI Breite (wird aus Padgröße berechnet)
$GUIHeight = ($Space + $PadSize) * 4 + $Space ;GUI Höhe (wird aus Padgröße berechnet)
$Key = ""
$Pass = "12345" ;Richtiges Passwort
$Timelimit = 20000 ;Zeitlimit für die Eingabe (nach Ablauf schließt sich das Script ordnungsgemäß)
#Region Pad Koordinaten
Dim $aPad[12][3]
$aPad[0][0] = $Space
$aPad[0][1] = $Space
$aPad[0][2] = "1"
$aPad[1][0] = $Space + $PadSize + $Space
$aPad[1][1] = $Space
$aPad[1][2] = "2"
$aPad[2][0] = ($Space + $PadSize) * 2 + $Space
$aPad[2][1] = $Space
$aPad[2][2] = "3"
$aPad[3][0] = $Space
$aPad[3][1] = $Space + $PadSize + $Space
$aPad[3][2] = "4"
$aPad[4][0] = $Space + $PadSize + $Space
$aPad[4][1] = $Space + $PadSize + $Space
$aPad[4][2] = "5"
$aPad[5][0] = ($Space + $PadSize) * 2 + $Space
$aPad[5][1] = $Space + $PadSize + $Space
$aPad[5][2] = "6"
$aPad[6][0] = $Space
$aPad[6][1] = ($Space + $PadSize) * 2 + $Space
$aPad[6][2] = "7"
$aPad[7][0] = $Space + $PadSize + $Space
$aPad[7][1] = ($Space + $PadSize) * 2 + $Space
$aPad[7][2] = "8"
$aPad[8][0] = ($Space + $PadSize) * 2 + $Space
$aPad[8][1] = ($Space + $PadSize) * 2 + $Space
$aPad[8][2] = "9"
$aPad[9][0] = $Space
$aPad[9][1] = ($Space + $PadSize) * 3 + $Space
$aPad[9][2] = "R"
$aPad[10][0] = $Space + $PadSize + $Space
$aPad[10][1] = ($Space + $PadSize) * 3 + $Space
$aPad[10][2] = "0"
$aPad[11][0] = ($Space + $PadSize) * 2 + $Space
$aPad[11][1] = ($Space + $PadSize) * 3 + $Space
$aPad[11][2] = "OK"
#EndRegion Pad Koordinaten
$hWnd = GUICreate("PIN", $GUIWidth, $GUIHeight, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION))
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;Erstellt eine Grafik aus der Clientfläche der GUI
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($GUIWidth, $GUIHeight, $hGraphic) ;Erstellt eine Bitmap aus der Grafik
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;Erstellt eine Grafik die der Bitmap zugeordnet ist
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2) ;Anti-Aliasing
_GDIPlus_GraphicsClear($hGraphic, $GUIColorBG) ;Füllt eine Grafik komplett in einer Farbe
$Brush_Pad = _GDIPlus_BrushCreateSolid($PadColor) ;Erstellt ein Füllobjekt mit einer bestimmten Farbe
$Brush_Pad_Active = _GDIPlus_BrushCreateSolid($ColorActive)
$Brush_Number = _GDIPlus_BrushCreateSolid($PadTextColor)
#Region Schrift
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
#EndRegion Schrift
_DrawPad()
$Estimated_Time = TimerInit() ;Initialisiert das Zeitlimit
While 1
$nMsg = GUIGetMsg(1) ;Wenn Parameter auf 1 ist, dann wird ein Array mit zusätzlichen Infos zurückgegeben
Switch $nMsg[0]
Case $GUI_EVENT_CLOSE
_Exit()
Case $GUI_EVENT_PRIMARYDOWN
For $i = 0 To UBound($aPad, 1) - 1
If $nMsg[3] > $aPad[$i][0] And $nMsg[3] < $aPad[$i][0] + $PadSize And $nMsg[4] > $aPad[$i][1] And $nMsg[4] < $aPad[$i][1] + $PadSize Then _PadEvent($i) ;Überprüft, ob der Mausklick auf ein bestimmtes Pad erfolgt
_DrawPad()
Next
EndSwitch
If Not WinActive($hWnd) Then ;Wenn Fenster nicht aktiv, dann...
While 1
If WinActive($hWnd) Then ;Wenn Fenster wieder aktiv, dann... (Um zu verhindern, dass die GUI übermalt wird)
_DrawPad()
ExitLoop
EndIf
WEnd
EndIf
If TimerDiff($Estimated_Time) > $Timelimit Then ;Überprüft, ob das Zeitlimit erreicht ist
_Exit()
EndIf
WEnd
Func _DrawPad()
_GDIPlus_GraphicsClear($hBuffer, $GUIColorBG) ;Leert den Buffer
For $i = 0 To UBound($aPad, 1) - 1
_GDIPlus_GraphicsFillRect($hBuffer, $aPad[$i][0], $aPad[$i][1], $PadSize, $PadSize, $Brush_Pad) ;Zeichnet ein Pad
$tLayout = _GDIPlus_RectFCreate($aPad[$i][0], $aPad[$i][1], $PadSize, $PadSize) ;Legt das Layout für den Schriftzug fest
$aInfo = _GDIPlus_GraphicsMeasureString($hBuffer, $aPad[$i][2], $hFont, $tLayout, $hFormat) ;Passt das Layout auf die berechnete Größe für den String an
_GDIPlus_GraphicsDrawStringEx($hBuffer, $aPad[$i][2], $hFont, $aInfo[0], $hFormat, $Brush_Number) ;Zeichnet den String auf das Pad
Next
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $GUIWidth, $GUIHeight) ;Zeichnet den Buffer in die GUI Grafik
EndFunc ;==>_DrawPad
Func _PadEvent($iPad)
_GDIPlus_GraphicsFillRect($hBuffer, $aPad[$iPad][0], $aPad[$iPad][1], $PadSize, $PadSize, $Brush_Pad_Active) ;Macht das gleiche wie oben nur mit einer anderen Farbe
$tLayout = _GDIPlus_RectFCreate($aPad[$iPad][0], $aPad[$iPad][1], $PadSize, $PadSize)
$aInfo = _GDIPlus_GraphicsMeasureString($hBuffer, $aPad[$iPad][2], $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hBuffer, $aPad[$iPad][2], $hFont, $aInfo[0], $hFormat, $Brush_Number)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $GUIWidth, $GUIHeight)
Sleep(100) ;Wirkt realistischer
If $aPad[$iPad][2] = "OK" Then ;Wenn OK gedrückt, dann...
If $Key = $Pass Then ;Wenn Passwort richtig, dann...
MsgBox(64, "Info", "Passwort richtig")
_Exit()
Else ;Wenn Passwort falsch, dann...
MsgBox(16, "Fehler", "Passwort falsch")
$Key = ""
$Estimated_Time = TimerInit() ;Zeitlimit wird zurückgesetzt
Return
EndIf
ElseIf $aPad[$iPad][2] = "R" Then ;Wenn Reset gedrückt, dann...
$Key = "" ;Eingegebene Zeichen werden zurückgesetzt
Else ;Wenn irgendwas anderes gedrückt, dann...
$Key &= $aPad[$iPad][2] ;Wert der Gedrückten Taste wird zum String hinzugefügt
EndIf
$t = TimerInit()
Do
Sleep(10)
Until TimerDiff($t) > 1000 Or _IsPressed(01)
EndFunc ;==>_PadEvent
Func _Exit() ;Aufräumen
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BrushDispose($Brush_Number)
_GDIPlus_BrushDispose($Brush_Pad)
_GDIPlus_BrushDispose($Brush_Pad_Active)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit