Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried moving the mouse programmatically but this didn't stop the "away from PC" because the user didn't do the move instead of the keypress that may be problematic.

What I have tried:

I simulate a keypress for Ctrl but I want to move the mouse 1 pixel to the right and then one pixel to the left and have the PC stop the away from PC time.
Posted
Updated 18-Sep-16 21:35pm
v2
Comments
Richard MacCutchan 19-Sep-16 3:22am    
Why not just tell the user to change the power settings?
john1990_1 19-Sep-16 3:28am    
The idea of "Caffeine" program is taken from Linux, it prevents PC from sleep without changing the power settings always.

Here's my program and the source code.

I tried 2 codes for moving the mouse, the mouse moved, but the PC knows the user didn't do this so the computer remains in "away" mode.

https://sites.google.com/site/caffeineforwindows/

1 solution

You can use SetThreadExecutionState with ES_SYSTEM_REQUIRED
Note: its a native method.

More details regarding Sleep criteria from msdn link
System Sleep Criteria (Windows)[^]
 
Share this answer
 
v2
Comments
john1990_1 19-Sep-16 3:58am    
But if the PC shuts down unexpectedly or the program terminates unexpectedly this remains and the computer doesn't sleep forever.

Does this have to be annulled after use?

Is there a way to move mouse and make the PC think it's the user who did it?
harish85 21-Sep-16 1:52am    
the system will discard the set flags when the thread that set it is no longer exists/killed (normally or abnormally)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900