Zhorn Software
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
Posts : 31
Join date : 2020-01-16

Bug in Caffeine ? Empty Bug in Caffeine ?

Fri Apr 16, 2021 12:37 pm
First of all, what I describe should never occur, since Caffeine is supposed to prevent both screen saver start, and go to sleep.
Nevertheless, it happened to me recently (it cannot be a long time ago, since I'm using Caffeine only for 1 week  Bug in Caffeine ? 1f609 ) at least TWO TIMES that Caffeine didn't its job despite active.
One time, the screen saver started (and I had only to reactivate the Pc to have all working fine), but another time (I was not in front of my Pc), it went to sleep !

I imagine this could be due to the fact that my screen saver is set to start after 1 minute (while Caffeine defaults to 59 seconds : very close schedule).
But if the screen saver starts incidently (maybe after 58 seconds only, rather than waiting for a full minute), this should not have any real impact, since it should be killed almost immediately by Caffeine.... except if Caffeine is no more sending its keystrokes if the screen saver runs.
Moreover this could explain that the time I was not in front of my laptop, it eventually went to sleep (sleep is parameterized after 30 minutes)

So I suspected a bug, and then set up a test scenario to confirm it.
And the result is clear :

If Caffeine is running, but if for any reason the screen save starts nevertheless, then Caffeine do not any more send its keystrokes... and the result is the same than if Caffeine were no more active.

How did I my testing to be so sure ?

1) I let my screen saver to start after 1 minute of inactivity.
2) I started Caffeine with the following parameters : Caffeine64.exe 90 -key:175
ie. send a "Volume up" every 90 seconds

If I'm "active" on the Pc, I can see that every 90 seconds, volume is "up" of 2%, ie. the same thing than if I stroke manually the key "Volume up". Clearly, this means that Caffeine is doing correctly its job.

But if I stop any activity on my Pc,
- as expected, the screen save starts afer 1 minute
- but after 90 seconds, the screen save remains active, letting to think that Caffeine didn't send keystroke (otherwise, screen saver should have stopped).
- I'm waiting for 5 or 10 minutes, then I reactivate manually my Pc.... and I can verify that Volume didn't increase at all during all this time
- Nevertheless, Caffeine is supposed to be still active (according to what says its icon).... and actually is (at least "again"), since after having closed the screen saver, I can see again volume increasing 2% every 90 seconds.

I agree that this bug is not of a very huge level of importance, since I'm quite sure that
- either with screen save parameterized to start after more than 1 minute
- and/or Caffeine parameterized to send its keystroke every 45 or 50 seconds (rather than 59)
the issue wouldn't be "visible" any more.
Nevertheless, I think it is worth that Tom has a look on it, since this could reveal a more important bug.
Posts : 295
Join date : 2018-04-28

Bug in Caffeine ? Empty Re: Bug in Caffeine ?

Sat Apr 17, 2021 11:31 am
It seems more to be a " feature " from the screensaver that it ignores software simulated keys when active . Other code that send keys has the same problem as caffeine ( also software mouse events are blocked ) .

From microsoft documentation:
The keyboard input can come from the local keyboard driver or from calls to the keybd_event function. If the input comes from a call to keybd_event, the input was "injected".
Posts : 294
Join date : 2018-03-30
Location : London

Bug in Caffeine ? Empty Re: Bug in Caffeine ?

Sat May 01, 2021 3:44 pm
I don't claim to be an expert on how Windows works, but I think what you describe is right.  It's to do with whether there's a current, active desktop session.  Once the screensaver starts, or the session is locked, a number of things won't happen any longer as there isn't a desktop session running any longer.  Raymond Chen alludes to this in his book The Old New Thing (which I've been reading) where he refers to "paying (software) taxes".  If your machine is locked or the screensaver is running, I suspect Windows puts some activities aside to save battery if nothing else.

Sponsored content

Bug in Caffeine ? Empty Re: Bug in Caffeine ?

Back to top
Permissions in this forum:
You can reply to topics in this forum