Jump to content

How to check if system is idle


Recommended Posts

Hey Salty/anyone.. were you able to see whats going wrong? I seriously could use another autoit scripter's opinion there.

if you post full listing of the code i'll take a look at it today while i'm killing time at work. through both threads you've got it broken up with different revisions throughout and i don't think anyone wants to try to piece together the whole thing from the bits to try to recreate.
Link to comment
Share on other sites

Thanks Cameron.. I posted the thread where the full code was..

If something happened with the re-direction here it is again..

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=d3mon Corporation\Autoit\ICON\SHELL32\016_shell32.ico
#AutoIt3Wrapper_outfile=ScreenSaver.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; Determine cfg paths
Local $TempDir=("\\<network_path>\")        ; network path to cfg 
Local $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 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("^!{s}", "_ScreenSaverHotKey")    ; Ctrl+Alt+S 

#Region Check cfg
If Not FileExists($sav) Then
    FileWrite($sav, "C:\DATA\SCREENSAVER\") ; where the images are stored
    FileWrite($sav, @CRLF & '5000') ; Time in ms between image transitions (standard is 15 seconds)
    FileWrite($sav, @CRLF & '.bmp|.jpg|.gif')   ; Image formats supported
    FileWrite($sav, @CRLF & '5000') ; Time in ms between idle timeouts
    FileWrite($sav, @CRLF & "test") ; default password to unlock screensaver
EndIf
#EndRegion Check cfg

#Region Pref GUI
$PGUI = GUICreate('Picture Screen Saver - d3monCorp', 260, 150, -1, -1, BitOR(0x00040000, 0x00000080))
GUISetOnEvent(-3, '_PrefClose')

GUICtrlCreateGroup('Pictures folder', 5, 5, 245, 42)
$p_pic = GUICtrlCreateEdit(FileReadLine($sav, 1), 10, 20, 170, 20, 2048 + 128)
GUICtrlCreateButton('Browse', 190, 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', 170, 50, 80, 40)
$tdisp = GUICtrlCreateEdit(FileReadLine($sav, 2), 180, 67, 60, 17, 8192 + 128)

; Need to correct this as GUI box is not yet set.
GUICtrlCreateGroup('Idle timeout', 170, 50, 80, 40)
$tidle = GUICtrlCreateEdit(FileReadLine($sav, 4), 180, 67, 60, 17, 8192 + 128)

GUICtrlCreateButton('Apply', 80, 100, 80, 20)
GUICtrlSetOnEvent(-1, '_PrefApply')
GUISetState(@SW_HIDE, $PGUI)
#EndRegion Pref GUI

If Not @Compiled Then ; Run ScreenSaver if not compiled
    _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) & @CRLF)
    If (GUICtrlRead($tdisp) = '') Then FileWrite($sav, @CRLF & '2000' & @CRLF)
    If (GUICtrlRead($tidle) <> '') Then FileWrite($sav, @CRLF & GUICtrlRead($tidle) & @CRLF)
    If (GUICtrlRead($tidle) = '') 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|')
    Return Call('_PrefClose')
EndFunc   ;==>_PrefApply

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)
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

; Needs to read line 5 in config file for password
Func _AskPassword()
    _StopScreenSaver()
    MsgBox(64, "", "Enter Password")
EndFunc

Func _StopScreenSaver()
    $bl_ScreenSaver = False
    GUIDelete($CGUI)
    GUIDelete($GUI)
    _WinAPI_ShowCursor(1)
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)
;~      $GUI = GUICreate('Screen Saver', @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000)
        GUISetBkColor(0x000000, $GUI)
        GUISetState(@SW_SHOW, $GUI)
        WinSetOnTop($GUI, "", 1)
;~      WinSetOnTop($GUI, '', 1)
    EndIf
    Global $CGUI = GUICreate('Screen Saver', $width, $height, 0, 0, 0x80000000, 0x00000008, $hwnd)
;~  $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
;~  While 1
        $check = FileFindFirstFile($s_path & '*.*')
        If $check = -1 Then Exit ConsoleWrite('!> FileFindFirstFile' & Chr(13))
        While $bl_ScreenSaver = True
