How to prevent Windows from Screensaver while program running
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to prevent Windows from Screensaver while program running
I have a Windows app built in LC that I want to disable the screensaver while running. You know, like all of the media player apps disable the screensaver while in "full screen" mode, so that you don't have to wiggle the mouse every 5 minutes while watching a movie. How could I achieve this in LC?
Re: How to prevent Windows from Screensaver while program running
Well, let me start off by saying it has been a long LONG time since I used windows for...anything really.
Having said that, from the cli, i remember at one time running a batch file I wrote that killed the screen saver process by simulating a mouse move to 0,0.
I think I'd either try to reconstruct that type of thing if I had the need, or, I'm pretty sure you could move the mouse in Lc (not sure if that qualifies to stop the screen saver though, but sure worth a shot), or possibly it could be as simple as sending a click at a given interval, like every 5 minutes -
Having said that, from the cli, i remember at one time running a batch file I wrote that killed the screen saver process by simulating a mouse move to 0,0.
I think I'd either try to reconstruct that type of thing if I had the need, or, I'm pretty sure you could move the mouse in Lc (not sure if that qualifies to stop the screen saver though, but sure worth a shot), or possibly it could be as simple as sending a click at a given interval, like every 5 minutes -
Lc Dictionary wrote: click
type
command
syntax
click [button mouseButtonNumber] at point [with key [, key [, key]]]
summary
Simulates a mouse click.
Re: How to prevent Windows from Screensaver while program running
I thought of doing something like that, but was hoping for something a bit more elegant.
I found some information in StackExchange that said there is a function in the Windows API called "SetThreadState" that programs like PowerPoint and Windows Media Player call on for this very task, but not sure how to write that into my LiveCode program.
Is there a way to do a Windows-specific API call in the LC script?
I found some information in StackExchange that said there is a function in the Windows API called "SetThreadState" that programs like PowerPoint and Windows Media Player call on for this very task, but not sure how to write that into my LiveCode program.
Is there a way to do a Windows-specific API call in the LC script?
Re: How to prevent Windows from Screensaver while program running
Not as far as I know short of writing an external or perhaps running a vbscript, perhaps someone else knows better. Me, I go for what works, I leave extreme elegance to people who understand it
I did come across this page in Max's excellent wiki though.
*Edit - I did find this little note in rev 2.2x -
**Edit 2 - I also hit these pages on SOT (man I love that site) -
http://www.sonsothunder.com/devres/live ... ext002.htm
http://www.sonsothunder.com/devres/live ... ext003.htm
I did come across this page in Max's excellent wiki though.
*Edit - I did find this little note in rev 2.2x -
.. so maybe?Go beyond Transcript
You can extend Revolution's capabilities using XCMDs and XFCNs (on Mac OS and OS X systems) and DLLs (on Windows).
To use an XCMD or XFCN, copy it to the stack's resource fork. To use a DLL, refer to it using the "externals" property. You can use external commands and functions in your scripts, the same as built-in Transcript commands and functions.
**Edit 2 - I also hit these pages on SOT (man I love that site) -
http://www.sonsothunder.com/devres/live ... ext002.htm
http://www.sonsothunder.com/devres/live ... ext003.htm
Re: How to prevent Windows from Screensaver while program running
Hi,
a rather crude way is demonstrated in the attached stack. Idea is to send a keystroke periodically that prevents the screen saver from kicking in. NUMLOCK came to mind - twice in quick succession.
Actually this idea came from VBS forums. Anyway, I couldn't get it running via the usual
For whatever reason. The VBS is rather simple & runs fine when invoked in any other way:
As you see, it invokes NUMLOCK twice, with 10ms pause.
To make it work in LC I had to make an .exe from it. Find it attached as "HitNum10.exe".
Now you might be a smart coder & ever reluctant to run .exes from shady sources - for you it's attached as a simple .vbs text file. And if you want to compile it yourself, I have added a link to the tool I used to compile. The evaluation version works well.
Remark: Both VBS & stack are "quick & dirty". Use at your own risk! (It didn't eat my machine, though.)
Have fun!
a rather crude way is demonstrated in the attached stack. Idea is to send a keystroke periodically that prevents the screen saver from kicking in. NUMLOCK came to mind - twice in quick succession.
Actually this idea came from VBS forums. Anyway, I couldn't get it running via the usual
Code: Select all
do myVBS as "VBScript"
Code: Select all
Set myShell = WScript.CreateObject("WScript.Shell")
myShell.SendKeys ("{NUMLOCK}")
WScript.Sleep 10
myShell.SendKeys ("{NUMLOCK}")
To make it work in LC I had to make an .exe from it. Find it attached as "HitNum10.exe".
Now you might be a smart coder & ever reluctant to run .exes from shady sources - for you it's attached as a simple .vbs text file. And if you want to compile it yourself, I have added a link to the tool I used to compile. The evaluation version works well.
Remark: Both VBS & stack are "quick & dirty". Use at your own risk! (It didn't eat my machine, though.)
Have fun!
- Attachments
-
- NoSleep.zip
- A rather crude demo that prevents the screen from sleeping
- (124.96 KiB) Downloaded 267 times
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: How to prevent Windows from Screensaver while program running
AxWald,
Dredging up an old thread in desperation. Haha.
I tried your approach and it works, but running that external executable seems to be a blocking operation, because my clock readout freezes for a second or two until it finishes executing. Since my application is a precision clock, that is a no go Is there a way to make such a script execution non-blocking? I found a couple of threads about this but didn't find a solution.
I've tried numerous other tricks and asked some questions regarding those, but not getting any responses, so thinking it is just too difficult for LiveCode to accomplish. My Python program executes it in one line and doesn't require strange keyboard hacks to run every few seconds, so it is frustrating that I can't execute the same thing in this environment.
Dredging up an old thread in desperation. Haha.
I tried your approach and it works, but running that external executable seems to be a blocking operation, because my clock readout freezes for a second or two until it finishes executing. Since my application is a precision clock, that is a no go Is there a way to make such a script execution non-blocking? I found a couple of threads about this but didn't find a solution.
I've tried numerous other tricks and asked some questions regarding those, but not getting any responses, so thinking it is just too difficult for LiveCode to accomplish. My Python program executes it in one line and doesn't require strange keyboard hacks to run every few seconds, so it is frustrating that I can't execute the same thing in this environment.