Sign in to follow this  
Followers 0
sacroyant

Problem with Screen Lock using AutoIT

6 posts in this topic

I write a small tools using AutoIT, used to lock the screen when a temporary leave of machinery, named Screen Lock.

The operating principle is very simple. In time activate first, Screen Lock asked to create the password and encryption MD5 and save as a key in Regedit. Then, each time the trigger, it will display a window as the cover of the entire screen and you want to disable it must enter a password to close this window.

Posted Image

The problem is that if foreigners subject to the "window" on the keyboard, Programs menu and tasks appear!

How to solve this problem? Please help me !

Thanks in advance !

Share this post


Link to post
Share on other sites



herewasplato, thanks. I have seen that topic and other related thread, but still can not find ways to solve problems. The source of the Screen Lock as below, you expect the review to help me :mellow:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <md5.au3>

Opt("TrayIconHide", 1) 

Global $title, $screenWidth, $screenHeight, $key, $keyPath, $mainWin

$title="Screen Lock"
$screenWidth=@DesktopWidth
$screenHeight=@DesktopHeight
$key="Primary Key"
$keyPath="HKEY_LOCAL_MACHINE\SOFTWARE\Screen Lock"

$mainWin=GUICreate ($title, $screenWidth, $screenHeight, -1, -1)

;/////////////////////////////////////////////////

Func setPassword($pwd)
    RegDelete($keyPath, $key)
    RegWrite($keyPath, $key, "REG_SZ", MD5($pwd))
EndFunc

Func getPassword()
    Return RegRead($keyPath, $key)
EndFunc

Func checkPassword($input)
  Local $result, $pwd
  $result=False
    $pwd=getPassword()
    If $pwd <> "" And MD5($input) == $pwd Then
        $result=True
    EndIf
  Return $result
EndFunc

Func lock()
  GUISetState(@SW_SHOW, $mainWin)
  GUICtrlCreateLabel ("", 0, 0, $screenWidth, $screenHeight)
  GUISetBkColor(0xff0000)
EndFunc

Func unlock()
    GUISetState(@SW_HIDE, $mainWin)
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func getTop($winHeight)
  Return Ceiling(($screenHeight-$winHeight)/2)
EndFunc

Func getLeft($winWidth)
  Return Ceiling(($screenWidth-$winWidth)/2)
EndFunc

;/////////////////////////////////////////////////

Dim $keypwd, $pwdMaster, $pwdInput

$keypwd=getPassword()

If $keypwd=="" Then
  $pwdMaster=InputBox ( $title, "Create master password : ", "", "*", 240, 60, getLeft(250), getTop(60), 0, $mainWin)
    If $pwdMaster<>"" Then
       setPassword($pwdMaster)
    EndIf
Else
    lock();
      While checkPassword($pwdInput)==False
        $pwdInput=InputBox ( $title, "Do you want to unlock screen now ? ", "", "*", 250, 60, getLeft(250), getTop(60), 0, $mainWin)
          If checkPassword($pwdInput)==True Then
            unlock()
            Exit
          ElseIf  $pwdInput=="" Then
            MsgBox(0, "Error", "Please enter password to unlock ! ")
          Else
            MsgBox(0, "Error", "Password you entered is not valid ! ")
          EndIf
      WEnd
  EndIf
  
; End Program

ScreenLock.au3

md5.au3

Share this post


Link to post
Share on other sites

> The problem is that if foreigners subject to the "window" on the keyboard, Programs menu and tasks appear!

Something is lost in the translation to English.

Is this what you meant?

[Pressing the WinKey or Ctrl-Esc] on the keyboard [makes the] Programs menu and tasks appear!


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

> The problem is that if foreigners subject to the "window" on the keyboard, Programs menu and tasks appear!

Something is lost in the translation to English.

Google Translate :mellow:

Is this what you meant?

[Pressing the WinKey or Ctrl-Esc] on the keyboard [makes the] Programs menu and tasks appear!

I want to say that is when the screen is locking, if somebody press on the "window" key, menu Start and taskbar of Window will appear above ScreenLock. How to set the ScreenLock's window away on top ?

Share this post


Link to post
Share on other sites

Then we are back to my first suggestion - disable the WinKey ("window" key).

Maybe someone that is more familar with the GUI functions can say if setting the "on top" attribute will keep it top most or in the Windows OS always wins.


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  
Followers 0