Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting a length of time with numericUpDowns and windows forms
    primarykey
    data
    text
    <p>I'm building an auto clicker application that makes the mouse click at a set interval of time. </p> <p><img src="https://i.stack.imgur.com/t6xOQ.png" alt="enter image description here"></p> <p>Notice the interval configuration area. I have tried to write some logic that automatically simplifies the amount of time entered. The minutes box goes up to 60, the seconds box goes up to 60, and the milliseconds box goes up to 1000. I have a class set up to handle that logic, but it's probably not the right way to do that (I'm still new at programming). </p> <pre><code>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 &amp;&amp; m_.Value &lt; 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 &amp; m_.Value &gt; 0) { s_.Value = 59; m_.DownButton(); if (ms_.Value == 1) ms_.DownButton(); } } } } </code></pre> <p>The ChangeLogic method is called each time the value in any of the boxes is updated.</p> <p>There's lots of bugs in the selection logic. For example, when the up button for seconds is held down, the program crashes. If seconds = 59 and minutes = 0, and the seconds up button is pressed, the warning "you can't have a time less than 250 milliseconds" shows up and minutes is adjusted to 2.</p> <p>I'm really confused. Can anyone help me? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload