Jump to content

Thudo

Active Members
  • Posts

    80
  • Joined

  • Last visited

About Thudo

  • Birthday 08/08/1972

Profile Information

  • Location
    North Toronto, Canada

Thudo's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Ok figured out the ESC, ENTER, and Red-X issues.. Use the GUISetAccelerators() and now have this working well. $hPasswordGetter = GUICreate('Login', 330, 85, -1, -1, BitOR($WS_DLGFRAME, $WS_CAPTION, $WS_EX_TOPMOST)) GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN') ; Prevent Login box from being moved $hPG_Label = GUICtrlCreateGroup('Enter Password ' & (FileReadLine($sav, 5)), 4, 10, 323, 40) $hPG_Input = GUICtrlCreateInput("", 10, 25, 310, 20, $ES_PASSWORD) GUICtrlSetState($hPG_Input, $GUI_FOCUS) $hPG_OK = GUICtrlCreateButton('OK', 100, 55, 50, 20) $hPG_Cancel = GUICtrlCreateButton('Cancel', 185, 55, 50, 20) Dim $GUIKeys[2][2]=[["{ENTER}", $hPG_OK], ["{ESC}", $hPG_Cancel]] GUISetAccelerators($GUIKeys)Note the changes in BitOR (which removes the top-right Red-X) and the addition of the Hotkeys using GUISetAccelerators.
  2. Mega thanks to forum user MELBA for drastically spring boarding this project. With this help, I'm almost at the finishing line. Just have some lingering issues to resolve. The script in question: #include <Crypt.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <WinAPI.au3> #include <Timers.au3> TraySetState(2) ; Disable the tray icon ; Clear screensaver backup files when possible. Local $Userprofile = envget("USERPROFILE") Local $Usertemp = ($Userprofile&"\Local Settings\Temp\") FileDelete($Usertemp&"\~DF*.tmp") Global $sav, $sPath, $lticks, $GUI, $CGUI, $PGUI, $PIC, $bl_ScreenSaver = False, $w = @DesktopWidth, $h = @DesktopHeight Global $parent_PID = "", $hWnd = "" Global $bmp = False, $jpg = False, $gif = False Global $s_path, $n_disp ; Determine cfg paths Global $TempDir = ("") ; network path to cfg Global $TempDir2 = ("C:\DATA\") ; local path to cfg (used as backup) ; Ensure network path is always backed-up to local path. If FileExists($TempDir) Then FileCopy($TempDir, $TempDir2, 1) EndIf ; Choose alternate path if primary does not exist If FileExists($TempDir) Then $sav = $TempDir & '\ScreenSaver.cfg' Else $sav = $TempDir2 & '\ScreenSaver.cfg' EndIf $sPath = FileReadLine($sav, 1) #Region Check cfg If Not FileExists($sav) Then FileWrite($sav, "C:\DATA\SCREENSAVER\") ; where the images are stored FileWrite($sav, @CRLF & '15000') ; Time in ms between image transitions (standard is 15 seconds) FileWrite($sav, @CRLF & '.bmp|.jpg|.gif') ; Image formats supported FileWrite($sav, @CRLF & '420000') ; Time in ms between idle timeouts (standard is 7 minutes) FileWrite($sav, @CRLF & "0x098F6BCD4621D373CADE4E832627B4F6") ; 'test' default Hash password to unlock screensaver (in MD5 Encyption) FileWrite($sav, @CRLF & "0x6D662F965D1E85BB367EFAA03594C5A1") ; 'sdm' master unchanging Hash password to unlock screensaver for support teams (in MD5 Encyption) EndIf #EndRegion Check cfg ; Set Hotkey to invoke password HotKeySet("^!{l}", "_ScreenSaverHotKey") ; Ctrl+Alt+L #Region Pref Create $PGUI = GUICreate('Picture Screen Saver', 350, 150, -1, -1, BitOR(0x00040000, 0x00000080)) GUICtrlCreateGroup('Pictures folder', 5, 5, 335, 42) $p_pic = GUICtrlCreateEdit(FileReadLine($sav, 1), 10, 20, 270, 20, 2048 + 128) $hPGUI_Browse = GUICtrlCreateButton('Browse', 285, 20, 50, 20) GUICtrlCreateGroup('Display picture extension...', 5, 50, 155, 40) $bmp = GUICtrlCreateCheckbox('.bmp', 15, 65) $jpg = GUICtrlCreateCheckbox('.jpg', 70, 65) $gif = GUICtrlCreateCheckbox('.gif', 120, 65) GUICtrlCreateGroup('Display time', 170, 50, 80, 40) $tdisp = GUICtrlCreateEdit(FileReadLine($sav, 2), 180, 67, 60, 17, 8192 + 128) GUICtrlCreateGroup('Idle timeout', 260, 50, 80, 40) $tidle = GUICtrlCreateEdit(FileReadLine($sav, 4), 270, 67, 60, 17, 8192 + 128) $hPGUI_Apply = GUICtrlCreateButton('Apply', 140, 95, 80, 20) GUISetState(@SW_HIDE, $PGUI) #EndRegion Pref Create If Not FileExists($sav) Then ; Check for command line If Not $CmdLine[0] Then ConsoleWrite('!> $CmdLine[0]' & @CRLF) ; Exit if no CmdLine Exit ElseIf StringInStr($CmdLine[1], '/p') Then If $CmdLine[0] < 2 Then MsgBox(48, 'Picture scr', 'Invalid preview window information supplied.') Exit Else $parent_PID = _ProcessGetParent(@AutoItPID) $w = 152 $h = 112 $hWnd = HWnd($CmdLine[2]) EndIf ElseIf Not StringInStr($CmdLine[1], '/s') Then _PrefOpen() EndIf EndIf $s_path = FileReadLine($sav, 1) $n_disp = FileReadLine($sav, 2) $Poss_Ext = FileReadLine($sav, 3) $i_WaitIdleTime = FileReadLine($sav, 4) $check = FileFindFirstFile($s_path & '*.*') If $check = -1 Then ConsoleWrite('!> FileFindFirstFile' & Chr(13)) Exit EndIf While 1 $sNext = FileFindNextFile($check) If @error Then ; No valid files $sNext = "" ExitLoop EndIf If StringInStr($sNext, ".") Then $s_Ext = StringRegExpReplace($sNext, "^.*\.", ".$1") If StringRegExp($s_Ext, "(?i)" & $Poss_Ext) Then ExitLoop EndIf WEnd ; On first run, don't start screensaver immediately, wait for idle time to expire. ;~ If _Timer_GetIdleTime() > $i_WaitIdleTime Then ;_WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h, $hWnd) ;~ EndIf If ($s_Ext = '.bmp') And $bmp = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) ElseIf ($s_Ext = '.jpg') And $jpg = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) ElseIf ($s_Ext = '.gif') And $gif = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) EndIf $iBegin = TimerInit() Sleep(500) ; Allow settle time from start click While 1 Sleep(10) Switch $bl_ScreenSaver Case True ; Has user actioned something in the last 500 ms If _Timer_GetIdleTime() < 500 Then _TurnOnSplash() Switch _AskPassword() ; Password good Case 1 ; Stop screensaver $bl_ScreenSaver = False _TurnOffSplash() ; Cancel pressed Case 0 ; Restart screensaver ;_WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h, $hWnd) _TurnOffSplash() ; Password fail x 5 Case -1 ; Restart screensaver ;_WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h, $hWnd) _TurnOffSplash() EndSwitch EndIf Case False If _Timer_GetIdleTime() > $i_WaitIdleTime Then ;_WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h, $hWnd) _TurnOffSplash() EndIf EndSwitch If TimerDiff($iBegin) > $n_disp Then While 1 $sNext = FileFindNextFile($check) If @error Then ; No valid files FileClose($check) $check = FileFindFirstFile($s_path & '*.*') ; Go back to the first file $sNext = FileFindNextFile($check) EndIf If StringInStr($sNext, ".") Then $s_Ext = StringRegExpReplace($sNext, "^.*\.", ".$1") If StringRegExp($s_Ext, "(?i)" & $Poss_Ext) Then ExitLoop EndIf WEnd If $parent_PID <> "" Then $child_PID = _ProcessGetChildren($parent_PID) If $child_PID[0] > 1 Then Exit ;Another ss selected If Not WinExists($CmdLine[2]) Then Exit EndIf If ($s_Ext = '.bmp') And $bmp = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) ElseIf ($s_Ext = '.jpg') And $jpg = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) ElseIf ($s_Ext = '.gif') And $gif = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext) EndIf $iBegin = TimerInit() EndIf WEnd #Region Pref Create Func _PrefOpen() GUICtrlSetData($p_pic, FileReadLine($sav, 1)) GUICtrlSetData($tdisp, FileReadLine($sav, 2)) $sExt = StringSplit(FileReadLine($sav, 3), '|') #Region Reset checkbox GUICtrlSetState($bmp, 4) GUICtrlSetState($jpg, 4) GUICtrlSetState($gif, 4) #EndRegion Reset checkbox For $i = 1 To UBound($sExt) - 1 If ($sExt[$i] = '.bmp') Then GUICtrlSetState($bmp, 1) ElseIf ($sExt[$i] = '.jpg') Then GUICtrlSetState($jpg, 1) ElseIf ($sExt[$i] = '.gif') Then GUICtrlSetState($gif, 1) EndIf Next GUISetState(@SW_SHOW, $PGUI) While 1 Switch GUIGetMsg() Case $hPGUI_Browse $path = FileSelectFolder('Select picture folder', @MyDocumentsDir, 1 + 2) If @error Then ConsoleWrite('!> FileSelectFolder' & @CRLF) Exit EndIf GUICtrlSetData($p_pic, $path & '\') Case $hPGUI_Apply FileDelete($sav) FileWrite($sav, GUICtrlRead($p_pic)) If (GUICtrlRead($tdisp) <> '') Then FileWrite($sav, @CRLF & GUICtrlRead($tdisp) & @CRLF) Else FileWrite($sav, @CRLF & '2000' & @CRLF) EndIf If (GUICtrlRead($tidle) <> '') Then FileWrite($sav, @CRLF & GUICtrlRead($tidle) & @CRLF) Else FileWrite($sav, @CRLF & '2000' & @CRLF) EndIf If (GUICtrlRead($bmp) = 1) Then FileWrite($sav, '.bmp|') If (GUICtrlRead($jpg) = 1) Then FileWrite($sav, '.jpg|') If (GUICtrlRead($gif) = 1) Then FileWrite($sav, '.gif|') GUISetState(@SW_HIDE, $PGUI) $bl_ScreenSaver = True EndSwitch WEnd EndFunc ;==>_PrefOpen #EndRegion Pref Create #Region ScreensaverPic ; _ScreenSaverPicture Func _ScreenSaverPicture($width, $height, $hWnd = 'Screen Saver') $bl_ScreenSaver = True Local $s_path = FileReadLine($sav, 1) Local $n_disp = FileReadLine($sav, 2) If ($hWnd = 'Screen Saver') Then Global $GUI = GUICreate('Screen Saver', @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000) GUISetBkColor(0x000000, $GUI) GUISetState(@SW_SHOW, $GUI) WinSetOnTop($GUI, "", 1) EndIf Global $CGUI = GUICreate('Screen Saver', $width, $height, 0, 0, 0x80000000, 0x00000008, $hWnd) _WinAPI_SetParent($CGUI, $hWnd) $PIC = GUICtrlCreatePic('', 0, 0, $width, $height) GUISetBkColor(0x000000, $CGUI) GUISetState(@SW_SHOW, $CGUI) $sExt = StringSplit(FileReadLine($sav, 3), '|') For $i = 1 To UBound($sExt) - 1 If ($sExt[$i] = '.bmp') Then $bmp = True ElseIf ($sExt[$i] = '.jpg') Then $jpg = True ElseIf ($sExt[$i] = '.gif') Then $gif = True EndIf Next Sleep(500) EndFunc ;==>_ScreenSaverPicture ; Randomize image transitions Func __SetPicture($hGUI, $ID, $p_path) _WinAnimate($hGUI, Random(1, 10, 1), 2, 700) GUICtrlSetImage($ID, $p_path) _WinAnimate($hGUI, Random(1, 10, 1), 1, 700) EndFunc ;==>__SetPicture #EndRegion ScreensaverPic Func _ScreenSaverHotKey() _WinAPI_ShowCursor(1) _TurnOnSplash() _AskPassword() _TurnOffSplash() EndFunc #Region Password Func _AskPassword() ; Stop screensaver $bl_ScreenSaver = False GUIDelete($CGUI) GUIDelete($GUI) _WinAPI_ShowCursor(1) Local $bPasswordHash = (FileReadLine($sav, 5)) Local $bMasterPasswordHash = (FileReadLine($sav, 6)) Local $iXTimes = 5, $iCount = 0 Local $sPassword = "" $hPasswordGetter = GUICreate('Login', 330, 85, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION), $WS_EX_TOPMOST) GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN') ; Prevent Login box from being moved $hPG_Label = GUICtrlCreateGroup('Enter Password ' & (FileReadLine($sav, 5)), 4, 10, 323, 40) $hPG_Input = GUICtrlCreateInput("", 10, 25, 310, 20, $ES_PASSWORD) GUICtrlSetState($hPG_Input, $GUI_FOCUS) $hPG_OK = GUICtrlCreateButton('OK', 100, 55, 50, 20) $hPG_Cancel = GUICtrlCreateButton('Cancel', 185, 55, 50, 20) GUISetState() While 1 Switch GUIGetMsg() Case $hPG_OK GUISetState(@SW_HIDE, $hPasswordGetter) $iCount += 1 If $iCount = $iXTimes Then ;BlockInput(1) ; Freeze user's mouse/keyboard -- likely will omit this but here for testing the lock down. MsgBox(16, "Failed Password Login attempt limit reached", "Please contact your local Support team for Assistance..") GUIDelete(GUISetState(@SW_HIDE, $hPasswordGetter)) Return -1 EndIf $sAttempt = GUICtrlRead($hPG_Input) If _Crypt_HashData($sAttempt, $CALG_MD5) = $bPasswordHash Or _Crypt_HashData($sAttempt, $CALG_MD5) = $bMasterPasswordHash Then Return 1 MsgBox(16, "Access Denied", "Password Incorrect!" & @CR & "You have " & $iXTimes - $iCount & " trys left") GUICtrlSetData($hPG_Input, "") GUICtrlSetState($hPG_Input, $GUI_FOCUS) GUISetState(@SW_SHOW, $hPasswordGetter) Case $hPG_Cancel GUIDelete(GUISetState(@SW_HIDE, $hPasswordGetter)) _MouseTrap() Return 0 EndSwitch WEnd EndFunc ;==>_AskPassword #EndRegion Password Func WM_NCLBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch $wParam Case 0x02 Return 0 EndSwitch Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_NCLBUTTONDOWN Func _TurnOnSplash() $findpic = ("") ; add custom background image if desired. SplashTextOn("", "", @DesktopWidth, @DesktopHeight, -1, -1, 3) EndFunc Func _TurnOffSplash() SplashOff() EndFunc #Region Process functions ; _ProcessGetParent Func _ProcessGetParent($i_pid) Local $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall('Kernel32.dll', 'long', 'CreateToolhelp32Snapshot', 'int', $TH32CS_SNAPPROCESS, 'int', 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid) Local $tagPROCESSENTRY32 = _ DllStructCreate( _ 'dword dwsize;' & _ 'dword cntUsage;' & _ 'dword th32ProcessID;' & _ 'uint th32DefaultHeapID;' & _ 'dword th32ModuleID;' & _ 'dword cntThreads;' & _ 'dword th32ParentProcessID;' & _ 'long pcPriClassBase;' & _ 'dword dwFlags;' & _ 'char szExeFile[260]' _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall('Kernel32.dll', 'int', 'Process32First', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) If $i_return Then Return $i_return Return $i_pid EndIf While @error = 0 $a_pnext = DllCall('Kernel32.dll', 'int', 'Process32Next', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_return Then ExitLoop $i_return = $i_pid ExitLoop EndIf WEnd DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) Return $i_return EndFunc ;==>_ProcessGetParent ; _ProcessGetChildren Func _ProcessGetChildren($i_pid) Local Const $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall('Kernel32.dll', 'long', 'CreateToolhelp32Snapshot', 'int', $TH32CS_SNAPPROCESS, 'int', 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid) Local $tagPROCESSENTRY32 = _ DllStructCreate _ ( _ 'dword dwsize;' & _ 'dword cntUsage;' & _ 'dword th32ProcessID;' & _ 'uint th32DefaultHeapID;' & _ 'dword th32ModuleID;' & _ 'dword cntThreads;' & _ 'dword th32ParentProcessID;' & _ 'long pcPriClassBase;' & _ 'dword dwFlags;' & _ 'char szExeFile[260]' _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall('Kernel32.dll', 'int', 'Process32First', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid) Local $a_pnext, $a_children[11] = [10], $i_child_pid, $i_parent_pid, $i_add = 0 $i_child_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') If $i_child_pid <> $i_pid Then $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_parent_pid = $i_pid Then $i_add += 1 $a_children[$i_add] = $i_child_pid EndIf EndIf While 1 $a_pnext = DllCall('Kernel32.dll', 'int', 'Process32Next', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop $i_child_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') If $i_child_pid <> $i_pid Then $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_parent_pid = $i_pid Then If $i_add = $a_children[0] Then ReDim $a_children[$a_children[0] + 10] $a_children[0] = $a_children[0] + 10 EndIf $i_add += 1 $a_children[$i_add] = $i_child_pid EndIf EndIf WEnd If $i_add <> 0 Then ReDim $a_children[$i_add + 1] $a_children[0] = $i_add EndIf DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) If $i_add Then Return $a_children Return SetError(3, 0, 0) EndFunc ;==>_ProcessGetChildren #EndRegion Process functions #Region WinAnimate Func _WinAnimate($hGUI, $Style = 1, $Ani = 1, $n_speed = 250) Local $sIN = StringSplit('80000,40001,40002,40004,40008,40005,40006,40009,4000A,40010', ',') Local $sOUT = StringSplit('90000,50002,50001,50008,50004,5000A,50009,50006,50005,50010', ',') If $Ani = 1 Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $hGUI, 'int', $n_speed, 'long', '0x000' & $sIN[$Style]) ElseIf $Ani = 2 Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $hGUI, 'int', $n_speed, 'long', '0x000' & $sOUT[$Style]) EndIf EndFunc ;==>_WinAnimate #EndRegion WinAnimate Yep this is a screensaver and yes it won't ever be secure but its a project I need to complete for the environment I work in. MELBA helped clean up my code so now I'm 90% there now. With the above code in mind I am stuck with the following issues to fix. I looked around everywhere and found no resolution as of yet to these.. 1) How to create a HotKey that integrates more appropriately with the running code? Current I use: ; Set Hotkey to invoke password HotKeySet("^!{l}", "_ScreenSaverHotKey") ; Ctrl+Alt+L ..but the problem is this is a static solution as you see it calls the function.. Func _ScreenSaverHotKey() _WinAPI_ShowCursor(1) _TurnOnSplash() _AskPassword() _TurnOffSplash() EndFuncbut this becomes a dead-end and doesn't work if you hit the CANCEL button in the Login Prompt (which should default back to the screensaver). How can I build in a better HotKey functionality here? 2) During the Login Box, hitting ESC, RETURN, or the Top-Right Red-X are disabled. I used to use InputBox and these were enabled. ESC and the Red-X should default back to the screensaver like clicking CANCEL. RETURN would be basically clicking OK. Anyway to enable these? 3) Quick Bonus question: Can _MouseTrap lock a mouse in a MsgBox? I've only see it work with a GUI. When the "Access Denied" message box comes up the _MouseTrap code is broken as its a MsgBox (just like InputBox too). So #1 and #2 are most important right now. If I can get those nailed down I'm good. Thanks so very much Autoit community.. guys have been a lifesaver!
  3. Ok #5 is fixed thanks to this thread. Another question: can I _MouseTrap a MsgBox? When the "Access Denied" comes up it breaks the _MouseTrap then stays broken when the next Login box comes up afterwards.
  4. THANK YOU MELBA! Yes that covers about 90% of what I needed. THANK YOU FOR YOUR PATIENCE!! I've been tweaking your code here and there and the only outstanding issues are: 1) Invoking hotkey so the password GUI comes up: HotKeySet("^!{l}", "_AskPassword") ; Ctrl+Alt+L This works but when after invoking the HotKeySet to bring up the Password UI, if you hit CANCEL it doesn't go back to the screensaver like it would without using the HotKeySet. 2) Sometimes when you hit the CANCEL button the screen goes black and doesn't load an image if the time between transitions number is 15000ms. On the third try of hitting Cancel it usually loads the images. Its not a big deal but curious as to why this happens? 3) During the Login Box, hitting ESC, RETURN, or the Top-Right Red-X are disabled. With InputBox they are enabled. ESC and the Red-X should default back to the screensaver like clicking CANCEL. RETURN would be basically clicking OK. 4) I noticed you use the script GUISetBkColor(0x000000, $GUI) which brought up the black background during image transitions in my older script. Not sure why but in the current build its showing the desktop during transitions instead of a pure black screen. Odd as the code is the same as before. 5) Curious.. how do you lock a GUI box so that its immovable? _MouseTrap works well except if a user goes above in the blue area of the Login Box they can inadvertently hold left-mouse, drag, then they have broken free of the trap. I looked around and found no GUI style to lock the GUI box down so it cannot be moved. You are indeed a savior, Melba.. I'm almost there.. just some lingering bits missing from the original script.
  5. hehe.. it actually works quite well so its more linguine then even angel-haired spaghettini Yep.. this is what was decreed for now as the systems this is being applied on will not have Windows Authentication via AD enabled. Its all profile-based so as a stop-gap measure we have this simulating what we've all taken for granted in Windows since the mid-90s. This works, in principle, but this is easier to do then the incredible task of giving thousands of machines AD logins. Thats why getting this working is really crucial at this point. Yer an absolute life-saver, melba.. beyond the call!
  6. Thanks M.. here is the full code: #include <Crypt.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Misc.au3> #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=ScreenSaver.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseAnsi=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** TraySetState(2) ; Disable the tray icon ; Determine cfg paths Local $TempDir=("") ; network path to cfg Local $TempDir2=("C:\") ; local path to cfg (used as backup) ; Ensure network path is always backed-up to local path. If FileExists($TempDir) then FileCopy($TempDir, $TempDir2, 1) endif ; Choose alternate path if primary does not exist If Not FileExists($TempDir) then Local $sav = $TempDir2 & '\ScreenSaver.cfg', $lticks, $GUI, $CGUI, $bl_ScreenSaver = False Local $sav = $TempDir2 & '\ScreenSaver.cfg', $lticks Local $w = @DesktopWidth, $h = @DesktopHeight, $sPath = FileReadLine($sav, 1) Else Local $sav = $TempDir & '\ScreenSaver.cfg', $lticks, $GUI, $CGUI, $bl_ScreenSaver = False Local $sav = $TempDir & '\ScreenSaver.cfg', $lticks Local $w = @DesktopWidth, $h = @DesktopHeight, $sPath = FileReadLine($sav, 1) endif Opt('GUIOnEventMode', 1) ; Set Hotkey to invoke password HotKeySet("^!{l}", "_ScreenSaverHotKey") ; Ctrl+Alt+L #Region Check cfg If Not FileExists($sav) Then FileWrite($sav, "C:\") ; where the images are stored FileWrite($sav, @CRLF & '15000') ; Time in ms between image transitions (standard is 15 seconds) FileWrite($sav, @CRLF & '.bmp|.jpg|.gif') ; Image formats supported FileWrite($sav, @CRLF & '60000') ; Time in ms between idle timeouts FileWrite($sav, @CRLF & "0x098F6BCD4621D373CADE4E832627B4F6") ; 'test' default Hash password to unlock screensaver (in MD5 Encyption) FileWrite($sav, @CRLF & "0x6D662F965D1E85BB367EFAA03594C5A1") ; 'sdm' master unchanging Hash password to unlock screensaver for support teams (in MD5 Encyption) EndIf #EndRegion Check cfg #Region Pref GUI $PGUI = GUICreate('Picture Screen Saver', 400, 150, -1, -1, BitOR(0x00040000, 0x00000080)) GUISetOnEvent(-3, '_PrefClose') GUICtrlCreateGroup('Pictures folder', 5, 5, 385, 42) $p_pic = GUICtrlCreateEdit(FileReadLine($sav, 1), 10, 20, 320, 20, 2048 + 128) GUICtrlCreateButton('Browse', 335, 20, 50, 20) GUICtrlSetOnEvent(-1, '_Browse') GUICtrlCreateGroup('Display picture extension...', 5, 50, 155, 40) $bmp = GUICtrlCreateCheckbox('.bmp', 15, 65) $jpg = GUICtrlCreateCheckbox('.jpg', 70, 65) $gif = GUICtrlCreateCheckbox('.gif', 120, 65) GUICtrlCreateGroup('Display Time (sec)', 170, 50, 110, 40) $tdisp = GUICtrlCreateEdit(FileReadLine($sav, 2)/1000, 195, 67, 60, 17, 8192 + 128) GUICtrlCreateGroup('Idle Timeout (mins)', 290, 50, 100, 40) $tidle = GUICtrlCreateEdit(FileReadLine($sav, 4)/1000/60, 310, 67, 60, 17, 8192 + 128) GUICtrlCreateButton('Apply', 140, 95, 80, 20) GUICtrlSetOnEvent(-1, '_PrefApply') GUISetState(@SW_HIDE, $PGUI) #EndRegion Pref GUI If @Compiled or NOT @Compiled Then ; Run ScreenSaver regardless _WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h) Else If Not $CmdLine[0] Then Exit ConsoleWrite('!> $CmdLine[0]' & @CRLF) ; Exit if no CmdLine If StringInStr($CmdLine[1], '/p') Then If $CmdLine[0] < 2 Then Exit MsgBox(48, 'Picture scr', 'Invalid preview window information supplied.') $parent_PID = _ProcessGetParent(@AutoItPID) _ScreenSaverPicture(152, 112, HWnd($CmdLine[2])) ElseIf StringInStr($CmdLine[1], '/s') Then _WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h) Else _PrefOpen() EndIf EndIf #Region Pref Func Func _Browse() $path = FileSelectFolder('Select picture folder', @MyDocumentsDir, 1 + 2) If @error Then Exit ConsoleWrite('!> FileSelectFolder' & @CRLF) GUICtrlSetData($p_pic, $path & '\') EndFunc ;==>_Browse Func _PrefApply() FileDelete($sav) FileWrite($sav, GUICtrlRead($p_pic)) If (GUICtrlRead($tdisp) <> '') Then FileWrite($sav, @CRLF & GUICtrlRead($tdisp)*1000 & @CRLF) If (GUICtrlRead($tdisp) = '') Then FileWrite($sav, @CRLF & '2000' & @CRLF) If (GUICtrlRead($bmp) = 1) Then FileWrite($sav, '.bmp|') If (GUICtrlRead($jpg) = 1) Then FileWrite($sav, '.jpg|') If (GUICtrlRead($gif) = 1) Then FileWrite($sav, '.gif|') If (GUICtrlRead($tidle) <> '') Then FileWrite($sav, @CRLF & GUICtrlRead($tidle)*1000*60) If (GUICtrlRead($tidle) = '') Then FileWrite($sav, @CRLF & '2000') FileWrite($sav, @CRLF & "0x098F6BCD4621D373CADE4E832627B4F6") ; 'test' default Hash password to unlock screensaver (in MD5 Encyption) FileWrite($sav, @CRLF & "0x6D662F965D1E85BB367EFAA03594C5A1") ; 'sdm' master unchanging Hash password to unlock screensaver for support teams (in MD5 Encyption) Return Call('_PrefClose') EndFunc ;==>_PrefApply Func _PrefOpen() GUICtrlSetData($p_pic, FileReadLine($sav, 1)) GUICtrlSetData($tdisp, FileReadLine($sav, 2)/1000) $sExt = StringSplit(FileReadLine($sav, 3), '|') #Region Reset checkbox GUICtrlSetState($bmp, 4) GUICtrlSetState($jpg, 4) GUICtrlSetState($gif, 4) #EndRegion Reset checkbox For $i = 1 To UBound($sExt) - 1 If ($sExt[$i] = '.bmp') Then GUICtrlSetState($bmp, 1) ElseIf ($sExt[$i] = '.jpg') Then GUICtrlSetState($jpg, 1) ElseIf ($sExt[$i] = '.gif') Then GUICtrlSetState($gif, 1) EndIf Next GUISetState(@SW_SHOW, $PGUI) EndFunc ;==>_PrefOpen Func _PrefClose() Exit GUISetState(@SW_HIDE, $PGUI) EndFunc ;==>_PrefClose #EndRegion Pref Func While 1 Sleep(250) WEnd Func OnAutoItExit() _WinAPI_ShowCursor(1) EndFunc ;==>OnAutoItExit Func _ScreenSaverHotKey() _WinAPI_ShowCursor(0) _ScreenSaverPicture($w, $h) EndFunc ; Initiates password facility Func _AskPassword() _StopScreenSaver() _PasswordCheck() EndFunc Func _StopScreenSaver() $bl_ScreenSaver = False GUIDelete($CGUI) GUIDelete($GUI) _WinAPI_ShowCursor(1) EndFunc Global $fPassword_Ready = False Func _PasswordCheck() Local $iXTimes = 5, $iCount = 1 While 1 Local $bPasswordHash=(FileReadLine($sav, 5)) Local $bMasterPasswordHash=(FileReadLine($sav, 6)) Local $sPassword= "" While $sPassword = "" $sPassword=_GetPassword() WEnd If _Crypt_HashData($sPassword,$CALG_MD5)=$bPasswordHash or _Crypt_HashData($sPassword,$CALG_MD5)=$bMasterPasswordHash Then Return $sPassword Select Case $sPassword = "Correct" Return 1 Case $iCount = $iXTimes ;~ BlockInput(1) ; Freeze user's mouse/keyboard -- likely will omit this but here for testing the lock down. MsgBox(16, "Failed Password Login attempt limit reached", "Please contact your local Associate or Front Store Manager for Assistance..") Return -1 Case Else MsgBox(16, "Access Denied", "Password Incorrect!" & @CR & "You have " & $iXTimes - $iCount & " trys left") $iCount += 1 EndSelect WEnd EndFunc ;==>_PasswordCheck Func _GetPassword() $hPasswordGetter = GUICreate('Login', 330, 85, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION), $WS_EX_TOPMOST) $hPG_Label = GUICtrlCreateGroup('Enter Password '&(FileReadLine($sav, 5)), 4, 10, 323, 40) $hPG_Input = GUICtrlCreateInput("", 10, 25, 310, 20, $ES_PASSWORD) $hPG_Button = GUICtrlCreateButton('OK', 100, 55, 50, 20) GUICtrlSetOnEvent(-1, "_PG_Button") $hCL_Button =GUICtrlCreateButton('Cancel', 185, 55, 50, 20) GUICtrlSetOnEvent(-1, "_ScreenSaverReturn") GUISetState() Local $aPos = WinGetPos($hPasswordGetter) ;~ _MouseTrap($aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3]) ; -- disabled for testing purposes Local $sPassword = "" $fPassword_Ready = False While $sPassword = "" While $fPassword_Ready = False Sleep(10) WEnd $fPassword_Ready = False Local $sPassword = GUICtrlRead($hPG_Input) WEnd GUIDelete($hPasswordGetter) ;~ _MouseTrap() ; -- disabled for testing purposes Return $sPassword EndFunc Func _PG_Button() $fPassword_Ready = True EndFunc Func _ScreenSaverReturn() _ScreenSaverHotKey() EndFunc ; _ScreenSaverPicture Func _ScreenSaverPicture($width, $height, $hwnd = 'Screen Saver') $bl_ScreenSaver = True If ($hwnd = 'Screen Saver') Then Global $GUI = GUICreate('Screen Saver', @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000) GUISetBkColor(0x000000, $GUI) GUISetState(@SW_SHOW, $GUI) WinSetOnTop($GUI, "", 1) EndIf Global $CGUI = GUICreate('Screen Saver', $width, $height, 0, 0, 0x80000000, 0x00000008, $hwnd) _WinAPI_SetParent($CGUI, $hwnd) $PIC = GUICtrlCreatePic('', 0, 0, $width, $height) GUISetBkColor(0x000000, $CGUI) GUISetState(@SW_SHOW, $CGUI) Local $s_path = FileReadLine($sav, 1) Local $n_disp = FileReadLine($sav, 2) Local $bmp = False, $jpg = False, $gif = False $sExt = StringSplit(FileReadLine($sav, 3), '|') For $i = 1 To UBound($sExt) - 1 If ($sExt[$i] = '.bmp') Then $bmp = True ElseIf ($sExt[$i] = '.jpg') Then $jpg = True ElseIf ($sExt[$i] = '.gif') Then $gif = True EndIf Next While $bl_ScreenSaver = True $check = FileFindFirstFile($s_path & '*.*') If $check = -1 Then Exit ConsoleWrite('!> FileFindFirstFile' & Chr(13)) While $bl_ScreenSaver = True Sleep(300) $sNext = FileFindNextFile($check) If @error Then ExitLoop ; Go to the first file $s_Ext = StringRegExpReplace($sNext, '^.*\.', '') If ($hwnd = 'Screen Saver') Then If _IdleTicks() Then _AskPassword() Else $child_PID = _ProcessGetChildren($parent_PID) If $child_PID[0] > 1 Then Exit ;Another ss selected If Not WinExists($hwnd) Then Exit EndIf If ($s_Ext = 'bmp') And $bmp = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext, $n_disp, $hwnd) ElseIf ($s_Ext = 'jpg') And $jpg = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext, $n_disp, $hwnd) ElseIf ($s_Ext = 'gif') And $gif = True Then __SetPicture($CGUI, $PIC, $s_path & $sNext, $n_disp, $hwnd) EndIf WEnd ConsoleWrite('!> FileFindNextFile' & Chr(13)) WEnd EndFunc ;==>_ScreenSaverPicture ; Edit how the screensaver cycles images (currently set to be random) Func __SetPicture($hGUI, $ID, $p_path, $idisp, $hwnd) GUICtrlSetImage($ID, $p_path) _WinAnimate($hGUI, Random(1, 10, 1), 1, 700) $Init = TimerInit() While 1 Sleep(300) If ($hwnd = 'Screen Saver') Then If _IdleTicks() Then _AskPassword() Else $child_PID = _ProcessGetChildren($parent_PID) If $child_PID[0] > 1 Then Exit ;Another ss selected If Not WinExists($hwnd) Then Exit EndIf If TimerDiff($Init) > $idisp Then ExitLoop WEnd _WinAnimate($hGUI, Random(1, 10, 1), 2, 500) EndFunc ;==>__SetPicture ; _WinAPI_SetParent Func _WinAPI_SetParent($hWndChild, $hWndParent) Local $aResult $aResult = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $hWndParent) Return $aResult[0] EndFunc ;==>_WinAPI_SetParent ; _WinAPI_ShowCursor Func _WinAPI_ShowCursor($fShow) Local $aResult $aResult = DllCall('User32.dll', 'int', 'ShowCursor', 'int', $fShow) If @error Then Return SetError(@error, 0, 0) Return $aResult[0] EndFunc ;==>_WinAPI_ShowCursor ; _WinAnimate Func _WinAnimate($hGUI, $Style = 1, $Ani = 1, $n_speed = 250) Local $sIN = StringSplit('80000,40001,40002,40004,40008,40005,40006,40009,4000A,40010', ',') Local $sOUT = StringSplit('90000,50002,50001,50008,50004,5000A,50009,50006,50005,50010', ',') If $Ani = 1 Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $hGUI, 'int', $n_speed, 'long', '0x000' & $sIN[$Style]) ElseIf $Ani = 2 Then DllCall('user32.dll', 'int', 'AnimateWindow', 'hwnd', $hGUI, 'int', $n_speed, 'long', '0x000' & $sOUT[$Style]) EndIf EndFunc ;==>_WinAnimate ; _IdleTicks Func _IdleTicks() Local $aTSB = DllCall('kernel32.dll', 'long', 'GetTickCount') Local $ticksSinceBoot = $aTSB[0] Local $struct = DllStructCreate('uint;dword') DllStructSetData($struct, 1, DllStructGetSize($struct)) DllCall('user32.dll', 'int', 'GetLastInputInfo', 'ptr', DllStructGetPtr($struct)) Local $ticksSinceIdle = DllStructGetData($struct, 2) If ($ticksSinceBoot - $ticksSinceIdle) < $lticks Then Return 1 $lticks = ($ticksSinceBoot - $ticksSinceIdle) EndFunc ;==>_IdleTicks ; This part disabled as doesn't work as expected. Above _IdleTicks used for testing purposes. ; ----------------------------------------------- ;~ Func _IdleTicks() ;Dim $i_WaitIdleTime = (FileReadLine($sav, 4)) ; 10*1000 ;=10sec (ms) // only for example then you will read this value in the config file ;~ Local $h_GTC = DllCall('kernel32.dll', 'long', 'GetTickCount') ;~ Local $i_Ticks_Init = $h_GTC[0] ;~ Local $struct = DllStructCreate('uint;dword') ;~ Local $i_WaitIdleTime = (FileReadLine($sav, 4)) ; 10*1000 ;=10sec (ms) // read from value in the config file ;~ DllStructSetData($struct, 1, DllStructGetSize($struct)) ;~ DllCall('user32.dll', 'int', 'GetLastInputInfo', 'ptr', DllStructGetPtr($struct)) ;~ Local $i_TicksSinceIdle = DllStructGetData($struct, 2) ;~ If ($i_Ticks_Init - $i_TicksSinceIdle) > $i_WaitIdleTime Then ;~ MsgBox(64, "", "Now we can start the screensaver") ;~ EndIf ;~ EndFunc ;==>_IdleTicks ; _ProcessGetParent Func _ProcessGetParent($i_pid) Local $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall('Kernel32.dll', 'long', 'CreateToolhelp32Snapshot', 'int', $TH32CS_SNAPPROCESS, 'int', 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid) Local $tagPROCESSENTRY32 = _ DllStructCreate( _ 'dword dwsize;' & _ 'dword cntUsage;' & _ 'dword th32ProcessID;' & _ 'uint th32DefaultHeapID;' & _ 'dword th32ModuleID;' & _ 'dword cntThreads;' & _ 'dword th32ParentProcessID;' & _ 'long pcPriClassBase;' & _ 'dword dwFlags;' & _ 'char szExeFile[260]' _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall('Kernel32.dll', 'int', 'Process32First', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) If $i_return Then Return $i_return Return $i_pid EndIf While @error = 0 $a_pnext = DllCall('Kernel32.dll', 'int', 'Process32Next', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') = $i_pid Then $i_return = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_return Then ExitLoop $i_return = $i_pid ExitLoop EndIf WEnd DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) Return $i_return EndFunc ;==>_ProcessGetParent ; _ProcessGetChildren Func _ProcessGetChildren($i_pid) Local Const $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall('Kernel32.dll', 'long', 'CreateToolhelp32Snapshot', 'int', $TH32CS_SNAPPROCESS, 'int', 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid) Local $tagPROCESSENTRY32 = _ DllStructCreate _ ( _ 'dword dwsize;' & _ 'dword cntUsage;' & _ 'dword th32ProcessID;' & _ 'uint th32DefaultHeapID;' & _ 'dword th32ModuleID;' & _ 'dword cntThreads;' & _ 'dword th32ParentProcessID;' & _ 'long pcPriClassBase;' & _ 'dword dwFlags;' & _ 'char szExeFile[260]' _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall('Kernel32.dll', 'int', 'Process32First', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid) Local $a_pnext, $a_children[11] = [10], $i_child_pid, $i_parent_pid, $i_add = 0 $i_child_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') If $i_child_pid <> $i_pid Then $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_parent_pid = $i_pid Then $i_add += 1 $a_children[$i_add] = $i_child_pid EndIf EndIf While 1 $a_pnext = DllCall('Kernel32.dll', 'int', 'Process32Next', 'long', $a_tool_help[0], 'ptr', $p_PROCESSENTRY32) If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop $i_child_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ProcessID') If $i_child_pid <> $i_pid Then $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, 'th32ParentProcessID') If $i_parent_pid = $i_pid Then If $i_add = $a_children[0] Then ReDim $a_children[$a_children[0] + 10] $a_children[0] = $a_children[0] + 10 EndIf $i_add += 1 $a_children[$i_add] = $i_child_pid EndIf EndIf WEnd If $i_add <> 0 Then ReDim $a_children[$i_add + 1] $a_children[0] = $i_add EndIf DllCall('Kernel32.dll', 'int', 'CloseHandle', 'long', $a_tool_help[0]) If $i_add Then Return $a_children Return SetError(3, 0, 0) EndFunc ;==>_ProcessGetChildren For testing purposes.. put this in C:\ drive and name it screensaver.cfg. Otherwise, the above code will assume its not there and create one for you. C:\ 5000 .bmp|.jpg|.gif 60000 0x136E264E94E5BE49096C7A54F33646B8 0x6D662F965D1E85BB367EFAA03594C5A1Password is "test". You can throw a single .bmp or .gif or .jpg file in C:\ to see the test or leave no image files and screen will be dark where images would be displayed.
  7. Well I can forgo #3 and focus on #1 and #2 because those essentially worked with the older InputBox. So the current code I am having the most problems with is still the one I posted this afternoon here just above. If we can get by why that code is not reading the user's input and passing it to the MD5 hash then determine how to get CANCEL and ESC keys to kill the Login GUI then that's a big step. Do you want me to post the entire code with your changes or just tackling the Password GUI first? I want to be as accommodating as possible.
  8. Oddly, when I enter the right password nothing happens when I click OK. If the password is correct, its supposed to kill the Login GUI but right now it just flashes back to the Login GUI after clicking OK. Putting in a wrong password is supposed to bring up the "Invalid Password" warning box but just goes back to the Login GUI box. CANCEL and hitting the ESC key are supposed to kill the Login GUI and put it back to its original state but does nothing currently. Fer sure.. that will allow you to see the larger picture: Full code with explanation is actually posted right above in this post. Whats different is that _PasswordCheck() and _GetPassword() have been substituted with your coding facility so the older InputBox was omitted. Hope that helps..
  9. Ok I've cleaned up the GUI so it looks the form. Its working much better now that MouseTrap detects the GUI box. Here is the updated code: Global $fPassword_Ready = False Func _PasswordCheck() Local $iXTimes = 5, $iCount = 1 While 1 Local $bPasswordHash=(FileReadLine($sav, 5)) Local $bMasterPasswordHash=(FileReadLine($sav, 6)) Local $sPassword= "" While $sPassword = "" $sPassword=_GetPassword() WEnd If _Crypt_HashData($sPassword,$CALG_MD5)=$bPasswordHash or _Crypt_HashData($sPassword,$CALG_MD5)=$bMasterPasswordHash Then Return $sPassword Select Case $sPassword = "" Return 0 _ScreenSaverReturn() Case $sPassword = "Correct" Return 1 Case $iCount = $iXTimes ;~ BlockInput(1) ; Freeze user's mouse/keyboard -- likely will omit this but here for testing the lock down. MsgBox(16, "Failed Password Login attempt limit reached", "Please contact help desk for Assistance..") Return -1 Case Else MsgBox(16, "Access Denied", "Password Incorrect!" & @CR & "You have " & $iXTimes - $iCount & " trys left") $iCount += 1 EndSelect WEnd EndFunc ;==>_PasswordCheck Func _GetPassword() $hPasswordGetter = GUICreate('Login', 330, 85, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION), $WS_EX_TOPMOST) $hPG_Label = GUICtrlCreateGroup('Enter Password '&(FileReadLine($sav, 5)), 4, 10, 323, 40) $hPG_Input = GUICtrlCreateInput("", 10, 25, 310, 20, $ES_PASSWORD) $hPG_Button = GUICtrlCreateButton('OK', 100, 55, 50, 20) GUICtrlSetOnEvent(-1, "_PG_Button") $hCL_Button =GUICtrlCreateButton('Cancel', 185, 55, 50, 20) GUICtrlSetOnEvent(-1, "_ScreenSaverReturn") GUISetState() Local $aPos = WinGetPos($hPasswordGetter) ;~ _MouseTrap($aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3]) Local $sPassword = "" $fPassword_Ready = False While $sPassword = "" While $fPassword_Ready = False Sleep(10) WEnd $fPassword_Ready = False Local $sPassword = GUICtrlRead($hPG_Input) WEnd GUIDelete($hPasswordGetter) ;~ _MouseTrap() Return $sPassword EndFunc Func _PG_Button() $fPassword_Ready = True EndFunc Func _ScreenSaverReturn() _ScreenSaverHotKey() EndFunc ;==>_ScreenSaverReturnHere is what is left to figure out: 1) $hPG_Input is not piping the user's input over to _PasswordCheck() to be checked if its valid or not. Not sure whats wrong here. 2) Is it possible when the user hits the ESC key or the CANCEL button it can revert back to its pre-GUI state basically calling "_ScreenSaverReturn()" which then calls "_ScreenSaverHotKey()". It used to sort of do this back when I used the InputBox but not sure why it won't properly work with a GUI? It works for CANCEL (although see #3) but not for ESC. 3) One thing I don't quite understand is when I hit the CANCEL button it runs "_ScreenSaverReturn" fine by reverting back to the screensaver. But when the Password GUI up there is re-called a second time, the CANCEL button doesn't invoke "_ScreenSaverReturn" -- it simply goes back to the Password GUI. Can it be set to keep looping back to "_ScreenSaverReturn" like it does the first time? Not sure why it works on the first CANCEL but not afterwards. Thanks so much Melba and everyone else who can assist.. I'm nearly there..
  10. Most wonderful Melba.. I'll experiment with it then let you know. You are indeed a gem!
  11. Thanks Melba.. one step closer except its not the GUI I couldn't create its how to merge the original Inputbox code over to GUI then ensure the _PasswordCheck() facility actually integrated like it did with the InputBox. Thats what has me cooked. Again, I am in your debt with this effort!
  12. Ok to give you an idea what I am looking to do based on my requests above I created this mock-up of the login box+working mousetrap.. #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('GUIOnEventMode', 1) Local $sav = ("C:\DATA\ScreenSaver.cfg") #Region Pref GUI $PASSGUI = GUICreate('Login', 330, 110, -1, -1, BitOR(0x00040000, 0x00000080)) GUISetOnEvent(-3, '_PrefClose') GUICtrlCreateGroup('Enter Password '&(FileReadLine($sav, 5)), 5, 10, 320, 40) $password = GUICtrlCreateInput("", 10, 25, 310, 20, 0x0020) ; $ES_PASSWORD style <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateButton('OK', 100, 55, 50, 20) GUICtrlSetOnEvent(-1, '_PrefClose') GUISetState(@SW_HIDE, $PASSGUI) GUICtrlCreateButton('Cancel', 185, 55, 50, 20) GUICtrlSetOnEvent(-1, '_PrefClose') GUISetState(@SW_HIDE, $PASSGUI) #EndRegion Pref GUI ; Always run the application _PrefOpen() Func _MouseTrapCurrent($hWin) If WinExists($hWin) Then $Pos = WinGetPos($hWin) If Not @error Then _MouseTrap($Pos[0], $Pos[1], $Pos[0] + $Pos[2], $Pos[1] + $Pos[3]) EndIf Else _MouseTrap() Endif EndFunc While 1 _MouseTrapCurrent('Login') WEnd Switch _PasswordCheck() Case 1 MsgBox(0, "Result", "Login Correct") Case 0 MsgBox(0, "Result", "Login Cancelled ") case -1 MsgBox(0, "Result", "Failed 5 times lock out user") EndSwitch Func _PasswordCheck() Local $iXTimes = 5, $iCount = 1 While 1 Local $bPasswordHash=(FileReadLine($sav, 5)) Local $bMasterPasswordHash=(FileReadLine($sav, 6)) If _Crypt_HashData($sPassword,$CALG_MD5)=$bPasswordHash or _Crypt_HashData($sPassword,$CALG_MD5)=$bMasterPasswordHash Then Return $sPassword Select Case $sPassword = "Correct" Return 1 Case $iCount = $iXTimes MsgBox(16, "Failed Password Login attempt limit reached", "Please contact your local Associate or Front Store Manager for Assistance..") Return -1 Case Else MsgBox(16, "Access Denied", "Password Incorrect!" & @CR & "You have " & $iXTimes - $iCount & " trys left") $iCount += 1 EndSelect WEnd EndFunc ;==>_PasswordCheck Func _PrefOpen() GUISetState(@SW_SHOW, $PASSGUI) EndFunc ;==>_PrefOpen Func _PrefClose() Exit GUISetState(@SW_HIDE, $PASSGUI) EndFunc ;==>_PrefClose #EndRegion Pref Func While 1 Sleep(10) WEndI hope this gives an idea of how to move the _PasswordCheck over so its read by the GUI I've put in instead of the InputBox as this part is killing me.
  13. Anyone willing to tackle this? I would so appreciate the help!
  14. Any thoughts on the above? I seriously need that InputBox replaced with the GUI code so _MouseTrap will work. I simply cannot get the code migrated over. If I can get that resolved, I likely can move forward.
  15. Hi Cameron.. One of my biggest hurtles is getting that GUI to replace the inputbox.. you'll notice the inputbox there which works but inputboxes cannot work with _MouseTrap whereas GUIs do hence why I need to move away from that InputBox to the GUI you see commented out (which I was playing with but still failed to integrate). So essentially what I want to do is: 1) Get the GUI to replace the InputBox 'Login' box (right now, the password facility works fine with the InputBox but not _MouseTrap). If you can get the GUI to replace the InputBox 'Login' that would be incredible. 2) Once the GUI is setup to use it as a 'Login', then getting _MouseTrap to work with the GUI to freeze the user in-place inside the newly working GUI 'Login' box. It works in-principle solidly with the GUI but I've had a bloody hard time getting #1 figured out. 3) Anything else you see in my code that might need some tweaks. Essentially, this whole exercise is one where our systems need to mimic Windows Authentication over AD. We do not have AD built in our systems so we need to simulate it with this screensaver. Yeah its weird but its what is demanded by security going forward. I so appreciate your input here.
×
×
  • Create New...