2011-08-30 08:32:07 +0000 2011-08-30 08:32:07 +0000
104
104
Advertisement

如何防止Windows 7系统中的策略强制屏幕锁定?

Advertisement

我们公司的BOFH强加屏幕锁定设置,延迟时间短得令人发指。

有什么方法可以防止自动锁屏吗?我会认为没有办法推翻策略强制设置,但也许有一种软件可以模仿用户的活动。

只是在我设置永久鼠标滚轮之前问一下。(明白了吗?)

Advertisement

答案 (11)

92
92
92
2013-04-10 17:22:35 +0000

如果仍然安装了Windows Media Player,你可以循环播放视频,然后将其最小化(样本 “Wildlife "视频可以正常使用)。默认情况下,只要视频在播放,屏幕就不会锁定。

89
89
89
2014-11-05 18:54:27 +0000

我使用了一个脚本,我把它命名为idle.vbs:

Dim objResult

Set objShell = WScript.CreateObject("WScript.Shell")    

Do While True
  objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
  Wscript.Sleep (6000)
Loop
choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/

每隔6秒,这个脚本就会快速切换键盘上的numlock,使Windows认为有人在与键盘交互,防止屏幕锁定。这可以在vanilla windows上运行,你不需要开发或脚本工具就可以使用它,只需制作一个以.vbs为扩展名的文本文件,然后双击它(或将它放在启动项中)。

编辑:你可以将这个脚本放在你的启动项中,用

&001

更多关于Choclatey (choco) CLI安装程序的信息请参见: https://chocolatey.org/

18
Advertisement
18
18
2015-06-24 17:31:31 +0000

然而,另一个选择是免费软件Caffeine程序。它是免费的,也可以用于商业用途。从程序的主页上看:

如果你的电脑出现锁机或睡眠问题,咖啡因可以让你的电脑保持清醒。它的工作原理是每59秒模拟一次按键,让你的机器认为你还在键盘前工作,因此不会锁屏或激活屏保。在所有可用的按键中,F15可能是干扰性最小的(我从未见过PC键盘上有这个键!),也最不可能干扰到你的工作。再次双击它就会将咖啡壶重新装满,并且会让你的机器保持清醒。

7
7
7
2011-08-30 14:59:16 +0000

你可以创建一个 AutoIt 脚本,让它不断地按下一个未使用的键(例如,让它切换数字锁、滚动锁),休眠一分钟左右,然后重复。或者,如果你经常使用键盘,你可以让它向任何方向移动鼠标一个像素左右。

如果你不想让它持续运行,你也可以将脚本作为一个预定任务(如果你有权限的话),在电脑不活动一段时间后启动。

这是一个非常简单的脚本,可以执行一个隐形鼠标移动,如果你不想进入AutoIt语法:

While True
   Local $pos = MouseGetPos()
   MouseMove($pos[0]-1, $pos[1]-1, 0)
   MouseMove($pos[0], $pos[1], 0)
   Sleep(540000)
WEnd

这个脚本将鼠标光标向左上方移动一个像素点,然后将其返回,然后休眠9分钟(540000毫秒)。脚本运行时,你可以在托盘中看到AutoIt图标。你可以右击这个图标并选择相应的选项来停止它。 要制作一个脚本,请安装AutoIt,在任意文件夹中右击,选择New>AutoIt v3 Script,命名,右击这个新的脚本,选择Edit,粘贴上面提供的代码并保存。你甚至可以把它编译成.exe(同样,从上下文菜单中)来启动,例如,从Windows调度器中启动。

5
Advertisement
5
5
2014-06-06 21:36:21 +0000

有一个叫 “超时阻止器 "的安卓应用,每隔一段时间就会震动,你可以把鼠标放在上面。但它说不要在工作时使用。 https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en

5
5
5
2013-03-09 03:28:45 +0000

在Visual Studio或C# Express中编译并从命令提示符中运行(或双击它)。需要.NET 4.0或以上版本。它可以实现你要找的一切。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms; 

namespace ImWorkin
{
    class Program
    {
        [FlagsAttribute]
        public enum EXECUTION_STATE : uint
        {
            ES_SYSTEM_REQUIRED = 0x00000001,
            ES_DISPLAY_REQUIRED = 0x00000002,
            ES_CONTINUOUS = 0x80000000
        }
        public SYSTEMTIMEOUTS TimeOuts
        {
            get { return sysTimeouts; }
        }
        public struct SYSTEMTIMEOUTS
        {
            public int BATTERYIDLETIMEOUT;
            public int EXTERNALIDLETIMEOUT;
            public int WAKEUPIDLETIMEOUT;
        }

        [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("USER32.DLL")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE flags);

        [DllImport("user32.dll", SetLastError = true, EntryPoint ="SystemParametersInfo")]
        internal static extern int SystemParametersInfo(int uiAction, int uiParam, ref int pvParam, int fWinIni);

        private static System.Threading.Timer preventSleepTimer = null;
        public const int SPI_GETBATTERYIDLETIMEOUT = 252;
        public const int SPI_GETEXTERNALIDLETIMEOUT = 254;
        public const int SPI_GETWAKEUPIDLETIMEOUT = 256;
        public static int Counter = 0;
        public static int timeOutinMS = 0;
        public static int batteryIdleTimer;
        public static int externalIdleTimer;
        public static int wakeupIdleTimer;
        public static SYSTEMTIMEOUTS sysTimeouts;

        static void Main(string[] args)
        {
            Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
            string dots = string.Empty;
            for (int i =2; i < 60; i++)
            {
                dots = "";
                for (int ii = 0; ii < i; ii++)
                {
                    dots = dots + ".";
                }
                Thread.Sleep(100);
                Console.Clear();
                Console.WriteLine("You are about to be workin!! Just a moment...I need to calculate a few values.");
                Console.WriteLine(dots);
            }

            GetSystemTimeOuts();

            if (timeOutinMS < sysTimeouts.BATTERYIDLETIMEOUT)
                timeOutinMS = sysTimeouts.BATTERYIDLETIMEOUT;
            if (timeOutinMS < sysTimeouts.EXTERNALIDLETIMEOUT)
                timeOutinMS = sysTimeouts.EXTERNALIDLETIMEOUT;
            if (timeOutinMS < sysTimeouts.WAKEUPIDLETIMEOUT)
                timeOutinMS = sysTimeouts.WAKEUPIDLETIMEOUT;

            if (timeOutinMS == 0)
                timeOutinMS = 30;

            DisableDeviceSleep();
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("OK. I have calculated your computers timeout periods and set the ");
            Console.WriteLine("necessary hooks. Your computer will not shut off the monitor, will");
            Console.WriteLine("show active in any chat programs,the screensaver is disabled and ");
            Console.WriteLine("the computer will not lock! Anyone looking at you eaither locally ");
            Console.WriteLine("or remotely will think you are hard at work.");
            Console.WriteLine("");
            Console.WriteLine("Now go do something fun...I got your back ;)");
            Console.WriteLine("Oh yeah....if you close this window OR press `q' in this ");
            Console.WriteLine("window you are going to have to actually work.");
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("This text will disappear in a 30 seconds. Just in case someone comes ");
            Console.WriteLine("by and reads your screen!");
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Need custom coding? Kenneth.gore@gmail.com");
            while (Console.KeyAvailable == false)
            {
                Thread.Sleep(250);
                ConsoleKeyInfo cki = Console.ReadKey(true);

                if (cki.KeyChar == 'q')
                    break;
            }

        }

        public static void DisableDeviceSleep()
        {
           SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
           preventSleepTimer = new System.Threading.Timer(new TimerCallback(PokeDeviceToKeepAwake), null, 0, timeOutinMS * 1000);
        }

        public static void EnableDeviceSleep()
        {

           preventSleepTimer.Dispose();
           preventSleepTimer = null;

        }

        private static void PokeDeviceToKeepAwake(object extra)
        {

            Counter++;
            try
            {
                   SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
                   IntPtr Handle = FindWindow("SysListView32", "FolderView");

                   if (Handle == IntPtr.Zero)
                   {
                       SetForegroundWindow(Handle);
                       SendKeys.SendWait("%1");
                   }

                   if (Counter > 1)
                       Console.Clear();
            } 
            catch 
            {

            }
        }

        public static void GetSystemTimeOuts()  
        {
            sysTimeouts.BATTERYIDLETIMEOUT = -2;
            sysTimeouts.EXTERNALIDLETIMEOUT = -2;
            sysTimeouts.WAKEUPIDLETIMEOUT = -2;

            if (SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, ref batteryIdleTimer, 0) == 1)
                sysTimeouts.BATTERYIDLETIMEOUT = batteryIdleTimer;
            else
                sysTimeouts.BATTERYIDLETIMEOUT = -1;

            if (SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, ref externalIdleTimer, 0) == 1)
                sysTimeouts.EXTERNALIDLETIMEOUT = externalIdleTimer;
            else
                sysTimeouts.EXTERNALIDLETIMEOUT = -1;

            if (SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, ref wakeupIdleTimer, 0) == 1)
                sysTimeouts.WAKEUPIDLETIMEOUT = wakeupIdleTimer;
            else
                sysTimeouts.WAKEUPIDLETIMEOUT = -1;

        }
    }
}
2
Advertisement
2
2
2018-01-16 14:55:11 +0000

