witam dopiero zaczynam uczyć się c# i chciałbym się zapytać jak przerobić
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text.Contains("on"))
{
clicktimer.Start();
button1.Text = "Toogle: off";
}
else
{
clicktimer.Stop();
button1.Text = "Toogle: on";
}
}
ze jak klikne r to juz clicktimer dziala i zebym nie musiał klikac w buttona zeby odpalic go chodzi mi o to ze jak klikne r to bedziejuz dzialal (program co robie to autoclicker) i jak znow klikne r to zastopoje sie caly kod tutaj
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace DragClicker
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwflags, int dx, int dy, int cButtons, int dwExtraInfo);
private const int LEFTUP = 0x0004;
private const int LEFTDOWN = 0x0002;
public Form1()
{
InitializeComponent();
}
private void clicktimer_Tick(object sender, EventArgs e)
{
Random rnd = new Random();
int maxcps = (int)Math.Round(1000.0 / (trackBar1.Value + trackBar2.Value * 0.2));
int mincps = (int)Math.Round(1000.0 / (trackBar1.Value + trackBar2.Value * 0.4));
try
{
clicktimer.Interval = rnd.Next(mincps, maxcps);
}
catch
{
// ignored
}
bool mousdown = MouseButtons == MouseButtons.Left;
if (mousdown)
{
mouse_event(dwflags: LEFTUP, dx: 0, dy: 0, cButtons: 0, dwExtraInfo: 0);
Thread.Sleep(millisecondsTimeout: rnd.Next(1, 6));
mouse_event(dwflags: LEFTDOWN, dx: 0, dy: 0, cButtons: 0, dwExtraInfo: 0);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text.Contains("on"))
{
clicktimer.Start();
button1.Text = "Toogle: off";
}
else
{
clicktimer.Stop();
button1.Text = "Toogle: on";
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
jakby ktoś mi wytłumaczył albo pokazał jak to zrobić będę bardzo wdzięczny <3