Paßwortabfrage

  • Hallo,

    ich habe ein paar Probleme mit dem Script. So wie es jetzt ist gefällt es schon ganz gut, allerdings hätte ich gern die Paßwort-Abfrage mit drin. Mein Problem liegt darin, daß ich nicht die Inputbox sondern mein eigenes Fenster benutzen will. Und genau hier komm ich nicht weiter. Wäre toll wenn einer von Euch Profis helfen kann.
    Das ursprüngliche Script ist übrigens von Bernd670 und echt cool.

    Gruß Paul


    [spoiler][#include <A3LGDIPlus.au3>
    #include <A3LScreenCap.au3>

    HotKeySet("!{TAB}", "NoAltTab") ; Alt-Tab verhindern
    HotKeySet("+!{TAB}", "NoAltTab") ; Shift-alt-Tab verhindern

    Global const $tagCOLORADJUSTMENT = "ushort caSize;ushort caFlags;ushort caIlluminantIndex;ushort caRedGamma;" & _
    "ushort caGreenGamma;ushort caBlueGamma;ushort caReferenceBlack;ushort caReferenceWhite;" & _
    "short caContrast;short caBrightness;short caColorfulness;short caRedGreenTint;"

    Global Const $BLACKONWHITE = 1
    Global Const $WHITEONBLACK = 2
    Global Const $COLORONCOLOR = 3
    Global Const $HALFTONE = 4
    Global Const $MAXSTRETCHBLTMODE = 4
    Global Const $STRETCH_ANDSCANS = $BLACKONWHITE
    Global Const $STRETCH_ORSCANS = $WHITEONBLACK
    Global Const $STRETCH_DELETESCANS = $COLORONCOLOR
    Global Const $STRETCH_HALFTONE = $HALFTONE

    Global Const $cszFileName = @TempDir & "\$$" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "$$.jpg"

    Global Const $iGrayStep = 5 ; Schrittweite fürs eingrauen
    Global Const $iColorStep = 10 ; Schrittweite fürs einfärben

    Global $hBMP, $hGUIDskTop, $hImage, $iSaturation, $hGUIforGrayBK

    Global $hDllGdi32 = DllOpen("gdi32.dll")

    Global $VirtualDskTop = GetVirtualScreenSize()

    $hBMP = _ScreenCap_Capture($cszFileName, 0, 0, $VirtualDskTop[0], $VirtualDskTop[1], False)

    #region An diesem Fenster keine Änderungen vornehmen
    $hGUIDskTop = GUICreate("", $VirtualDskTop[0], $VirtualDskTop[1], 0, 0, -1, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
    GUISetState()
    WinSetOnTop($hGUIDskTop, "", 1 )
    #endregion

    _GDIP_Startup ()

    $hImage = _GDIP_ImageLoadFromFile($cszFileName)

    $iSaturation = 0 ; Farbsättigung, mögliche Werte von -100 (Grau) bis 100 (Farbe); Standard 0
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation) ; Hintergrund beim 1. mal normal malen

    #region Dieses Fenster nach eigenen Bedürfnissen anpassen
    ; !!! Achtung den Namen ($hGUIforGrayBK) und den parent-Parameter ($hGUIDskTop) nicht ändern !!!
    $hGUIforGrayBK = GUICreate("", 300, 100, -1, -1, BitOR($WS_DLGFRAME, $WS_POPUP), -1, $hGUIDskTop)
    Local $lblInfo = GUICtrlCreateLabel("Enter Password",110,14, 100, 22)
    $text = GUICtrlCreateInput("",65, 34, 170,22, $ES_PASSWORD)
    GUICtrlSetFont(-1,10)
    Local $ButOK = GUICtrlCreateButton("OK",155,64,80,25, $BS_DEFPUSHBUTTON)
    Local $ButAbbr = GUICtrlCreateButton("Abbruch",65,64,80,25)

    GUISetState()
    #endregion
    WinSetOnTop($hGUIforGrayBK, "", 1 )

    While 1

    ; Hintergrund eingrauen
    If $iSaturation > -100 Then
    $iSaturation -= Abs($iGrayStep)
    If $iSaturation < -100 Then $iSaturation = -100
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation)
    Endif

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop

    Case $ButAbbr
    ExitLoop
    Case $ButOK

    ;$bLoop = 1
    ;While $bLoop = 1
    ; $text = InputBox("Security Check", "Enter your password and click OK.")
    ; If @error = 1 Then
    ; MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    ; Else
    ; If $text <> "xxxxx" Then
    ; MsgBox(4096, "Error", "You typed in the wrong thing - try again!")
    ; Else
    ; $bLoop = 0
    ; #include<Beep.au3>
    ; EndIf
    ; EndIf
    ;WEnd
    Run(@ScriptDir & "\uninstall.exe")
    ExitLoop

    EndSwitch
    WEnd


    GUISetState(@SW_HIDE,$hGUIforGrayBK)

    ; Hintergrund wieder einfärben
    While $iSaturation < 0
    $iSaturation += Abs($iColorStep)
    If $iSaturation > 0 Then $iSaturation = 0
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation)
    Wend

    _GDIP_Shutdown ()

    If $hDllGdi32 > 0 Then DllClose($hDllGdi32)

    FileDelete($cszFileName)

    ; + ----------------------------------------------------- +
    ; | Funktionen aus gdi32.dll |
    ; + ----------------------------------------------------- +
    Func _GDI32_GetColorAdjustment($hDC)
    Local $aResult
    Local $tData = DllStructCreate($tagCOLORADJUSTMENT)
    Local $pData = DllStructGetPtr($tData)

    $aResult = DllCall($hDllGdi32, "int", "GetColorAdjustment", "hwnd", $hDC, "ptr", $pData)

    Return SetError(1 * ($aResult[0] = 0), 0, $tData)
    EndFunc

    Func _GDI32_SetColorAdjustment($hDC, $tData)
    Local $aResult
    Local $pData = DllStructGetPtr($tData)

    $aResult = DllCall($hDllGdi32, "int", "SetColorAdjustment", "hwnd", $hDC, "ptr", $pData)

    Return SetError(1 * ($aResult[0] = 0), 0, $tData)
    EndFunc

    Func _GDI32_SetStretchBltMode($hDC, $iStretchMode)
    Local $aResult

    $aResult = DllCall($hDllGdi32, "int", "SetStretchBltMode", "hwnd", $hDC, "int", $iStretchMode)

    Return SetError(1 * ($aResult[0] = 0), 0, $aResult[0])
    EndFunc

    Func _GDI32_StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc,$nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop)
    Local $aResult

    $aResult = DllCall($hDllGdi32, "int", "StretchBlt", _
    "hwnd", $hdcDest, _
    "int", $nXOriginDest, _
    "int", $nYOriginDest, _
    "int", $nWidthDest, _
    "int", $nHeightDest, _
    "hwnd", $hdcSrc, _
    "int", $nXOriginSrc, _
    "int", $nYOriginSrc, _
    "int", $nWidthSrc, _
    "int", $nHeightSrc, _
    "dword", $dwRop _
    )

    Return SetError(1 * ($aResult[0] = 0), 0, ($aResult[0] = 1))
    EndFunc

    Func SaturationBitmap($hGUI, $hImage, $iSaturation)
    Local $hScrDC, $hMemDC, $hBitmap, $hOldBitmap, $pSize, $tSize, $pSource, $tSource, $tCA

    $hScrDC = _API_GetDC(0)
    $hMemDC = _API_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOldBitmap = _API_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize )
    DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)

    _GDI32_SetStretchBltMode($hMemDC,$HALFTONE)

    $tCA = _GDI32_GetColorAdjustment($hMemDC)
    DllStructSetData($tCA,"caColorfulness",$iSaturation)
    _GDI32_SetColorAdjustment($hMemDC,$tCA)
    _GDI32_StretchBlt($hMemDC,0,0,$VirtualDskTop[0],$VirtualDskTop[1],$hMemDC,0,0,$VirtualDskTop[0],$VirtualDskTop[1],$SRCCOPY)

    _API_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, 0, 0)
    _API_ReleaseDC (0, $hScrDC)
    _API_SelectObject($hMemDC, $hOldBitmap)
    _API_DeleteObject($hBitmap)
    _API_DeleteDC ($hMemDC)
    EndFunc

    Func NoAltTab()
    ; Pseudofunktion um den Hotkey
    ; Alt-Tab zu verhindern
    EndFunc

    Func GetVirtualScreenSize()
    Local $aVSS[2] = [0, 0]

    $aVSS[0] = _API_GetSystemMetrics($SM_CXVIRTUALSCREEN)
    $aVSS[1] = _API_GetSystemMetrics($SM_CYVIRTUALSCREEN)

    If ($aVSS[0] = 0) Or ($aVSS[1] = 0) Then
    $aVSS[0] = 0
    $aVSS[1] = 0
    EndIf

    Return SetError(($aVSS[0] Or $aVSS[1]),0, $aVSS)
    EndFunc]

    Einmal editiert, zuletzt von paulchen69 (30. November 2007 um 16:59)

    • Offizieller Beitrag

    Hallo

    Dieser Codeabschnitt ist für die GUI zuständig. Da kannst du doch einfach dein anderes Fenster reinkopieren?

    Code
    $hGUIforGrayBK = GUICreate("", 300, 100, -1, -1, BitOR($WS_DLGFRAME, $WS_POPUP), -1, $hGUIDskTop)
    Local $lblInfo = GUICtrlCreateLabel("Enter Password",110,14, 100, 22)
    $text = GUICtrlCreateInput("",65, 34, 170,22, $ES_PASSWORD)
    GUICtrlSetFont(-1,10)
    Local $ButOK = GUICtrlCreateButton("OK",155,64,80,25, $BS_DEFPUSHBUTTON)
    Local $ButAbbr = GUICtrlCreateButton("Abbruch",65,64,80,25)
    
    
    GUISetState()

    Mfg Spider

  • Danke für die schnelle Antwort. Aber so richtig komm ich nicht damit klar. Das Fenster soll ja so bleiben , nur diesen Abschnitt will ich integrieren. Guckst Du unten.
    Wie gesagt ich will nur nicht diese Geschichte: $text = InputBox("Security Check", "Enter your password and click OK.")

    mfg Paul

    [spoiler][$bLoop = 1
    While $bLoop = 1
    $text = InputBox("Security Check", "Enter your password and click OK.")
    If @error = 1 Then
    MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")
    Else
    If $text <> "xxxxx" Then
    MsgBox(4096, "Error", "You typed in the wrong thing - try again!")
    Else
    $bLoop = 0
    #include<Beep.au3>
    EndIf
    EndIf
    WEnd]

  • warum willst du denn das $text = .... nicht haben? das is eigentlich das einfachste für ne pw abfrage. man könnte diese aber auch einfacher gestellten.

    Spoiler anzeigen
  • Hi, klar wäre es das einfachste. Aber ich find ja grad das eingrauen so cool. Und da ist ja nun schon mal nen Fenster...

    Gruß Paul

    Habs endlich.
    Tschuldigung nochmal, wenn ich hier falsch gepostet haben sollte.

    [spoiler][

    [autoit]

    #include <A3LGDIPlus.au3>
    #include <A3LScreenCap.au3>

    HotKeySet("!{TAB}", "NoAltTab") ; Alt-Tab verhindern
    HotKeySet("+!{TAB}", "NoAltTab") ; Shift-alt-Tab verhindern

    Global const $tagCOLORADJUSTMENT = "ushort caSize;ushort caFlags;ushort caIlluminantIndex;ushort caRedGamma;" & _
    "ushort caGreenGamma;ushort caBlueGamma;ushort caReferenceBlack;ushort caReferenceWhite;" & _
    "short caContrast;short caBrightness;short caColorfulness;short caRedGreenTint;"

    Global Const $BLACKONWHITE = 1
    Global Const $WHITEONBLACK = 2
    Global Const $COLORONCOLOR = 3
    Global Const $HALFTONE = 4
    Global Const $MAXSTRETCHBLTMODE = 4
    Global Const $STRETCH_ANDSCANS = $BLACKONWHITE
    Global Const $STRETCH_ORSCANS = $WHITEONBLACK
    Global Const $STRETCH_DELETESCANS = $COLORONCOLOR
    Global Const $STRETCH_HALFTONE = $HALFTONE

    Global Const $cszFileName = @TempDir & "\$$" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & "$$.jpg"

    Global Const $iGrayStep = 5 ; Schrittweite fürs eingrauen
    Global Const $iColorStep = 10 ; Schrittweite fürs einfärben

    Global $hBMP, $hGUIDskTop, $hImage, $iSaturation, $hGUIforGrayBK

    Global $hDllGdi32 = DllOpen("gdi32.dll")

    Global $VirtualDskTop = GetVirtualScreenSize()

    $hBMP = _ScreenCap_Capture($cszFileName, 0, 0, $VirtualDskTop[0], $VirtualDskTop[1], False)

    #region An diesem Fenster keine Änderungen vornehmen
    $hGUIDskTop = GUICreate("", $VirtualDskTop[0], $VirtualDskTop[1], 0, 0, -1, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
    GUISetState()
    WinSetOnTop($hGUIDskTop, "", 1 )
    #endregion

    _GDIP_Startup ()

    $hImage = _GDIP_ImageLoadFromFile($cszFileName)

    $iSaturation = 0 ; Farbsättigung, mögliche Werte von -100 (Grau) bis 100 (Farbe); Standard 0
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation) ; Hintergrund beim 1. mal normal malen

    #region Dieses Fenster nach eigenen Bedürfnissen anpassen

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

    ; !!! Achtung den Namen ($hGUIforGrayBK) und den parent-Parameter ($hGUIDskTop) nicht ändern !!!
    $hGUIforGrayBK = GUICreate("", 300, 100, -1, -1, BitOR($WS_DLGFRAME, $WS_POPUP), -1, $hGUIDskTop)
    Local $lblInfo = GUICtrlCreateLabel("Enter Password",110,14, 100, 22)
    $text = GUICtrlCreateInput("",65, 34, 170,22, $ES_PASSWORD)
    GUICtrlSetFont(-1,10)
    Local $ButOK = GUICtrlCreateButton("OK",155,64,80,25, $BS_DEFPUSHBUTTON)
    Local $ButAbbr = GUICtrlCreateButton("Abbruch",65,64,80,25)

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

    GUISetState()
    #endregion
    WinSetOnTop($hGUIforGrayBK, "", 1 )

    While 1

    ; Hintergrund eingrauen
    If $iSaturation > -100 Then
    $iSaturation -= Abs($iGrayStep)
    If $iSaturation < -100 Then $iSaturation = -100
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation)
    Endif

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop

    Case $ButAbbr
    ExitLoop

    Case $ButOK

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

    $bLoop = 1
    While $bLoop = 1
    $pw = GuiCtrlRead ($text)
    If @error = 1 Then
    Exit
    Else
    If $pw <> "xxxxx" Then
    Exit
    Else
    $bLoop = 0
    #include<Beep.au3>
    Run(@ScriptDir & "\uninstall.exe")
    EndIf
    EndIf
    WEnd
    EndSwitch
    WEnd

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


    GUISetState(@SW_HIDE,$hGUIforGrayBK)

    ; Hintergrund wieder einfärben
    While $iSaturation < 0
    $iSaturation += Abs($iColorStep)
    If $iSaturation > 0 Then $iSaturation = 0
    SaturationBitmap($hGUIDskTop,$hImage,$iSaturation)
    Wend

    _GDIP_Shutdown ()

    If $hDllGdi32 > 0 Then DllClose($hDllGdi32)

    FileDelete($cszFileName)

    ; + ----------------------------------------------------- +
    ; | Funktionen aus gdi32.dll |
    ; + ----------------------------------------------------- +
    Func _GDI32_GetColorAdjustment($hDC)
    Local $aResult
    Local $tData = DllStructCreate($tagCOLORADJUSTMENT)
    Local $pData = DllStructGetPtr($tData)

    $aResult = DllCall($hDllGdi32, "int", "GetColorAdjustment", "hwnd", $hDC, "ptr", $pData)

    Return SetError(1 * ($aResult[0] = 0), 0, $tData)
    EndFunc

    Func _GDI32_SetColorAdjustment($hDC, $tData)
    Local $aResult
    Local $pData = DllStructGetPtr($tData)

    $aResult = DllCall($hDllGdi32, "int", "SetColorAdjustment", "hwnd", $hDC, "ptr", $pData)

    Return SetError(1 * ($aResult[0] = 0), 0, $tData)
    EndFunc

    Func _GDI32_SetStretchBltMode($hDC, $iStretchMode)
    Local $aResult

    $aResult = DllCall($hDllGdi32, "int", "SetStretchBltMode", "hwnd", $hDC, "int", $iStretchMode)

    Return SetError(1 * ($aResult[0] = 0), 0, $aResult[0])
    EndFunc

    Func _GDI32_StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc,$nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop)
    Local $aResult

    $aResult = DllCall($hDllGdi32, "int", "StretchBlt", _
    "hwnd", $hdcDest, _
    "int", $nXOriginDest, _
    "int", $nYOriginDest, _
    "int", $nWidthDest, _
    "int", $nHeightDest, _
    "hwnd", $hdcSrc, _
    "int", $nXOriginSrc, _
    "int", $nYOriginSrc, _
    "int", $nWidthSrc, _
    "int", $nHeightSrc, _
    "dword", $dwRop _
    )

    Return SetError(1 * ($aResult[0] = 0), 0, ($aResult[0] = 1))
    EndFunc

    Func SaturationBitmap($hGUI, $hImage, $iSaturation)
    Local $hScrDC, $hMemDC, $hBitmap, $hOldBitmap, $pSize, $tSize, $pSource, $tSource, $tCA

    $hScrDC = _API_GetDC(0)
    $hMemDC = _API_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOldBitmap = _API_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize )
    DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)

    _GDI32_SetStretchBltMode($hMemDC,$HALFTONE)

    $tCA = _GDI32_GetColorAdjustment($hMemDC)
    DllStructSetData($tCA,"caColorfulness",$iSaturation)
    _GDI32_SetColorAdjustment($hMemDC,$tCA)
    _GDI32_StretchBlt($hMemDC,0,0,$VirtualDskTop[0],$VirtualDskTop[1],$hMemDC,0,0,$VirtualDskTop[0],$VirtualDskTop[1],$SRCCOPY)

    _API_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, 0, 0)
    _API_ReleaseDC (0, $hScrDC)
    _API_SelectObject($hMemDC, $hOldBitmap)
    _API_DeleteObject($hBitmap)
    _API_DeleteDC ($hMemDC)
    EndFunc

    Func NoAltTab()
    ; Pseudofunktion um den Hotkey
    ; Alt-Tab zu verhindern
    EndFunc

    Func GetVirtualScreenSize()
    Local $aVSS[2] = [0, 0]

    $aVSS[0] = _API_GetSystemMetrics($SM_CXVIRTUALSCREEN)
    $aVSS[1] = _API_GetSystemMetrics($SM_CYVIRTUALSCREEN)

    If ($aVSS[0] = 0) Or ($aVSS[1] = 0) Then
    $aVSS[0] = 0
    $aVSS[1] = 0
    EndIf

    Return SetError(($aVSS[0] Or $aVSS[1]),0, $aVSS)
    EndFunc

    [/autoit]

    ]

    Einmal editiert, zuletzt von paulchen69 (30. November 2007 um 16:15)