我喜欢使用简单的集成的选项(不需要额外的软件),就像一个powershell脚本(感谢https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/),用 “f15 "作为成功的关键(感谢咖啡因。它确实是干扰最少的)

param($minutes = 180)

write "... screen will be awake for $minutes"

 $myshell = New-Object -com "Wscript.Shell"

 for ($i = 0; $i -lt $minutes; $i++) {
 write "... screen will be awake for" ($minutes-$i)
 Start-Sleep -Seconds 60    
 $myshell.sendkeys("{F15}")
}

把这个放到myScriptName.ps1中,然后通过桌面快捷方式或命令行启动它:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nop "C:\Users\myUser\Desktop\myScriptName.ps1"

更新:可能是管理员的一些改变,但这对我来说已经不起作用了,现在我必须使用NBirnel的自动热键脚本。https://github.com/nbirnel/nosleep —-这个工作完美,因为它可以移动鼠标(不会分散任何工作的注意力)。

1
1
1
2014-12-30 08:17:36 +0000

在我的案例中,只需将其放在Timer_Tick事件中,并将时间间隔设置为60000ms。

1
Advertisement
1
1
2017-05-23 06:00:59 +0000

鼠标夹具可能是一个选择 https://mousejiggler.codeplex.com/

-1
-1
-1
2018-10-03 15:01:08 +0000

正确的处理方法是:

  • 进入注册表中的策略所在的注册表
  • 将值设置为你想要的任何值
  • 改变注册表的密钥权限
  • 只对除你自己以外的任何人进行拒绝写权限
-5
Advertisement
-5
-5
2013-11-15 03:17:15 +0000

你应该关闭 “屏幕锁定”/“睡眠模式",从控制面板>电源选项>更改计划设置。点击下拉菜单中的 "让电脑进入睡眠模式 "并选择 "从不"。

Advertisement
Advertisement