c#定時滾動滾輪

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
namespace WindowsFormsApplication8
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        static extern void mouse_event(int flags, int dX, int dY, int buttons, int extraInfo);
        const int MOUSEEVENTF_MOVE = 0x1;
        const int MOUSEEVENTF_LEFTDOWN = 0x2;
        const int MOUSEEVENTF_LEFTUP = 0x4;
        const int MOUSEEVENTF_RIGHTDOWN = 0x8;
        const int MOUSEEVENTF_RIGHTUP = 0x10;
        const int MOUSEEVENTF_MIDDLEDOWN = 0x20;
        const int MOUSEEVENTF_MIDDLEUP = 0x40;
        const int MOUSEEVENTF_WHEEL = 0x800;
        const int MOUSEEVENTF_ABSOLUTE = 0x8000;
        int ji=1;
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (ji == 1)
            {
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -800, 0);
                Thread.Sleep(100);
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -800, 0);
                ji = 2;
            }
            else
            {
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 800, 0);
                Thread.Sleep(100);
                mouse_event(MOUSEEVENTF_WHEEL, 0, 0,800, 0);
                ji = 1;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章