Sign in to follow this  
Followers 0
Darc

Unable to set a login box on top of a fullscreen GUI

3 posts in this topic

I have been working on a script for the last few days and I have run into a big problem. I have created a login/screen lock script that I want to use on a BartPE CD. The script for the log-in box works fine. However, my problems started when I tried to integrate it into Valuater's great "Vaulter - PC Lockout" script. I want to use the locking features of his script and have my login script kick in when the user moves the mouse or presses a key. I can't get my login script to stay on top. The login script opens then goes right to the background. Does anyone have any idea how I could integrate the two scripts? Below is a copy of my login script. Any help would be greatly appreciated.

; =============================================================================================
; Author:       Darc
; Platform:     WinPE/XPE
; Script Name:  WinPE Toolbox Logon.exe
; Description:  Prompt for ID and password and compare them to the contents of Pass.ini
; AutoIt Version: 3.1.1.114 (beta)
; History:
;   v1.0 - Initial Release
;
; =============================================================================================
; Declarations
; =============================================================================================
#include <GUIConstants.au3>
#include <MD5.au3>
#include <Date.au3>
AutoItSetOption ( "RunErrorsFatal", 0 )
AutoItSetOption ( "TrayIconHide", 1 )
Opt("GUIOnEventMode", 1)
;HotKeySet( "{ENTER}", "_ok" ); Set escape as an exit hotkey
$Script_Name = @ScriptName
$Script_Name_Short = StringTrimRight($Script_Name, 4)
$Title = "WinPE Toolbox - Logon"; Title of the main GUI
$Version = "1.0"
$Pass_List = "Pass.ini"
$Min_User_Length = 6
$Min_Password_Length = 6
;$User_Expires = "no"
$Attempts_Allowed = 3
Dim $User_Name
; =============================================================================================
; Make sure this script is not already running
; =============================================================================================
If WinExists ($Script_Name_Short & " 1st") Then
    WinActivate($Title & " "); The space at the end of the title is so the window will have a unique name
    _Middle($Title & " ", ""); Moves the GUI to the center of the screen
    Exit
EndIf
AutoItWinSetTitle ($Script_Name_Short & " 1st")
; =============================================================================================
; Build the GUI
; =============================================================================================
$Main_Gui = GUICreate($Title & " ", 320, 165, -1, -1, BitOr($WS_POPUP,$WS_CAPTION))
GUISetState(@SW_SHOW)
GuiSetIcon("Logon.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Cancel")
$SetLogon_Pic = GuiCtrlCreatePic("Logon_Full.jpg", 0, 0, 320, 60)
    GuiCtrlSetState($SetLogon_Pic,$GUI_DISABLE)
$User_Label = GUICtrlCreateLabel("User: ",10,72,90,20)
$User = GUICtrlCreateInput("",105,70,205,20, $ES_LOWERCASE)
    ControlFocus("", "", $User)
$Password_Label = GUICtrlCreateLabel("Password: ",10,102,90,20)
$Password = GUICtrlCreateInput("",105,100,205,20, $ES_PASSWORD)
$Button_OK = GUICtrlCreateButton("OK", 155, 130, 75, 25)
    GUICtrlSetOnEvent($Button_OK, "_ok")
$Button_Shutdown = GUICtrlCreateButton("Shutdown...", 235, 130, 75, 25)
    GUICtrlSetOnEvent($Button_Shutdown, "_Shutdown")

GUISetState()

While 1
    Sleep(10); Slows down the script to minimize CPU usage
WEnd
; =============================================================================================
; Function _OK()
; Create or edit the current user (using MD5 encryption)
; =============================================================================================
Func _OK()
    Select
        Case GUICtrlRead($User) = ""
            MsgBox(8256,"No user specified","Please enter a user name.")
            ControlFocus("", "", $User)
            Return
        Case StringLen(GUICtrlRead($User)) < $Min_User_Length
            MsgBox(8208,"User name is not valid","Please make sure the user name is at least " & $Min_User_Length & " characters long.")
            GUICtrlSetData($User,"")
            ControlFocus("", "", $User)
            Return
        Case GUICtrlRead($Password) = ""
            MsgBox(8256,"No password specified","Please enter a password.")
            ControlFocus("", "", $Password)
            Return
        Case StringLen(GUICtrlRead($Password)) < $Min_Password_Length
            MsgBox(8208,"Password is not valid","Please make sure the password is at least " & $Min_Password_Length & " characters long.")
            GUICtrlSetData($Password,"")
            ControlFocus("", "", $Password)
            Return
    EndSelect
