Turn computer screen off using matlab function

Hi, i have a code which i want to program to turn computer screen off using matlab function. I do find code which shut down the computer such as system('shutdown -s') but i just need to turn the display off. Could anyone suggest me how to turn it off? I am using window 7. Thanks.

 採用された回答

Jan
Jan 2015 年 5 月 3 日
編集済み: Jan 2015 年 5 月 3 日

0 投票

There are many possibilities, which can be easily found by asking your favorite internet search engine:
One solution:
system('%systemroot%\system32\scrnsave.scr /s')
Or with FEX: WinPower:
WinPower('monitor', 'off');
This does not stop the processing. If the computer whould sleep also, use: Winpower('sleep').

4 件のコメント

Vittorio Cecconi
Vittorio Cecconi 2018 年 8 月 11 日
Hi! So, I checked system('%systemroot%\system32\scrnsave.scr /s') and it works. But in my case, I have 2 screens and I need to close only one of them, what should I write so that Matlab shuts only my second screen?
Thank you in advance for your cooperation!
Best, Vittorio.
Walter Roberson
Walter Roberson 2018 年 8 月 11 日
That is really a Windows problem rather than a MATLAB problem. Windows does not make it easy to do selective screensavers.
You might be able to get somewhere following up on the information in https://forum.solidworks.com/thread/220685 starting about the Youtube video.
Vittorio Cecconi
Vittorio Cecconi 2018 年 8 月 12 日
Thank you Walter! But I really need a code, so I can use it in my program.
Walter Roberson
Walter Roberson 2018 年 8 月 12 日
I am not even close to being a Windows specialist, so I might have missed something, but the information I find suggests that Windows 7 through to earlier Windows 10 only support screensavers on the primary monitor. Later Windows 10 by defaults shows the screensaver on all monitors, and has provision to configure the screensaver to display only on particular monitors, but not to configure different monitors with different screensavers or different timeouts.
So far I only see the following commercial product indicating support for different screensavers with different timeouts on multiple monitors: https://www.actualtools.com/articles/detail.php?ID=1392

サインインしてコメントする。

その他の回答 (1 件)

Marcel
Marcel 2019 年 10 月 24 日

0 投票

Trying to use WinPower I get the error "== InstallMex: failed."
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
For manually compiling I get
>> mex -O -largeArrayDims -D_LITTLE_ENDIAN -DHAS_HG2 -DMATLABVER=907 WinPower.c -v
Error using mex
C:\Users\aktiv\AppData\Local\Temp\mex_237481349027607_8440\WinPower.obj:WinPower.c:(.text+0x238): undefined reference to
`SetSuspendState'
C:\Users\aktiv\AppData\Local\Temp\mex_237481349027607_8440\WinPower.obj:WinPower.c:(.text+0x24c): undefined reference to
`SetSuspendState'
collect2.exe: error: ld returned 1 exit status
Any idea? Thanks in advance...

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

質問済み:

2015 年 5 月 3 日

回答済み:

2019 年 10 月 24 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by