;~      While 1
            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 Exit ;Mouse/Keyboard event
                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 "1")
Func __SetPicture($hGUI, $ID, $p_path, $idisp, $hwnd)
    GUICtrlSetImage($ID, $p_path)
    ;_WinAnimate($hGUI, Random(1, 10, 1), 1, 700)
    _WinAnimate($hGUI, 1, 1, 700)
    $Init = TimerInit()
    While 1
        Sleep(300)
        If ($hwnd = 'Screen Saver') Then
;~          If _IdleTicks() Then Exit ;Mouse/Keyboard event
            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)
    _WinAnimate($hGUI, 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)
;~     ;Return ($ticksSinceBoot - $ticksSinceIdle)
;~ EndFunc   ;==>_IdleTicks

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

Thats the full code or at least the relevant part re: idle time issues.

Edited by Thudo
Link to comment
Share on other sites

Thanks Cameron.. I posted the thread where the full code was..

If something happened with the re-direction here it is again..

np, it's obvious you're making a real effort so i'm glad to help. sorry i didn't go through each of the posts on both threads to find the link or whatever, i tend to be as lazy as i am helpful. ;)
Link to comment
Share on other sites

All good man.. I really appreciate any scripting help from this great community! ;)

I'm sure the issue is in the _Idleticks() function as mentioned.

could you post a cfg file also? just quicker than creating one based on your code. when i run the posted code i get a black screen and have to end task on autoitexe because the hotkey isn't doing anything
Link to comment
Share on other sites

C:\DATA\SCREENSAVER\
5000
.bmp|.jpg|.gif
60000
0x136E264E94E5BE49096C7A54F33646B8
0x6D662F965D1E85BB367EFAA03594C5A1
Any bmp or jpg or gif can reside in the C:\DATA\SCREENSAVER\ folder for testing purposes. ;)
Link to comment
Share on other sites

i'm actually away from my desk for a bit today, so won't be able to post any findings for a little while. as far as why it runs straight to screensaver without waiting; are you running from scite? you have a check in there to run straight to screensaver if the script is not compiled...

Link to comment
Share on other sites

Ah.. ok that understood. Now what about the other inquiry:

2) Once the screensaver shows the images, if the user moves the mouse, instead of going to the password box it just fades to black and nothing happens freezing the screen it place with a blank black screen. I have to ctrl-alt-delete out.

Link to comment
Share on other sites

Ah.. ok that understood. Now what about the other inquiry:

2) Once the screensaver shows the images, if the user moves the mouse, instead of going to the password box it just fades to black and nothing happens freezing the screen it place with a blank black screen. I have to ctrl-alt-delete out.

when i was playing with your code, i had to make my own escape function to end it also. you're probably setting your screensaver window top most, and not changing that when you are trying to show the other window would be my guess.
Link to comment
Share on other sites

I guess what I don't get why this doesn't cause #2:

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)
    ;Return ($ticksSinceBoot - $ticksSinceIdle)
EndFunc   ;==>_IdleTicks

But this does (which I want working like the above code since the code below has links to the outside variable to set the duration of the timeout)

Func _IdleTicks()
    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
This code above causes the black screen yet the first one does not. I don't understand why. ;)

Even if I set "(FileReadLine($sav, 4))" to any high # the screen still blacks out unlike the first code above.

Edited by Thudo
Link to comment
Share on other sites

Updated the full code in THIS THREAD. Thats the actual full code I am dealing with and need it resolved asap. ;)

i'm going through it and there are some big issues... actually having to troubleshoot like every bit of code to even get to the issues that you're listing... :) i can definitely see your effort though, that's why i'm putting in the time. one thing to change just off the top of my head; you have the following line:

;If _IdleTicks() Then _AskPassword()

i've commented that out because just running the script is calling that ask password because you're referencing a function without a return as a boolean expression... continuing on and i will have more for you i'm sure, but i'm not rewriting your whole code

Link to comment
Share on other sites

more issues in code, your _PasswordCheck() function doesn't DO anything except fail.

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

i see that you have a password box/gui sitting there, but you never give the user a chance to enter the password, and you never evaluate the contents of the pw box... as soon as password check is called it just starts failing them

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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...