If Not FileExists($Pass_List) Then
    MsgBox(8208,"No user's found","The user list could not be found." & @CRLF & @CRLF & "This PC will now shut down.")
    _Shutdown()
Else
    $Current_Users = IniReadSectionNames($Pass_List)
EndIf
If IsArray($Current_Users) Then
    $Found_User = "no"
    For $u = 1 To $Current_Users[0]
        $Current_Users_Split = StringSplit($Current_Users[$u], "!")
            If $Current_Users_Split[1] = GUICtrlRead($User) Then
                $Found_User = "yes"
                $Selected_User_Name = $Current_Users[$u]
                ExitLoop
            EndIf
    Next
Else
    MsgBox(8208,"No user's found","The user list could not be found." & @CRLF & @CRLF & "This PC will now shut down.")
    _Shutdown()
EndIf
If $Found_User = "yes" Then
    $User_Info = IniRead($Pass_List , $Selected_User_Name, "password", "")
    $Split_Name = StringSplit($Selected_User_Name, "!")
    $Split_User_Info = StringSplit($User_Info, "!")
    If $Split_Name[2] = MD5("no") Then
        If MD5(GUICtrlRead($Password)) = $Split_User_Info[1] Then
            MsgBox(8256,"Correct password", "You entered the correct password. Congrats!")
            _Cancel()
        Else
;           $Attempt_Count = $Attempts_Allowed - 1
            MsgBox(8256,"Wrong password", "You entered an incorrect password. Please try again.")
            GUICtrlSetData($Password,"")
            ControlFocus("", "", $Password)
            Return
        EndIf
    Else
    ;verify dates
        If MD5(_DateTimeFormat( _NowCalc(),2)) < $Split_User_Info[2] Then
            MsgBox(8256,"User has expired", "This user has an expired account.  Please try another user.")
            GUICtrlSetData($User,"")
            ControlFocus("", "", $User)
            GUICtrlSetData($Password,"")
            Return
        ElseIf MD5(_DateTimeFormat( _NowCalc(),2)) > $Split_User_Info[3] Then
            MsgBox(8256,"User has expired", "This user has an expired account.  Please try another user.")
            ControlFocus("", "", $User)
            GUICtrlSetData($Password,"")
            Return
        Else
            MsgBox(8256,"Correct password", "You entered the correct password. Congrats!")
            _Cancel()
        EndIf
    EndIf
Else
    MsgBox(8208,"Invalid user","The user does not exist." & @CRLF & @CRLF & "Please try again.")
    GUICtrlSetData($User,"")
    ControlFocus("", "", $User)
    GUICtrlSetData($Password,"")
    Return
EndIf
EndFunc  ; ==> _OK
; =============================================================================================
; Function _Shutdown()
; =============================================================================================
Func _Shutdown()
    MsgBox(0, "Shutting Down", "You pressed Shutdown!")
    _Cancel()
; Use Paraglider's shutdown tool
EndFunc  ; ==> _Shutdown
; =============================================================================================
; Function _Middle
; Center Window on Screen
; =============================================================================================
Func _Middle($win, $txt)
    $size = WinGetClientSize($win, $txt)
    Local $y = (@DesktopHeight / 2) - ($size[1] / 2)
    Local $x = (@DesktopWidth / 2) - ($size[0] / 2)
    Return WinMove($win, $txt, $x, $y)
    Return
EndFunc  ; ==> _Middle
; =============================================================================================
; Function _Cancel()
; =============================================================================================
Func _Cancel()
    Exit
EndFunc  ; ==> _Cancel

Share this post


Link to post
Share on other sites



I forgot to attach the Pass.ini. This needs to be in the same folder as the above script.

Pass.ini

[administrator!7fa3b767c460b54a2be4d49030b349c7]
password=200ceb26807d6bf99fd6f4f0d1ca54d4!0f6cf78b4db217f4f73f5ca21e827a75!d22d6a9e946f702cdd1d10d10ed3ea90

The ID and Password are set to administrator.

Share this post


Link to post
Share on other sites

For the GUI stay on top, you need the $WS_EX_TOPMOST style or use the Winsetontop("","",1)

Also, the PC Lockout window has to be set non-topmost

:whistle:


F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]

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