BildSchirm-Sperre

  • Heyho
    Ich wollte dann auch mal hier mein erstes kleines Progrämmchen vorstellen :D
    Es ist eigentlich eine simple Idee, die mir auf einer LAN-Party kam, wo ich mir nicht sicher war, ob nicht meine Kumpel an meinem PC rumfuchteln, wenn ich mal kurz auf dem Klo bin ^^(ja, ich weiss, dass ich ein Bisschen paranoid bin :D )
    Deswegen hab ich mal DAS hier gebastelt:

    Spoiler anzeigen
    [autoit]


    ;;;; Hotkeys etc ;;;;
    #NoTrayIcon
    #include <GUIConstants.au3>
    #include <String.au3>
    #include <Misc.au3>
    Opt("GUIOnEventMode", 1)
    HotKeySet("#s", "_start")
    HotKeySet("#^s", "_exit")
    HotKeySet("+{TAB}", "_nix")
    Global $STATE = 0

    ;;;; Registry ;;;;
    If RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "BildSchirmSperre") = "" And RegRead("HKLM\Software\AutoIt v3\AutoIt", "BildSchirmSperrepw") = "" Then
    $autostart = MsgBox(4,"Bildschirm-Sperre","Wollen Sie die Bildschirm-Sperre im Autostart haben?")
    If $autostart = 6 Then RegWrite("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "BildSchirmSperre", "REG_SZ", @ScriptFullPath)
    EndIf

    If Regread("HKLM\Software\AutoIt v3\AutoIt", "BildSchirmSperrepw") = "" Then
    $pwi = InputBox("Bildschirm-Sperre-Passwort", "Was soll das Passwort sein?" & @CRLF & "(Gut merken!)", "", "*M")
    If (@error = 1) Then
    Exit
    EndIf
    Global $pw = $pwi
    RegWrite("HKLM\Software\AutoIt v3\AutoIt", "BildSchirmSperrepw", "REG_SZ", _StringEncrypt(1, $pw, "asdfg", 2))
    SplashTextOn("", "Mit Windows+S 'scharf' machen." & @CRLF & "Mit Windows+Strg+S beenden.", 275, 50, -1, -1, 1)
    Sleep(5000)
    SplashOff()
    Else
    Global $pw = _StringEncrypt(0, RegRead("HKLM\Software\AutoIt v3\AutoIt", "BildSchirmSperrepw"), "asdfg", 2)
    EndIf

    ;;;; GUI ;;;;
    $GUI = GUICreate("SPERRE", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW)
    GUISetBkColor(0x000000)
    $pwin = GUICtrlCreateInput("", @DesktopWidth/2-65, @DesktopHeight/2-10, 130, 20, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL, $ES_CENTER))
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetColor(-1, 0xFF0000)
    WinSetOnTop("SPERRE", "", 1)
    GUISetCursor(16, 1)

    While 1
    Sleep(100)
    WEnd

    ;;;; Funcs ;;;;
    Func _start()
    If $STATE = 0 Then
    $old = MouseGetPos()
    Sleep(500)
    While 1
    $new = MouseGetPos()
    If ProcessExists("taskmgr.exe") Then ProcessClose("taskmgr.exe")
    If NOT WinActive("SPERRE") Then WinActivate("SPERRE")
    FOr $i = 0 To 255 Step 1
    If $new[0] <> $old[0] Or $new[1] <> $old[1] Or _IsPressed(Hex($i, 2)) Then
    $mouse = MouseGetPos()
    XSkinAnimate($GUI, 1, 1)
    _MouseTrap(@DesktopWidth/2-1, @DesktopHeight/2+30-1, @DesktopWidth/2+1, @DesktopHeight/2+30+1)
    $STATE = 1
    EndIf
    Next
    If GUICtrlRead($pwin) = $pw Then
    _MouseTrap()
    GUICtrlSetData($pwin, "")
    $STATE = 0
    XSkinAnimate($GUI, 2, 2)
    ExitLoop
    EndIf
    WEnd
    EndIf
    EndFunc

    Func _exit()
    If $STATE = 0 Then Exit
    EndFunc

    Func XSkinAnimate($Xwnd, $Xstate = 1, $Xstyle = 0, $Xtrans = 0, $Xspeed = 500) ; Func by Valuater
    ; $Xstate - 1 = Show, 2 = Hide, '' = No State Set
    ; $Xstyle - 1=Fade, 3=Explode, 5=L-Slide, 7=R-Slide, 9=T-Slide, 11=B-Slide, 13=TL-Diag-Slide, 15=TR-Diag-Slide, 17=BL-Diag-Slide, 19=BR-Diag-Slide
    Local $Xpick = StringSplit('80000,90000,40010,50010,40001,50002,40002,50001,40004,50008,40008,50004,40005,5000a,40006,50009,40009,50006,4000a,50005', ',')
    If Not WinExists($Xwnd) Then MsgBox(262208, "XSkin Error", "XSkinAnimate $Xwnd - Window not found", 5)
    If $Xstyle > $Xpick[0] Then MsgBox(262208, "XSkin Error", "$Xstyle max is 19", 5)
    If $Xstyle <> 0 Then Local $ret = DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $Xwnd, 'int', $Xspeed, 'long', '0x000' & $Xpick[$Xstyle])
    If $Xtrans <> 0 Then WinSetTrans($Xwnd, '', $Xtrans)
    If $Xstate = 1 Then GUISetState(@SW_SHOW, $Xwnd)
    If $Xstate = 2 Then GUISetState(@SW_HIDE, $Xwnd)
    If $Xstyle <> 0 Then Return $ret
    EndFunc ;==>XSkinAnimate

    [/autoit]

    Nur eine Sache habe ich gefunden, bei der ich nicht ganz zu frieden bin, und auch nicht weiß, wie ich es besser machen könnte...Die Sache mit dem Alt+Tab. Da das ja verhindert werden sollte, habe ich es einfach mit WinActivate() gemacht, was aber nicht wirklich schön ist, wie ich finde.
    Ich habe es auch schon einmal SO probiert, aber das wollte nicht wirklich funktionieren... :/

    Spoiler anzeigen
    [autoit]


    HotKeySet("+{Tab}", "_nix")
    ;Der Rest vom Code
    Func _nix()
    If $STATE = 0 Then Send("+{TAB}")
    EndIf

    [/autoit]


    Deswegen wollte ich mal fragen, ob ihr dazu eine Lösung hättet :)

    MfG
    FerD

    Einmal editiert, zuletzt von FerD (9. Oktober 2007 um 17:14)

  • Zitat

    Original von Daniel W.
    Windows Passwort rein und dann Win+L
    in einfach ;)


    hehe so einfach wollte ich das nicht ;D

    Zitat

    Original von progandy
    Schau dir doch das mal an. Sperrt alles (mit wnlock.dll)


    hmmm wo kriegt man denn diese winlockdll.dll her? Oo
    habe grade bisschen gegooglet, aber nur eine Downloadseite gefunden, wo man sich allerdings registrieren muss.
    Bei der Registration wird mir aber gesagt, dass meine E-Mail Addresse ungültig sei oO