• Hallo zusammen,

    ich habe hier ein Programm mit dem man den Pc sperren kann.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=Icon.ico
    #AutoIt3Wrapper_outfile=Pc Lock.exe
    #AutoIt3Wrapper_Compression=4
    #AutoIt3Wrapper_Res_Description=Security Programm
    #AutoIt3Wrapper_Res_Fileversion=0.6
    #AutoIt3Wrapper_Res_LegalCopyright=Moritz
    #AutoIt3Wrapper_Res_Field=Author|Moritz
    #AutoIt3Wrapper_Res_Field=Orginaldateiname|Pc Lock.exe
    #AutoIt3Wrapper_Res_Field=Produktname|Pc Lock
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

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

    #include <WindowsConstants.au3>
    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <ButtonConstants.au3>
    #include <ScreenCapture.au3>
    #include <Misc.au3>
    #include <Sound.au3>

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

    AutoItSetOption ( "TrayMenuMode",1 )
    Opt("TrayMenuMode",1)

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

    $tray_optionen = TrayCreateItem("Einstellungen")
    TrayCreateItem("")
    $tray_exit = TrayCreateItem("Beenden")
    TrayCreateItem("")

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

    TraySetState()

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

    Const $Width = 1280
    Const $Height = 800
    Const $version = "v0.6"
    Global $text = "# Bitte Code eingeben #"
    Global $fehler = 0
    Global $fehler_sd = -1
    Global $buffer
    Global $screen
    Global $pic1,$pic2,$pic3,$pic4,$pic5,$pic6
    Global $hgraphic
    Global $bitmap
    Global $state
    Global $text
    Global $pin,$s,$taskkill,$doors,$shutdown,$alarm,$alarm_num,$hotkey
    Global $richtig, $falsch, $door ,$alarm_s

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

    $richtig = ""
    $falsch = ""
    $door = ""
    $dll = DllOpen("user32.dll")

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

    If Not FileExists ("bin\not.not") Then _optionen ()

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

    Func _optionen ()

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

    GUICreate ("Pc Lock " & $version,320,110)
    GuiSetIcon("shell32.dll",48)
    GUISetBkColor (0x444444)

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

    $ok = GUICtrlCreateButton ("OK",270,10,40,20)

    $tab = GUICtrlCreateTab(10, 10, 300, 90)

    $tab0 = GUICtrlCreateTabItem("Main")
    GUICtrlCreateLabel ("PW:",20,45,20,20)
    $PW = GUICtrlCreateInput ("",50,40,80,20)
    $do = GUICtrlCreateCheckbox ("Tür",20,70)
    $ast = GUICtrlCreateCheckbox ("Autostart",200,70)
    GUICtrlCreateLabel ("Hotkey:",80,75)
    $hk = GUICtrlCreateCombo ("F1", 120,70,60,20)
    GUICtrlSetData(-1,"F2|F3|F4|F5|F6|F7|F8|F9|F10|F11","F1")

    $tab1 = GUICtrlCreateTabItem("Sound")
    $sound = GUICtrlCreateCheckbox ("Sound",20,40)
    $al = GUICtrlCreateCheckbox ("Alarm",80,40)
    $an = GUICtrlCreateCombo ("Alarm1", 130,40,60,20)
    GUICtrlSetData(-1,"Alarm2|Alarm3","Alarm1")
    $test_al = GUICtrlCreateButton ("Test",200,40,20,20,$BS_ICON)
    GUICtrlSetImage (-1, "shell32.dll",277,0)

    $tab2 = GUICtrlCreateTabItem("Aktionen")
    $tk = GUICtrlCreateCheckbox ("Taskkill",20,40)
    $sd = GUICtrlCreateCheckbox ("Shutdown",80,40)
    GUICtrlCreateLabel ("Versuche: ",210,45)
    $tries = GUICtrlCreateInput ("",265,40,35,20)
    GuiCtrlCreateUpDown(-1)

    GUICtrlCreateTabItem("")

    GUISetState ()

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

    GUICtrlSetState ($sound,IniRead ("bin\config.ini","Buttons","ton",""))
    GUICtrlSetState ($tk,IniRead ("bin\config.ini","Buttons","taskkill",""))
    GUICtrlSetState ($do,IniRead ("bin\config.ini","Buttons","türen",""))
    GUICtrlSetState ($ast,IniRead ("bin\config.ini","Buttons","autostart",""))
    GUICtrlSetState ($sd,IniRead ("bin\config.ini","Buttons","Ausschalten",""))
    GUICtrlSetState ($al,IniRead ("bin\config.ini","Buttons","alarm",""))
    GUICtrlSetData ($hk,IniRead ("bin\config.ini","Buttons","hotkey","F1"))
    GUICtrlSetData ($pw,BinaryToString (IniRead ("bin\config.ini","Buttons","pw","")))
    GUICtrlSetData ($an,"","")
    GUICtrlSetData ($an,"Alarm1|Alarm2|Alarm3",IniRead ("bin\config.ini","Buttons","alarm ton",""))
    GUICtrlSetData ($tries,IniRead ("bin\config.ini","Buttons","versuche",""))

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

    While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $ok Then ExitLoop
    If $msg = $test_al Then SoundPlay ("sound\" & GUICtrlRead ($an) & ".wav",0)
    If _IsPressed ("0D",$dll) Then ExitLoop
    WEnd

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

    $pin = GUICtrlRead ($PW)
    $s = GUICtrlRead ($sound)
    $taskkill = GUICtrlRead ($tk)
    $doors = GUICtrlRead ($do)
    $autostart = GUICtrlRead ($ast)
    $shutdown = GUICtrlRead ($sd)
    $alarm = GUICtrlRead ($al)
    $alarm_num = GUICtrlRead ($an)
    $hotkey = GUICtrlRead ($hk)
    If GUICtrlRead ($tries) <> "" Then $fehler_sd = GUICtrlRead ($tries)

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

    IniWrite ("bin\config.ini","Buttons","Ton",$s)
    IniWrite ("bin\config.ini","Buttons","Hotkey",$hotkey)
    IniWrite ("bin\config.ini","Buttons","Taskkill",$taskkill)
    IniWrite ("bin\config.ini","Buttons","Türen",$doors)
    IniWrite ("bin\config.ini","Buttons","autostart",$autostart)
    IniWrite ("bin\config.ini","Buttons","Ausschalten",$shutdown)
    IniWrite ("bin\config.ini","Buttons","Alarm",$alarm)
    IniWrite ("bin\config.ini","Buttons","Alarm Ton",$alarm_num)
    IniWrite ("bin\config.ini","Buttons","Versuche",$fehler_sd)
    IniWrite ("bin\config.ini","Buttons","PW",Binary($pin))

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

    GUIDelete ()

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

    If $autostart = 1 Then
    FileCreateShortcut(FileGetShortName("pc lock.exe",1),@StartupDir & "\pc lock.lnk",@WindowsDir,"/e,c:\", "Dies ist ein Explorerlink")
    FileWrite ("bin\not.not","Not")
    EndIf
    If $autostart <> 1 Then
    FileDelete (@StartupDir & "\pc lock.lnk")
    FileDelete ("bin\not.not")
    EndIf
    _hotkey_set ($hotkey)

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

    EndFunc

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

    Func _hotkey_set ($hotkey)
    HotKeySet ("{F1}")
    HotKeySet ("{F2}")
    HotKeySet ("{F3}")
    HotKeySet ("{F4}")
    HotKeySet ("{F5}")
    HotKeySet ("{F6}")
    HotKeySet ("{F7}")
    HotKeySet ("{F8}")
    HotKeySet ("{F9}")
    HotKeySet ("{F10}")
    HotKeySet ("{F11}")

    If $hotkey = "F1" Then HotKeySet ("{F1}","_lock")
    If $hotkey = "F2" Then HotKeySet ("{F2}","_lock")
    If $hotkey = "F3" Then HotKeySet ("{F3}","_lock")
    If $hotkey = "F4" Then HotKeySet ("{F4}","_lock")
    If $hotkey = "F5" Then HotKeySet ("{F5}","_lock")
    If $hotkey = "F6" Then HotKeySet ("{F6}","_lock")
    If $hotkey = "F7" Then HotKeySet ("{F7}","_lock")
    If $hotkey = "F8" Then HotKeySet ("{F8}","_lock")
    If $hotkey = "F9" Then HotKeySet ("{F9}","_lock")
    If $hotkey = "F10" Then HotKeySet ("{F10}","_lock")
    If $hotkey = "F11" Then HotKeySet ("{F11}","_lock")
    EndFunc

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

    If $s = 1 Then
    $richtig = _SoundOpen("sound\richtig.wav")
    $falsch = _SoundOpen("sound\falsch.wav")
    $door = _SoundOpen("sound\door_move.wav")
    EndIf
    If $alarm = 1 Then $alarm_s = _SoundOpen("sound\" & $alarm_num & ".wav")

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

    Sleep (100)

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

    While 1
    Sleep (20)
    $tray = TrayGetMsg()
    If $tray = $tray_optionen Then _optionen ()
    If $tray = $tray_exit Then _beenden ()
    WEnd

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

    Func _lock ()

    HotKeySet("{Enter}", "_pw_compaire")
    HotKeySet ("{Left}", "_nichts" )
    HotKeySet ("{Right}", "_nichts" )
    HotKeySet ("{Up}", "_nichts" )
    HotKeySet ("{Down}", "_nichts" )
    HotKeySet ("{Space}", "_nichts" )
    HotKeySet ("{Delete}", "_nichts" )
    HotKeySet ("{Backspace}", "_pw_del_let" )
    HotKeySet ("{F1}")
    HotKeySet ("{F2}")
    HotKeySet ("{F3}")
    HotKeySet ("{F4}")
    HotKeySet ("{F5}")
    HotKeySet ("{F6}")
    HotKeySet ("{F7}")
    HotKeySet ("{F8}")
    HotKeySet ("{F9}")
    HotKeySet ("{F10}")
    HotKeySet ("{F11}")

    $hBitmap = _ScreenCapture_Capture ("",0,0,-1,-1,False)

    $hGUI = GUICreate("Locker", $Width, $Height,0,0, $WS_POPUP, $WS_EX_TOPMOST)
    $hWnd = WinGetHandle("Locker")

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

    GUISetState ()

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

    ;Resourcen laden
    _GDIPlus_Startup ()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) ;create graphic
    $Bitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic) ;create bitmap
    $Buffer = _GDIPlus_ImageGetGraphicsContext($Bitmap) ;create buffer
    _GDIPlus_GraphicsSetSmoothingMode($Buffer, 4) ;Antialiasing
    _GDIPlus_GraphicsClear($Buffer,0xFFFFFFFF) ;clear buffer

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

    $pic1 = _GDIPlus_BitmapCreateFromFile("texturen\door_oben.gif")
    $pic2 = _GDIPlus_BitmapCreateFromFile("texturen\door_unten.gif")
    $pic3 = _GDIPlus_BitmapCreateFromFile("texturen\door.gif")
    $pic4 = _GDIPlus_BitmapCreateFromFile("texturen\door2_links.gif")
    $pic5 = _GDIPlus_BitmapCreateFromFile("texturen\door2_rechts.gif")
    $pic6 = _GDIPlus_BitmapCreateFromFile("texturen\door2.gif")
    $screen = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)

    If $doors = 1 Then _close ()

    While $state <> 2

    $tray = TrayGetMsg()
    If $tray = $tray_optionen Then _optionen ()
    If $tray = $tray_exit Then _beenden ()

    _tastature ()

    If WinExists ("Windows Task-Manager") Then WinKill ("Windows Task-Manager")
    WinSetOnTop("Locker", "", 1)

    If $alarm = 2 Then _SoundPlay ($alarm_s)

    _GDIPlus_GraphicsClear($Buffer,0xFF00FF00)
    If $doors = 1 Then _GDIPlus_GraphicsDrawImageRectRect($Buffer, $pic3,0,0,1280,800,0,0, $Width, $Height)
    If $doors = 4 Then _GDIPlus_GraphicsDrawImageRectRect($Buffer, $screen,0,0,1280,800,0,0, $Width, $Height)
    _GDIPlus_GraphicsDrawString ($Buffer,$text,500,470,"Arial",18)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap, 0, 0, $Width, $Height)
    WEnd

    GUIDelete ()
    $state = 0
    $text = "# Bitte Code eingeben #"
    $fehler = 0

    HotKeySet("{Enter}")
    HotKeySet ("{Left}")
    HotKeySet ("{Right}")
    HotKeySet ("{Up}")
    HotKeySet ("{Down}")
    HotKeySet ("{Space}")
    HotKeySet ("{Delete}")
    HotKeySet ("{Backspace}")

    EndFunc

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

    Func _open ()
    _SoundPlay($door, 0)
    Local $i = 0

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

    While $i < $Height * 2 / 3

    _GDIPlus_GraphicsClear($Buffer,0xFF00FF00)

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

    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $screen,0,0,1280,800,0,0, $Width, $Height)
    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $pic1,0,0,1280,800,0,$i * -1, $Width, $Height)
    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $pic2,0,0,1280,800,0,$i, $Width, $Height)

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap, 0, 0, $Width, $Height)

    $i = $i + 4

    Sleep (10)
    WEnd
    EndFunc

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

    Func _close ()
    _SoundPlay($door, 0)
    Local $i = 0

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

    While $i < $Height * 2/3

    _GDIPlus_GraphicsClear($Buffer,0xFF00FF00)

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

    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $screen,0,0,1280,800,0,0, $Width, $Height)
    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $pic1,0,0,1280,800,0,$Height * 2/3 * -1 + $i, $Width, $Height)
    _GDIPlus_GraphicsDrawImageRectRect($Buffer, $pic2,0,0,1280,800,0,$Height * 2/3 - $i, $Width, $Height)

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap, 0, 0, $Width, $Height)

    $i = $i + 4

    Sleep (10)
    WEnd

    EndFunc

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

    Func _tastature ()
    For $a = 48 To 90
    If _IsPressed(Hex($a),$dll) Then
    Do
    Until Not _IsPressed(Hex($a),$dll)
    If $text = "# Bitte Code eingeben #" Or $text = "# Falsches Passwort #" Then $text = ""
    $text = $text & StringLower(Chr($a))
    EndIf
    Next
    EndFunc

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

    Func _pw_compaire ()
    If $text = $pin Then
    _SoundPlay($richtig, 1)
    If $doors = 1 Then _open ()
    _hotkey_set ($hotkey)
    $state = 2
    EndIf

    If $pin = "" Then
    _SoundPlay($richtig, 1)
    _hotkey_set ($hotkey)
    If $doors = 1 Then _open ()
    $state = 2
    EndIf

    If $text <> $pin Then
    _SoundPlay($falsch, 0)
    $text = "# Falsches Passwort #"
    $fehler = $fehler + 1
    EndIf
    If $fehler = $fehler_sd And $taskkill = 1 Then _taskkill_all ()
    If $fehler = $fehler_sd And $shutdown = 1 Then Shutdown (4)
    If $fehler = $fehler_sd And $alarm = 1 Then $alarm = 2

    EndFunc

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

    Func _pw_del_let ()
    $text = StringTrimRight ($text,1)
    EndFunc

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

    Func _taskkill_all ()
    Local $var = WinList()

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

    For $i = 1 to $var[0][0]
    If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    If $var[$i][0] <> "Program Manager" Then WinKill ($var[$i][0])
    EndIf
    Next
    EndFunc

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

    Func IsVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then
    Return 1
    Else
    Return 0
    EndIf

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

    EndFunc

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

    Func _nichts ()
    Return
    EndFunc

    Func _beenden ()
    _GDIPlus_ImageDispose ($pic1)
    _GDIPlus_ImageDispose ($pic2)
    _GDIPlus_ImageDispose ($pic3)
    _GDIPlus_ImageDispose ($pic4)
    _GDIPlus_ImageDispose ($pic5)
    _GDIPlus_ImageDispose ($pic6)
    _GDIPlus_ImageDispose ($screen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_BitmapDispose($Bitmap)
    _GDIPlus_GraphicsDispose($Buffer)
    _GDIPlus_Shutdown ()
    _SoundClose($alarm_s)
    _SoundClose($richtig)
    _SoundClose($falsch)
    _SoundClose($door)
    Exit
    EndFunc

    [/autoit]

    autoit.de/wcf/attachment/5642/