Jump to content

Break my code


Recommended Posts

I am trying to lockdown my computer if specific hardware is removed and unlock it if it comes back. The triggering is done in another script, these are the lock and release scripts which are executed in case of the hardware events. I am so far not able to gain control over the computer without resetting it or replugging the specific hardware. Are you ?

I know about Win+L but since one couldn't unlock the computer in the "real" lock-state programmatically I am trying to do this whole lock via script.

lock.exe

#NoTrayIcon
#include <misc.au3>

while 1
    block()
    sleep(50)
    for $x=0 to 165
        if _IsPressed(Hex($x)) then 
            block()
            sleep(50)
        EndIf
    Next
WEnd

Func block()
    Opt("WinTitleMatchMode", 4)

    ;Deactivate Monitor
    $HWND = WinGetHandle("classname=Progman")

    DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", 274, "int", _
    61808, "int", 2)
    
    ;Deactivate Taskbar
    WinSetState("classname=Shell_TrayWnd", "", @SW_HIDE)
    
    ;Disable Taskmanager
    ProcessClose('taskmgr.exe')
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD","1")
    
    ;Disable Input
    BlockInput(1)

    Opt("WinTitleMatchMode", 1)
EndFunc


block()

release.exe

#NoTrayIcon

Func unblock()
    Opt("WinTitleMatchMode", 4)

    ;Activate Monitor
    $HWND = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", 274, "int", _
    61808, "int", -1)
    
    ;Activate Taskbar
    WinSetState("classname=Shell_TrayWnd", "", @SW_SHOW)
    
    ;Enable Taskmanager
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD","0")

    ;Enable Input
    BlockInput(0)

    Opt("WinTitleMatchMode", 1)
EndFunc


ProcessClose('lock.exe')
unblock()
Edited by level20peon
Link to comment
Share on other sites

simple enough... though Regwriting...(correct me if i'm wrong) but it needs to be rebooted to take effect

Link to comment
Share on other sites

I can understand if somebody doesn't want to distribute scripts that include regwriting but since this is for personal use only I am ok if it writes to my computers registry (if this is what you mean).

The changes take effect immediately, tested on Windows 7 x64 and Windows Server 2003 x86 which I guess covers most possible kernels of modern windows systems.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...