Sign in to follow this  
Followers 0
Homes32

Issue with prevent screensaver from running with send()

5 posts in this topic

#1 ·  Posted (edited)

Greetings!

I've run into a bit of an issue with my script. I am using the following code to block the screensaver from running but am also using _Timer_GetIdleTime() to decide whether to hide or show a GUI window. The idea being that after 30 sec of inactivity the controlGUI will hide itself until the user is ready for it. The problem is that when I call Send() the IdleTime gets reset and the window will show itself, which I don't want unless the user actually sends activity.

does anybody have any advice on how to either disable the screen saver from running without modifying the registry or keep the controlGUI from showing on Send("{RSHIFT}")?

#include <Timers.au3>            ; _Timer_GetIdleTime()
#include <WindowsConstants.au3>

$DisableScrSvr = 1
$controlGui = GUICreate("Unlock Computer", 430, 165, (@DesktopWidth / 2) - 200, (@DesktopHeight / 2) - 100, BitOR($WS_DLGFRAME, $WS_POPUP))

While 1
        ; get time since last mouse/key
        Global $iIdleTime = _Timer_GetIdleTime()

        ; block screensaver if user so wishes
        If $DisableScrSvr = 1 And $iIdleTime > 50000 Then ; every 50 sec press the right shift key
            Send("{RSHIFT}")
            Sleep(10) ; sleep 6 ms so send key is released
        EndIf

        ; Hide the password window if no activity and show it when user hits keyboard or mouse
        If $iIdleTime < 30000 Then
            GUISetState(@SW_SHOW, $controlGui)
        Else
            GUISetState(@SW_HIDE, $controlGui)
        EndIf
WEnd

regards,

-Homes32

Edited by Homes32

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Do you consider right clicking the desktop, clicking display, and disabiling the screensaver as modifying the registry? I always have my screensaver disabled as it isn't a problem now that we don't have issues with newer monitors burning still images into the screen...

Another option may be to have the mouse mouse a few pixels every couple minutes, just check the screensaver delay.

Perhaps I'm not understanding the problem fully.

Can I see the code you are using to show the GUI? Does the GUI show with ANY user activity?

Edited by Synct

Share this post


Link to post
Share on other sites

Do you consider right clicking the desktop, clicking display, and disabiling the screensaver as modifying the registry? I always have my screensaver disabled as it isn't a problem now that we don't have issues with newer monitors burning still images into the screen...

in this case yes. when the program exits normally or abnormally I want everything as the user had it, so this isn't an option for me in the scenario.

Another option may be to have the mouse mouse a few pixels every couple minutes, just check the screensaver delay.

thats going to reset the _Timer_GetIdleTime() and leave me in the same situation as I am now with Send()

Perhaps I'm not understanding the problem fully.

Can I see the code you are using to show the GUI? Does the GUI show with ANY user activity?

certainly. its in my 1st post. It checkes the value of _Timer_GetIdleTime() and hides the GUI after 30 seconds of inactivity and shows the GUI on any activity.

thanks for having a look.

-Homes32

Share this post


Link to post
Share on other sites

judging by the lack of response I have either completely confused everyone or you are all as baffled as myself in the matter at hand.

to pose the question in another way: is there a method to exclude certain keystrokes from resetting _Timer_GetIdleTime()?

Share this post


Link to post
Share on other sites

No, otherwise he would not do his job properly ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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