Sign in to follow this  
Followers 0
jokke

Script running while screensaver is active and vica verca.

9 posts in this topic

#1 ·  Posted (edited)

Hiya,

I know this has been upp for question several times, but i could not seem to find any good answer for this.

Im running a script witch counts, every minute it ads one to a var i'we stored, but heres the catch i need to make it not record when screensaver is active, i actually needs it to substract ten everytime screen saver starts, but thats not the problem. (domain policy screen saver starts after 10 min idle)

I know there are windows triggers for this, but i cant find out how to use them.

SystemParametersInfo Search for this string: Screen saver parameter

Then there is a Parameter called "SPI_GETSCREENSAVERRUNNING" witch will return FALSE or TRUE, but this is where the road for me ends, i have no idea how to use that parameter with autoit.

Dim $countingvar = 0

While 1

    While SPI_GETSCREENSAVERRUNNING = FALSE; <------ Help this aint right!
        Sleep(59500)
        $countingvar +=1
        ;Execute command 
    Wend

    Sleep(20)

Wend

All help apreciated :whistle:

Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites



Well I wouldf guess you need one of those

ObjCreate Creates a reference to a COM object from the given classname.

ObjEvent Handles incoming events from the given Object.

ObjGet Retrieves a reference to a COM object from an existing process or filename.

ObjName Returns the name or interface description of an Object


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

This nowhere near works (I tried), but I think you need something that looks like:

DllCall("user32.dll", "long", "SystemParametersInfoA", "long","SPI_GETSCREENSAVERRUNNING","long", 0x00010a92)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the reply folks, ill look into the DllCall and see if im able to get something there =)

I'we found a thread where the dllcall has been the issue once, they could not solwe it right though. Thread here...

Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

I also wrote this code for testing, with no results though :whistle:

#include <A3LWinAPI.au3>

$iAction = 'SPI_GETSCREENSAVERRUNNING'
$test1 = _API_SystemParametersInfo($iAction)
ConsoleWrite( $test1 ) ;Will Return false....

While 1
    $test2 = _API_SystemParametersInfo($iAction)
    If $test2 <> $test1 Then
        ConsoleWrite( $test2 ) ;Should return true if screensaver is started..
    EndIf
    Sleep(40)
WEnd

Auto3Lib found inn this thread.. < -- (A3LWinAPI.au3)


UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

I also wrote this code for testing, with no results though :whistle:

#include <A3LWinAPI.au3>

$iAction = 'SPI_GETSCREENSAVERRUNNING'
$test1 = _API_SystemParametersInfo($iAction)
ConsoleWrite( $test1 ) ;Will Return false....

While 1
    $test2 = _API_SystemParametersInfo($iAction)
    If $test2 <> $test1 Then
        ConsoleWrite( $test2 ) ;Should return true if screensaver is started..
    EndIf
    Sleep(40)
WEnd

Auto3Lib found inn this thread.. < -- (A3LWinAPI.au3)

Remove the quotes from around SPI_GETSCREENSAVERRUNNING. It's a numeric constant, not a string.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Remove the quotes from around SPI_GETSCREENSAVERRUNNING. It's a numeric constant, not a string.

Yep, that is an error, but has anyone got this to work even so?

Spent a couple of hours experimenting, starting with the A3LWinAPI library function _API_SystemParametersInfo, and then using a direct and minimalist DLL call with no variables, just numeric values. Seems that neither can be persuaded to return anything other than zero for this particular call.

A quick check with msgbox functions shows that DLLCall itself is working, but the screensaver-related calls don't do anything, neither do they set or retrieve values. Yet, they don't return any @error either.

Browsing around I hit references to this call in the contexts of C# and VB, and both seemed to suggest that the return value will be the third parameter of the call, rather than the actual function return - in other words $vParam in the A3L function. However, trying it this way (and looking for changes in any returned value) also drew a complete blank.

For the moment I'm stumped on this one. :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Yep, that is an error, but has anyone got this to work even so?

Spent a couple of hours experimenting, starting with the A3LWinAPI library function _API_SystemParametersInfo, and then using a direct and minimalist DLL call with no variables, just numeric values. Seems that neither can be persuaded to return anything other than zero for this particular call.

A quick check with msgbox functions shows that DLLCall itself is working, but the screensaver-related calls don't do anything, neither do they set or retrieve values. Yet, they don't return any @error either.

Browsing around I hit references to this call in the contexts of C# and VB, and both seemed to suggest that the return value will be the third parameter of the call, rather than the actual function return - in other words $vParam in the A3L function. However, trying it this way (and looking for changes in any returned value) also drew a complete blank.

For the moment I'm stumped on this one. :)

Here is what MSDN says about SPI_GETSCREENSAVERRUNNING:

SPI_GETSCREENSAVERRUNNING Determines whether a screen saver is currently running on the window station of the calling process. The pvParam parameter must point to a BOOL variable that receives TRUE if a screen saver is currently running, or FALSE otherwise.

If you run this code in SciTE, it will display 0 if no screen saver is running and a 1 if it is:

#include <A3LWinAPI.au3>

Global $pBool, $tBool

$tBool = DllStructCreate("int Result")
$pBool = DllStructGetPtr($tBool)

while 1
  _API_SystemParametersInfo($SPI_GETSCREENSAVERRUNNING, 0, $pBool)
  _Lib_ConsoleWrite("Result: " & DllStructGetData($tBool, "Result"))
  Sleep(1000)
wend
Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Here is what MSDN says about SPI_GETSCREENSAVERRUNNING:

Ahh... must be the variable type that's the issue. Did wonder if that might be the problem, but couldn't see the workaround.

Anyway, meanwhile found another way of detecting the screensaver, basically:

Find its process-name from the Control Panel registry key.

Check for the process existing.

Optionally, confirm that the process's window has no properties, which verifies that it's been launched by winlogon and not manually by the user. (This is because the system screensaver runs in a protected desktop)

func IsSaverOn()
; (returns 0 if No, PID if running)

 $scrProcess=filename(RegRead ( 'HKEY_CURRENT_USER\Control Panel\Desktop\', 'scrnsave.exe' ))
 $exists=ProcessExists($scrProcess)

 $winClasses=wingetclasslist("")
 if $winClasses<>"" then $exists=0
 
 return $exists
endfunc; Is SaverOn

; Library function...

func filename ($_pathtostrip)
 return stringmid($_pathtostrip,stringinstr($_pathtostrip,"\",0,-1) +1 ,255)
endfunc

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