简体   繁体   English

如何防止第三方应用检测到用户空闲?

[英]How to prevent third party apps from detecting user idleness?

In Discord there is no option to disable idle detection, so i want to write a little app which simulates user so that discord and other apps don't think I'm idle.Discord没有禁用空闲检测的选项,所以我想编写一个模拟用户的小应用程序,以便不和谐和其他应用程序不会认为我空闲。

I've tried using Cursor.我试过使用光标。 Position and that teleports the mouse around on the screen but it does not prevent idle detection.定位并在屏幕上传送鼠标,但它不会阻止空闲检测。

How can i simulate user input in c# windows forms application so as to fool idle detection in discord and other apps?我如何在 c# windows 窗体应用程序中模拟用户输入,以便在不和谐和其他应用程序中欺骗空闲检测?

I ended up going with the following line of code.我最终使用了以下代码行。 This just sends alt+tab to windows.这只是将 alt+tab 发送到 Windows。 Works for my purposes though a less disruptive approach would be preferable, like maybe a windows click or something.虽然破坏性较小的方法更适合我的目的,但可能适合我的目的,例如单击 Windows 之类的。

SendKeys.SendWait("%({tab})");

The code below in the button Click event could be placed into Timer.Tick event which toggles scroll lock button.按钮 Click 事件中的以下代码可以放入切换滚动锁定按钮的 Timer.Tick 事件中。

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace StackOverflow_PressScrollLock
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        static extern void keybd_event(
            byte bVk, 
            byte bScan, 
            uint dwFlags, 
            UIntPtr dwExtraInfo);

        public Form1()
        {
            InitializeComponent();
        }
        private static void PressScrollLock()
        {
            const byte vkScroll = 0x91;
            const byte keyeventfKeyup = 0x2;

            keybd_event(vkScroll, 0x45, 0, (UIntPtr)0);
            keybd_event(vkScroll, 0x45, keyeventfKeyup, (UIntPtr)0);
        }
        /// <summary>
        /// This would go in a Timer.Tick event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExecuteButton_Click(object sender, EventArgs e)
        {
            PressScrollLock();
            PressScrollLock();
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM