C# clicker durdurma butonu

fdfgdse

Centipat
Katılım
22 Aralık 2020
Mesajlar
497
Çözümler
1
Daha fazla  
Cinsiyet
Erkek
Merhaba, ben C# Form'da böyle bir clicker yaptım. Ama ben bir tuşa bastığımda Clicker'ın durmasını istiyorum. Nasıl yapabilirim?

C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Windows.Input;

namespace end
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        [DllImport("user32.dll")]
        static extern void mouse_event(int dwFlags, int dx, int dy, int dwdata, int dwextrainfo);
        public enum mouseeventFlags
        {
            LeftDown = 2,
            LeftUp = 4,
        }
        public void leftclick(Point p)
        {
            mouse_event((int)(mouseeventFlags.LeftDown), p.X, p.Y, 0, 0);
            mouse_event((int)(mouseeventFlags.LeftUp), p.X, p.Y, 0, 0);
        }
        bool stop = true;
        private void button1_Click(object sender, EventArgs e)
        {
            stop = (stop) ? false : true;
            timer1.Interval = (int)numericUpDown1.Value;
            timer1.Enabled = true;
            if (!stop) timer1.Start();
            if (stop) timer1.Stop();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            leftclick(new Point(MousePosition.X, MousePosition.Y));
        }


      
     

        private void Form1_Load(object sender, EventArgs e)
        {
               
        }
    }
}
 
Son düzenleyen: Moderatör:
flag ekleyebilirsiniz.

En başta bool bir değişken tanımlayıp ona false değerini atayın. Sonra ilgili koşul cümlesinde (eğer değişken false ise) oluşturulan bool değişkenin değerini true yapın tıklamayı disable edin. hemen altına bir koşuş cümlesi ile eğer bu ifade true ise tıklama işlemini enabled yapın ve değişkeni false olarak ayarlayın. Aklıma bu geliyor.
 

Yeni konular

Geri
Yukarı