Interrupt for Screensaver
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2011
07:50 PM
09-26-2011
07:50 PM
Interrupt for Screensaver
Hi,
I want to write an interrupt for Screensaver(VB Script) until my tests are running. Checked with WMI, TC is not supporting it. Has anyone done this. Please share some pointers.
Regards
Smita
I want to write an interrupt for Screensaver(VB Script) until my tests are running. Checked with WMI, TC is not supporting it. Has anyone done this. Please share some pointers.
Regards
Smita
11 REPLIES 11
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2011
09:54 PM
09-26-2011
09:54 PM
The easiest way to disable sceensaver for test run is to completely disable it 🙂
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2011
10:08 PM
09-26-2011
10:08 PM
And here is a JScript example how to disable screensaver. If you really need this, you'll need to rewrite this in VBScript (see TC help topic "How to Call a DLL Routine From Your Script"). However, I still recommend just disable screen saver on you PC.
function DisableScreensaver()
{
kernel = DLL.DefineDLL("kernel32");
Lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
proc = kernel.DefineProc("SetThreadExecutionState", vt_void);
Lib.SetThreadExecutionState();
}
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
function DisableScreensaver()
{
kernel = DLL.DefineDLL("kernel32");
Lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
proc = kernel.DefineProc("SetThreadExecutionState", vt_void);
Lib.SetThreadExecutionState();
}
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2011
10:51 PM
09-26-2011
10:51 PM
Hi Smita,
In addition to Gennadiy's answer, you can prevent a screen saver from starting in the following ways:
* Call the Windows API SystemParametersInfo function to temporarily disable the screen saver:
* Create a timer that will fire periodically and move the mouse pointer on the screen:
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
In addition to Gennadiy's answer, you can prevent a screen saver from starting in the following ways:
* Call the Windows API SystemParametersInfo function to temporarily disable the screen saver:
' Disable the screen saver
Call Win32API.SystemParametersInfo(Win32API.SPI_SETSCREENSAVEACTIVE, False, Null, 0)
' Do something
' Enable the screen saver
Call Win32API.SystemParametersInfo(Win32API.SPI_SETSCREENSAVEACTIVE, True, Null, 0)
* Create a timer that will fire periodically and move the mouse pointer on the screen:
Sub Test
Set timer = Utils.Timers.Add(900, "Unit1.MoveMouse", True)
' Do something
End Sub
Sub MoveMouse
Sys.Desktop.MouseX = Sys.Desktop.MouseX + 1
End Sub
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2011
12:37 AM
09-27-2011
12:37 AM
Thanks Gennadiy and Helen. Will try this out and let you know.
Regards
Smita
Regards
Smita
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013
03:42 AM
08-20-2013
03:42 AM
function DisableScreensaver()
{
kernel = DLL.DefineDLL("kernel32");
Lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
proc = kernel.DefineProc("SetThreadExecutionState", vt_void);
Lib.SetThreadExecutionState();
}
Looks like this is what I need, but this code rises an exeption:
---------------------------
TestComplete
---------------------------
JScript runtime error.
An exception occurred: 0xC0000005; class: ; description: ''
---------------------------
OK
---------------------------
Any ideas why this is happening?
{
kernel = DLL.DefineDLL("kernel32");
Lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
proc = kernel.DefineProc("SetThreadExecutionState", vt_void);
Lib.SetThreadExecutionState();
}
Looks like this is what I need, but this code rises an exeption:
---------------------------
TestComplete
---------------------------
JScript runtime error.
An exception occurred: 0xC0000005; class: ; description: ''
---------------------------
OK
---------------------------
Any ideas why this is happening?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013
03:46 AM
08-20-2013
03:46 AM
Don't use this example. After some investigations I found out that it doesn't work. Anyway, even if you make it working, it will not disable the screensaver.
Please use Helen's suggestion instead.
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
Please use Helen's suggestion instead.
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013
04:05 AM
08-20-2013
04:05 AM
Don't care too much about screensaver. I need to prevent the system from entering sleep or turning off the display. MSDN says this function (SetThreadExecutionState) should help, but I have no idea how to make it working:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208(v=vs.85).aspx
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013
04:11 AM
08-20-2013
04:11 AM
The correct solution for you is
function disableSleep()
{
var ES_SYSTEM_REQUIRED = 0x00000001;
var ES_DISPLAY_REQUIRED = 0x00000002;
var kernel = DLL.DefineDLL("kernel32");
var lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
var proc = kernel.DefineProc("SetThreadExecutionState", vt_i2, vt_void);
lib.SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}
But since it only sends command to OS, but not sets some kind of settings, you need to run it from time to time. For instanse, you can create Timer and call this function every minute.
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
function disableSleep()
{
var ES_SYSTEM_REQUIRED = 0x00000001;
var ES_DISPLAY_REQUIRED = 0x00000002;
var kernel = DLL.DefineDLL("kernel32");
var lib = DLL.Load("c:\\Windows\\System32\\kernel32.dll");
var proc = kernel.DefineProc("SetThreadExecutionState", vt_i2, vt_void);
lib.SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}
But since it only sends command to OS, but not sets some kind of settings, you need to run it from time to time. For instanse, you can create Timer and call this function every minute.
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013
04:39 AM
08-20-2013
04:39 AM
Hi,
This is all about the power scheme. If you need to configure your machine programmatically use powercfg.exe (doc).
An easy way to do this is to configure a power scheme, export it and import it on the target machine.
Sincerely
This is all about the power scheme. If you need to configure your machine programmatically use powercfg.exe (doc).
An easy way to do this is to configure a power scheme, export it and import it on the target machine.
Sincerely
Simon Glet
