Jump to content
Sign in to follow this  
ludocus

Block wins with a password

Recommended Posts

ludocus

Hi everybody..

It's been a long time since I posted here :D

This is very simple but effective..

When you try to open a window that's blocked, the window will hide and you will be prompted to enter a password..

If it's correct the window shows again, else it closes..

Check it out:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         Ludocus

 Script Function:
    Block windows with a password

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
Opt("WinTitleMatchMode", 1) ; = 1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
$nopasstime = 60000         ; = 1 minute (1000*60=60000)
$num = 5                    ; = number of titles
$setpass = 'somepassword'   ; = password for blocked window
global $titles[$num+1] = ['Notepad', 'Calculator', 'Minesweeper', 'Windows Live Messenger', 'My documents']
While 1
    sleep(200)
    $titlez = WinList()
    For $i = 1 to $titlez[0][0]
        For $p = 0 to ($num-1)
            if $titlez[$i][0] = $titles[$p] then
                if _Password($titlez[$i][0]) Then 
                    Sleep($nopasstime)
                Else
                    WinClose($titlez[$i][0])
                EndIf
                exitloop
            EndIf
        Next
    Next
WEnd

Func _Password($title)
    WinSetState($title, '', @SW_HIDE)
    $pass = InputBox('Forbidden!', 'Please enter your password', '', '*', 100, 100, -1, -1, 30)
    if $pass = $setpass then
        WinSetState($title, '', @SW_SHOW)
        return 1
    EndIf
    return 0
EndFunc

Share this post


Link to post
Share on other sites
gseller

Cool, it works on some things. Not on notepad or mydocuments. I am using vista x64.. Love it! Thanks for sharing

Share this post


Link to post
Share on other sites
nguyenbason

Nice Idea but what if your script is terminated from Task Manager?


UnderWorldVN- Just play the way you like it

Share this post


Link to post
Share on other sites
James

Global $titles[$num + 1] = ['Untitled - Notepad', 'Calculator', 'Minesweeper', 'Windows Live Messenger', 'Documents']

Changed that for Windows 7/Vista. Notepad will work on any OS. This would be better if it worked through processes and not window titles.

Share this post


Link to post
Share on other sites
ludocus

you could use:

If ProcessExists('taskman.exe') Then ProcessClose('taskman.exe')

or you could edit the registry:

RegWrite ('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', "DisableTaskMgr", "REG_DWORD", 1 )

(to enable taskmanager use: RegWrite ('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', "DisableTaskMgr", "REG_DWORD", 0 )

Share this post


Link to post
Share on other sites
Yashied
Zisly

you could use:

If ProcessExists('taskman.exe') Then ProcessClose('taskman.exe')

or you could edit the registry:

RegWrite ('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', "DisableTaskMgr", "REG_DWORD", 1 )

(to enable taskmanager use: RegWrite ('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', "DisableTaskMgr", "REG_DWORD", 0 )

Don't post things that could end up in the wrong lazy hands.

Share this post


Link to post
Share on other sites
slayerz

Nice script but still need major improvement to be more secure.

I did bypassed the security easily.

Run the script, open My Documents.

The script hide it and prompt for password.

Without entering the password, try to open My Documents again, and the script will not hide it and not bothering for password again.


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
corgano

This would be better if it worked through processes and not window titles.

Yes, a much better idea. you could have it get the process of the window when setting the password and get the window of the process when the program is running, or something like that

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
James

Run the script, open My Documents.

The script hide it and prompt for password.

Without entering the password, try to open My Documents again, and the script will not hide it and not bothering for password again.

That's because of this:

If $titlez[$i][0] = $titles[$p] Then
    If _Password($titlez[$i][0]) Then
        Sleep($nopasstime)
    Else
        WinClose($titlez[$i][0])
    EndIf
    ExitLoop
EndIf

It's sleeping till the password is entered.

Yes, a much better idea. you could have it get the process of the window when setting the password and get the window of the process when the program is running, or something like that

Well that would bugger up any multi-lingual support.

Share this post


Link to post
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
Sign in to follow this  

×