Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Hi allAs the title suggests, I would like to know how S+ behaves when Windows is in sleep mode or locked(the time when you wake it up by pressing any key and it asks for password) It is more of a confirmation post actually because I know programs do keep their processes alive when Windows is asleep(or at least they dont kill the program entirely) Here's my use case, I do some things before turning Windows off, such as unmounting any VeraCrypt containers and logging some information to files. I have a shortcut set(in S+) to turn off Windows which does those things and then turns off Windows. Sometimes I fall asleep and Windows goes to sleep mode for 7 to 10 hours, leaving VeraCrypt containers mounted and vulnerable. I would like to set a timer which fires every 15 minutes and turns off Windows after 3 hours of inactivity(by monitoring mouse pointer location changes?) and that way I can turn Windows off properly(after unmounting VeraCrypt containers using S+ that is) But I'm not sure how much 'alive' S+ really is when Windows is locked in sleep mode, is it able to fire timers? can it run programs? such as writing to files and running VeraCrypt command lines.. I could test it with trial and error but honestly I can't be sure until someone(aka Rob ![Laugh](/Images/Emoticons/msp_laugh.gif) ) confirms it. Any clarification and ideas regarding the best 'monitoring' practices when Windows is locked in sleep mode are much appreciated. Thanks
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 ![United States United States](/Content/images/flags/US.png) Location: Tampa, FL Thanks: 28 times Was thanked: 430 time(s) in 363 post(s)
|
|
![thanks](/Themes/BlueGrey/heart_small.png) 1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Thanks RobIt looks a bit too complicated for me right now but nice to know an option exists
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 ![United States United States](/Content/images/flags/US.png) Location: Tampa, FL Thanks: 28 times Was thanked: 430 time(s) in 363 post(s)
|
But yeah, if you want to just disable sleep in Windows, you can make a timer in S+ to look at the mouse location or call GetLastInputInfo to see when the last input happened. You could then have S+ do the stuff and put Windows to sleep via SetSuspendState or shutdown.exe. Also, SetThreadExecutionState tells windows that a process must be running and prevents sleep and/or display from turning off, for what it's worth.
|
![thanks](/Themes/BlueGrey/heart_small.png) 1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Informative stuff, I'll implement some of it for sure.
Thanks Rob
|
|
|
|
Rank: Member
Groups: Approved
Joined: 4/2/2020(UTC) Posts: 11 ![United States United States](/Content/images/flags/US.png) Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
|
What I do is hook a task scheduler task to the windows screen saver event. There is an onsleep event, but that isn't guaranteed to fire off the task before the computer sleeps. The screen saver event is not normally logged, so you'll have to go into the Group Policy Editor under Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Advanced Audit Policy Configuration -> System Audit Policies -> Logon/Logoff -> Audit Other Logon/Logoff Events. Set that to log Success and Fail.
In Task Scheduler, set the task to begin On an Event. Log: Security, Source: Microsoft Windows security auditing, Event ID: 4802
After that, add any scripts/programs you want to run when the screensaver runs, then as the last action, run a program to set the computer to standby.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 ![United States United States](/Content/images/flags/US.png) Location: Tampa, FL Thanks: 28 times Was thanked: 430 time(s) in 363 post(s)
|
You can also create a simple WinForms and handle session ending events broadcast by Windows. Code:// Windows message query end session
public const int WM_QUERYENDSESSION = 17;
// Windows message end session
public const int WM_ENDSESSION = 22;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_QUERYENDSESSION:
// Windows is letting all apps know that the user is requesting
// to end the session
// Do stuff here
break;
case WM_ENDSESSION:
// Windows is ending the session
// Do stuff here
break;
}
base.WndProc(ref m);
}
I will add to the list to create events in S+ so you can respond to these, as S+ does receive these messages.
|
|
|
|
Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 162 ![China China](/Content/images/flags/CN.png) Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
The form I create to show the icons in this post Popup-an-icons-bar seems to flash randomly when loading, and the form has set DoubleBuffered as true. I find some ways probably solve the flash problem for the form with a transplant background. But I don't know whether both of them will work to stop the flash of form. One of them also needs to override this function to receive the message. Code:protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0014) // Disable clear background messages
return;
base.WndProc(ref m);
}
The second is to SetStyle of the form, which shows an Error that form.SetStyle is not a function that I set in the code. Code:public Form1()
{
InitializeComponent();
base.SetStyle(
ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw
| ControlStyles.Selectable
| ControlStyles.AllPaintingInWmPaint // Background erasing is prohibited
| ControlStyles.UserPaint
| ControlStyles.SupportsTransparentBackColor
| ControlStyles.DoubleBuffer // double buffering
,true);
}
Edited by user Sunday, July 31, 2022 3:20:35 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 162 ![China China](/Content/images/flags/CN.png) Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Is this right to the second SetStyle that refer to avoids-display-flickering? Turn this: Code:tabPageLearn.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
.Invoke(tabPageLearn, new object[]
{
System.Windows.Forms.ControlStyles.UserPaint |
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint |
ystem.Windows.Forms.ControlStyles.DoubleBuffer, true
});
To S+ Code:form.GetType().GetMethod("SetStyle", host.flags(clr.System.Reflection.BindingFlags.Instance, clr.System.Reflection.BindingFlags.NonPublic))
.Invoke(form, new Object() {
System.Windows.Forms.ControlStyles.UserPaint,
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,
System.Windows.Forms.ControlStyles.DoubleBuffer, true}
);
Edited by user Sunday, July 31, 2022 2:11:51 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 ![United States United States](/Content/images/flags/US.png) Location: Tampa, FL Thanks: 28 times Was thanked: 430 time(s) in 363 post(s)
|
Originally Posted by: soooulp ![Go to Quoted Post Go to Quoted Post](/Themes/BlueGrey/icon_latest_reply.png) Is this right to the second SetStyle that refer to avoids-display-flickering? Turn this: Code:tabPageLearn.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
.Invoke(tabPageLearn, new object[]
{
System.Windows.Forms.ControlStyles.UserPaint |
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint |
ystem.Windows.Forms.ControlStyles.DoubleBuffer, true
});
To S+ Code:form.GetType().GetMethod("SetStyle", host.flags(clr.System.Reflection.BindingFlags.Instance, clr.System.Reflection.BindingFlags.NonPublic))
.Invoke(form, new Object() {
System.Windows.Forms.ControlStyles.UserPaint,
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,
System.Windows.Forms.ControlStyles.DoubleBuffer, true}
);
Try something like this: Code:var parms = new List(System.Object);
parms.Add(host.flags(System.Windows.Forms.ControlStyles.UserPaint,
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,
System.Windows.Forms.ControlStyles.DoubleBuffer)
);
form.GetType().GetMethod("SetStyle", host.flags(clr.System.Reflection.BindingFlags.Instance, clr.System.Reflection.BindingFlags.NonPublic))
.Invoke(form, parms.ToArray(), true);
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 162 ![China China](/Content/images/flags/CN.png) Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Originally Posted by: Rob ![Go to Quoted Post Go to Quoted Post](/Themes/BlueGrey/icon_latest_reply.png)
Try something like this:
Ops, It shows an Error, "no overload for method 'Invoke' takes 3 arguments" ![UserPostedImage](https://i.vgy.me/wb5h8g.png)
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,382 ![United States United States](/Content/images/flags/US.png) Location: Tampa, FL Thanks: 28 times Was thanked: 430 time(s) in 363 post(s)
|
Oops: Code:var parms = new List(System.Object);
parms.Add(host.flags(System.Windows.Forms.ControlStyles.UserPaint,
System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,
System.Windows.Forms.ControlStyles.DoubleBuffer)
);
parms.Add(true);
form.GetType().GetMethod("SetStyle", host.flags(clr.System.Reflection.BindingFlags.Instance, clr.System.Reflection.BindingFlags.NonPublic))
.Invoke(form, parms.ToArray());
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 162 ![China China](/Content/images/flags/CN.png) Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close