模拟鼠标移动程序实现——解决域控制器策略强制电脑锁屏问题(转)

参考文章:https://blog.csdn.net/water_0815/article/details/54959062

在此基础上增加了窗口后台运行的功能,解决了自己的强迫症.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace MouseMoveTimer
{
    class Program
    {
        [DllImport("User32.dll", EntryPoint = "ShowWindow")]
         private static extern bool ShowWindow(IntPtr hWnd, int type);

        [DllImport("User32.dll", EntryPoint = "FindWindow")]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("User32.dll", EntryPoint = "mouse_event")]
        private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

        private const int MOUSEEVENTF_MOVE = 0x0001;
        static void Main(string[] args)
        {
            // 1. 输入鼠标定时移动的时间间隔(秒)
            Console.WriteLine("Input the Timer Interval by second: ");
            string timerInterval = Console.ReadLine();

            // 2. 定义定时器
            int TimerInterval;
            if (Int32.TryParse(timerInterval, out TimerInterval))
            {
                Timer timer = new System.Timers.Timer(); // 定义定时器
                timer.Enabled = true; // 启用定时器
                timer.Interval = 1000 * TimerInterval; // 设定时间间隔(毫秒:1秒 = 1000毫秒)

                timer.Elapsed += new ElapsedEventHandler(MoveMouseHandler); // 等到间隔时间到,执行
            }
            else
            {
                Console.WriteLine("Error: Please input a number!");
            }

            // 2.Plus 添加后台运行功能
            Console.Title = "MyConsole";
            IntPtr ParenthWnd = new IntPtr(0);
            ParenthWnd = FindWindow(null, "MyConsole");
            ShowWindow(ParenthWnd, 0);//隐藏本dos窗体, 0: 后台执行;1:正常启动;2:最小化到任务栏;3:最大化

            // 3. 保持程序不退出
            Console.ReadKey();
        }

        private static void ShowWindow(object parenthWnd, int v)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 定时器方法体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected static void MoveMouseHandler(object sender, System.Timers.ElapsedEventArgs e)
        {
            // 将鼠标移动一个像素
            mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
        }
    }
}

原文地址:https://www.cnblogs.com/Stephen-Qin/p/12077390.html

时间: 2024-07-31 09:14:08

模拟鼠标移动程序实现——解决域控制器策略强制电脑锁屏问题(转)的相关文章

强制卸载域控制器

在日常生活中我们通过正常方式卸载与空的时候可能无法将其完全的清除干净,这时我们就需要通过强制卸载域控制器的方式将其卸载. 下面我们就做一个关于如何强制卸载域控制器的实验: 首先我准备了两台域控服务器分别为server01.server02.下面我们要将在server02服务器上面的域控制器进行强制卸载. 第一步:点击管理--删除角色和功能,如下图所示: 之后会出现"删除角色和功能向导",按照提示进行"下一步"操作,如下图所示: 将"Active Direc

python模拟鼠标键盘操作 GhostMouse tinytask 调用外部脚本或程序 autopy右键另存为

1.参考 autopy (实践见最后一章节) 用Python制作游戏外挂(上) AutoPy Introduction and Tutorial autopy.mouse.smooth_move(1, 1) 可以实现平滑移动 autopy - API Reference pip install PyUserInput SavinaRoja/PyUserInput [python3.5][PyUserInput]模拟鼠标和键盘模拟 Python-模拟鼠标键盘动作 autoit selenium借助

python + selenium webdriver 通过python来模拟鼠标、键盘操作,来解决SWFFileUpload调用系统底层弹出框无法定位问题

Webdriver是基于浏览器操作的,当页面上传文件使用的是flash的控件SWFFileUpload调用的时候,调用的是系统底层的文件选择弹出框 这种情况,Webdriver暂时是不支持除页面外的其他操作 前期尝试过很多种方法,比如send_keys("path"),但是都无法解决 虽然Webdriver无法对底层进行操作,但是Python的扩展是可以的 通过模拟鼠标.键盘的操作,可以解决这个问题,但是这个方法比较笨,而且不怎么理想,如果有好的方法,请留言给我,谢谢! 解决方法: 1

求助:程序如何模拟鼠标点击一个TreeView节点?

void CreateTreeViewControl(HWND hMainWnd) { g_hTreeView = CreateWindow(WC_TREEVIEW, _T("Tree View"), WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT, 5, 5, 320, 480, hMainWnd, NULL, hInst, NULL); TVINSERTSTRUCT tvInsertStruct

解决 DFS 命名空间服务无法初始化该域控制器上的跨林信任信息

网友反馈,在 Windows Server 2008 R2 上安装 Active Directory 服务之后,重新服务器可能会收到"DFS命名空间服务无法初始化该域控制器上的跨林信任信息--"的错误警告.但是根据实际的测试,该问题的出现几率很低,但是确实也有发生. 出现该错误警告的原因是由于 DFS 服务在 Active Directory 初始化完毕前就进行访问,所以要解决该问题只需要将"DFS Namespace"服务改为"自动(延迟启动)"

通过迁移的方式解决Active Directory服务器问题之3-转移域控制器角色到中转服务器

2 转移域控制器角色到中转服务器 我们引入"中转"服务器的作用,是在迁移的过程中,将原来"有问题"的Active Directory的域用户信息"转移"到中转服务器,等原来的域服务器重新安装后再"迁移"回去,在本节将执行以下几个操作: 将"中转"服务器安装操作系统,与要迁移的.有问题的Active Directory服务器系统相同(最好是操作系统补丁也一致). 将中转服务器加入到现有域并成为"额外

创建BDC域控制器时,提示“出站复制验证失败。在复制源域控制器上未启用出站复制”的解决办法

创建BDC域控制器时,在完成角色添加后的部署界面,进行配置后的先决条件检查,提示失败如下: 后在现有DC上通过windows powershell(CMD管理员模式)运行repadmin /showrepl,得到 运行repadmin /options [YourServerName] -disable_inbound_replrepadmin /options [YourServerName] -disable_outbound_repl 两个命令,去除disable repl选项后,即可开启

Delphi下利用WinIo模拟鼠标键盘详解

http://www.cnblogs.com/rogee/archive/2010/09/14/1827248.html 本文最早在编程论坛上发表,文章地址:http://programbbs.com/bbs/view12-17207-1.htm,相关文件可以在上述地址的页面中下载.转载时请注明出处. 前言 一日发现SendInput对某程序居然无效,无奈只好开始研究WinIo.上网查了很多资料,发现关于WinIo模拟鼠标键盘的资料很少,有的也只是支言片语讲的不是很详细,而且大部分都是关于模拟键

升级域控制器-从Windows 2012升级到2016案例之1

Microsoft已经发布了Windows Server 2016的正式版,为了深入了解与学习这个产品,第一时间将我的实验环境中的服务器升级到了Windows Server 2016,整个升级过程比较顺利,只是在升级后一些小问题也一一解决,现在将整个升级过程展现出来,希望对读者有所帮助. 我当前的实验环境有3台服务器,系统都是Windows Server 2012 R2 Datacenter版本,其中1台是域控制器,另2台是成员服务器,其中一台是WSUS服务器,一台是Hyper-V Server