how could I get a script to automatically reload upon waking up my computer?
-
- Posts: 68
- Joined: 25 Oct 2018, 11:33
how could I get a script to automatically reload upon waking up my computer?
I have a script that I have running on four different computers. I often tweak the script on one computer and then later, say when I go home and use another computer, I need to click "reload" to get the latest version. (I'm using google drive to sync them across the computers.)
I have a run at startup program that is working well, but is there a way to get a script to "run at wakeup", so to speak? so I can have a computer asleep and when I wake it up and log in, it will reload the script to get the newest version?
I have a run at startup program that is working well, but is there a way to get a script to "run at wakeup", so to speak? so I can have a computer asleep and when I wake it up and log in, it will reload the script to get the newest version?
thank you,
Someguy
Someguy
Re: how could I get a script to automatically reload upon waking up my computer?
I use
but be aware that your network adapter might not be ready at that time. You would probably also need to wait for Google Drive to sync the file.
You might want to use wParam = 18 (PBT_APMRESUMEAUTOMATIC) instead.
Code: Select all
OnMessage(WM_POWERBROADCAST := 0x218, OnPowerBroadcast)
OnPowerBroadcast(wParam, *) {
if (wParam = 7) { ; PBT_APMRESUMESUSPEND: resume triggered by user input
;...
}
}
You might want to use wParam = 18 (PBT_APMRESUMEAUTOMATIC) instead.
-
- Posts: 68
- Joined: 25 Oct 2018, 11:33
Re: how could I get a script to automatically reload upon waking up my computer?
@Lexicos
I tried this script by adding it to a running script. I saved the script and reloaded it manually. I then put my computer to sleep and waited awhile and awakened it. it did not reload the script like I wanted it to.
any suggestions?
I tried this script by adding it to a running script.
Code: Select all
OnMessage(WM_POWERBROADCAST := 0x218, OnPowerBroadcast)
OnPowerBroadcast(wParam, *) {
if (wParam = 7) { ; 7 is for "system is resuming from a suspended state triggered by user input"
Reload ;...
}
}
any suggestions?
thank you,
Someguy
Someguy
Re: how could I get a script to automatically reload upon waking up my computer?
Just try to use debugging, like as:
Code: Select all
OnMessage(WM_POWERBROADCAST := 0x218, OnPowerBroadcast)
OnPowerBroadcast(wParam, *) {
MsgBox wParam ; For debugging purpose
if (wParam = 7) { ; 7 is for "system is resuming from a suspended state triggered by user input"
Reload ;...
}
}
Code: Select all
if (wParam = 18 or wParam = 7)
Code: Select all
/**
* PBT_APMRESUMEAUTOMATIC = 18 (0x12)
* Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
*
* PBT_APMRESUMESUSPEND = 7 (0x7)
* Operation is resuming from a low-power state. This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key.
*/
https://learn.microsoft.com/en-us/windows/win32/power/wm-powerbroadcast#return-value
Please post your script code inside [code] ... [/code] block. Thank you.
Re: how could I get a script to automatically reload upon waking up my computer?
"An application should return TRUE if it processes this message."
It doesn't specify what constitutes "processing", or that it should ever return FALSE, or that the return value is used in any way. One way of looking at it is that in order to return any value, the application would need to process the message. Therefore, the application should always return TRUE or not process the message. It really has no meaning at all. If we suppose that the default processing of the message returns FALSE and that the sender assumes a return value of 0 if the application terminates before replying, terminating would be the same as not processing the message. Processing the message is not mandatory, so there is no need for concern.
However, if you did need to reply to a message before terminating, you could generally just call Reload and then immediately return. If the new process somehow starts and terminates the old process faster than it can return (seems unlikely), it could perhaps use ReplyMessage prior to Reload.
-
- Posts: 1
- Joined: 14 Apr 2024, 06:34
Re: how could I get a script to automatically reload upon waking up my computer?
You can achieve this by scheduling a task in the Task Scheduler to run your script on system wake-up. This way, whenever you wake up the computer and log in, the script will automatically reload to get the latest version.someguyinKC wrote: ↑31 Mar 2024, 07:35I have a script that I have running on four different computers. I often tweak the script on one computer and then later, say when I go home and use another computer, I need to click "reload" to get the latest version. (I'm using google drive to sync them across the computers.)
I have a run at startup program that is working well, but is there a way to get a script to "run at wakeup", so to speak? so I can have a computer asleep and when I wake it up and log in, it will reload the script to get the newest version?
Re: how could I get a script to automatically reload upon waking up my computer?
use "task scheduler" and launch an another custom reload script.
I did project with task scheduler to stop steam downloading If i'm connected to my pocket wifi.
https://github.com/xmaxrayx/steam-auto-stop-downloading
I did project with task scheduler to stop steam downloading If i'm connected to my pocket wifi.
https://github.com/xmaxrayx/steam-auto-stop-downloading