Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
May 22, 2013, 03:06:17 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to make JKdefrag work after monitor turn off  (Read 3805 times)
WerK
JkDefrag Supporter
***
Posts: 12


View Profile
« on: November 17, 2008, 02:31:56 pm »

Hi, I'm using this excellent defrag program as my screensaver to tidy the disk when I'm away from keyboard. I have just on problem. I also like screen to turn off after a while of inactivity to save power. The problem is that running screensaver (like JKdefrag) gets terminated when screen turns off -> no defrag :/ It means that the JKdefrag screen saver can only run for the time difference between turning on the screensaver and turning off the screen. Maybe do you have some trick to make the JKdefrag work even after the screen has been turned off ? Thanks for any help
Logged
kandro
JkDefrag Hero
*****
Posts: 72


MyDefragGUI at www.mydefrag.net


View Profile WWW
« Reply #1 on: November 17, 2008, 04:47:41 pm »

Hi, maybe this thread helps:

Running JkDefragScreenSaver even when monitor in powersave
« Last Edit: November 17, 2008, 05:48:32 pm by kandro » Logged

It doesn't mtater, in wihch seqenuce the ltteres in wodrs aeappr. The mian pnoit is taht the frsit and the lsat lteter is crroect. The remnaider can be ttalloy wrnog neevrtehlses you can raed it withuot porbelms.
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #2 on: November 17, 2008, 07:16:11 pm »

The thread that Kandro has linked is a year old, but the information is still valid. The JkDefrag screensaver contains a bit of code that tells Windows not to go into power saving mode. After JkDefrag has finished Windows is free to go into power saving mode.
Logged
WerK
JkDefrag Supporter
***
Posts: 12


View Profile
« Reply #3 on: November 18, 2008, 03:27:20 pm »

Thanks for replies. It looks like that this method doesn't work with Vista anymore. The defrag was running, then monitor turned off, stopping the defrag. This looks like a common problem with Vista, for example the Media Player Classic also stops screensaver from appearing in XP but not in Vista. I don't want to bother you with it, so I'll try to find a solution to it and post it here.
Logged
WerK
JkDefrag Supporter
***
Posts: 12


View Profile
« Reply #4 on: November 18, 2008, 08:40:45 pm »

Okay, I'm not much of a programmer but I've DLed the sources and found that JKdefrag calls the function
Code:
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
The API reference ( http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx) states that
Code:
ES_SYSTEM_REQUIRED
Forces the system to be in the working state by resetting the system idle timer.
I think that by 'working state', it means that the computer doesn't enter some power saving mode, but could turn off the display. Maybe it somehow works in XP but doesn't in Vista. I think that issue can be fixed by calling
Code:
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
This _should_ stop computer from entering sleep AND to prevent it from turning screen off.

BTW I noticed that you call this function everytime when you repaint the screen. The API has the ES_CONTINUOUS macro, which states that you want the current state to remain in effect, until you reset it. So, maybe you could achieve a better performance by calling
Code:
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED)
once somewhere early in the code and then calling
Code:
SetThreadExecutionState(ES_CONTINUOUS)
once before the termination of the program before it exits. I'll try to install Microsoft Visual C++ and try to test the changes myself.

Cheers
Logged
WerK
JkDefrag Supporter
***
Posts: 12


View Profile
« Reply #5 on: November 18, 2008, 09:54:09 pm »

OK, I guess I made it to work on Vista. I added
Code:
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
after the part
Code:
  /* Setup the defaults. */
  OptimizeMode = 2;
  Speed = 100;
  FreeSpace = 1;
  Excludes = NULL;
  SpaceHogs = NULL;
and removed the respective call in the PaintScreen() method. I also added
Code:
SetThreadExecutionState(ES_CONTINUOUS)
to re-enable power-saving modes after termination, put it once before the alternate screensaver execution and also to the part, which terminates program after the mouse has been moved. It now works flawlessly.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #6 on: November 19, 2008, 08:49:25 am »

Thank you very much for your detective work and for the solution! I wish all bugs were fixed liked this.... I have updated the sources and your fix will be in the next version.
Logged
WerK
JkDefrag Supporter
***
Posts: 12


View Profile
« Reply #7 on: November 19, 2008, 11:22:40 am »

No problem, glad to help.

By the way, I think that you also have to place the
Code:
SetThreadExecutionState(ES_CONTINUOUS)
to a method that gets called when exiting the program via ALT+F4,Close button and so on. I think the Windows power manager should disable this flag on a process that is quitting, but just to be sure that you have this possibility fixed Smiley
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #8 on: November 20, 2008, 05:08:45 am »

By the way, I think that you also have to place the SetThreadExecutionState(ES_CONTINUOUS) to a method that gets called when exiting the program via ALT+F4,Close button and so on.
I'm not sure if a screensaver can be stopped like that. Also, the Microsoft screensaver library handles the main message loop and I don't know how to overrule that. But I will apply the same fix to the regular Windows version of JkDefrag.
Logged
h4nc0
Newbie
*
Posts: 1


View Profile
« Reply #9 on: December 15, 2008, 04:27:23 pm »

When can we expect the next release with fix?  Also, can there be an option in the screensaver version to run in blank screen?

Thanks!
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7155



View Profile WWW
« Reply #10 on: December 16, 2008, 07:32:56 am »

When can we expect the next release with fix?
Version 3 is more or less frozen and I will only release a new version when I find a serious bug. Version 4 is nearing completion but I do not have a release date yet.

Quote
Also, can there be an option in the screensaver version to run in blank screen?
It has been asked before. I'm sorry but a screensaver that shows a blank screen makes no sense to me. The diskmap is a bit confusing to users, I know, but I think a blank screen is even more confusing. I think what you are really looking for is a way to run JkDefrag invisibly in the background, and there is a much better way for that, via the Windows task scheduler. It has lot's of useful possibilities, such as an option to only run the task when the computer is idle. Try it, you will like it.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!