青与鱼博客

@青与鱼

December 27th 2018 / 玩玩编程

c#写一个抓不到的程序

一个exe,鼠标移动过来的时候就换个位置
。。。

public partial class MainForm : Form
    {
        private int x = 0, y = 0;
        private Random rd = new Random();
        public MainForm()
        {
            InitializeComponent();
            //没有任务栏
            this.ShowInTaskbar = false;
            //没有标题
            this.FormBorderStyle = FormBorderStyle.None;
            //屏幕大小
            Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);
            x = ScreenArea.Width;
            y = ScreenArea.Height;
        }

        private void onMouseEnter(object sender, EventArgs e)
        {
            SetDesktopLocation(rd.Next(1,x), rd.Next(1,y));
        }

        private void onFormClose(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            SetDesktopLocation(rd.Next(1, x), rd.Next(1, y));

        }

    
    }

有注释,可见意思

发表评论
已登录为 [退出]


皖ICP备16001584号-2
x
皖ICP备16001584号-2