我正在構建一個自動的Clicker應用程序,它可以在設定的時間間隔內點擊鼠標。使用numericUpDowns和windows窗體選擇時間長度
通知的間隔配置區。我試圖編寫一些能夠自動簡化輸入時間的邏輯。分鐘框上升到60,秒框上升到60,毫秒框上升到1000.我有一個類來處理這個邏輯,但它可能不是這樣做的正確方法(我是在編程中仍然是新的)。
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;
namespace AutoClicker {
public static class TotalTime {
public static int Interval(NumericUpDown m_, NumericUpDown s_, NumericUpDown ms_) {
int m = (int)m_.Value;
int s = (int)s_.Value;
int ms = (int)ms_.Value;
int total = 0;
total = total + (m * 60000);
total = total + (s * 1000);
total = total + ms;
return total;
}
public static void ChangeLogic(NumericUpDown m_, NumericUpDown s_, NumericUpDown ms_) {
int interval = Interval(m_, s_, ms_);
if (ms_.Value == 1000)
{
ms_.Value = 500;
s_.UpButton();
ms_.Value = 0;
}
if (s_.Value == 60 && m_.Value < 60)
{
if (ms_.Value == 0)
{
ms_.Value = 1;
s_.Value = 0;
m_.UpButton();
ms_.Value = 0;
}
else
{
s_.Value = 0;
m_.UpButton();
if (ms_.Value == 1)
ms_.DownButton();
}
}
if (ms_.Value == -1)
{
ms_.Value = 999;
s_.DownButton();
}
if (s_.Value == -1 & m_.Value > 0)
{
s_.Value = 59;
m_.DownButton();
if (ms_.Value == 1)
ms_.DownButton();
}
}
}
}
每次更新任何框中的值時,都會調用ChangeLogic方法。
選擇邏輯中有很多錯誤。例如,當按住秒按鈕時,程序崩潰。如果秒數= 59,分數= 0,並且按下秒數向上按鈕,則警告「您不能有少於250毫秒的時間」顯示並且分鐘被調整爲2.
我真的很困惑。誰能幫我?謝謝!
自我造成的傷口,UI過於笨拙。使用* single * NUD設置數值和單選按鈕來選擇單位。 – 2013-03-20 14:09:51
我可以嘗試,但我真的很喜歡用戶界面保持不變。 – 2013-03-20 14:32:47
@HansPassant提出的想法很可能適合你。另外:知道如何使用[斷點](http://www.blackwasp.co.uk/VSBreakpoints.aspx)可能會有很大的幫助,如果你還不知道! – Conduit 2013-03-20 14:41:09