topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday April 27, 2024, 4:30 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Variable-speed repeated button press  (Read 2589 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 553
    • View Profile
    • Donate to Member
Variable-speed repeated button press
« on: July 02, 2023, 01:56 AM »
Imagine repeatedly pressing the Page-Down key.  It can get old fast.  Poor index finger.

Suppose we have a Page-Down that automatically repeats.  Once every 5 seconds (the 'default').  For 100 rounds.

How cool would that be??!!

Here's the huge challenge:  Create the above.  With the following addition....

If user presses the Ctrl-Minus key, we multiply the 5 seconds by 1.05, and use that value in between each round.

If user presses the Ctrl-Plus key, we multiply the 5 seconds by 0.95, and use that value in between each round.

The idea is to get a 'variable-speed' repeated button press.

Here is some of the logic, as I see it:

There is a 'default' amount of time between button presses.  Say, 5 seconds.  There is some variable somewhere holding this value.  Let's call the variable "Rest."

Every time the user hits Ctrl-Minus, the little program looks for the variable "Rest," multiplies it by 1.05, and writes that result back to the variable location.  So, "Rest" is now 5.25.

If user hits Ctrl-Minus another time, current value of "Rest" is multiplied by 1.05, with the result then written to the variable.  "Rest" then becomes 5.51.  Etc.  Etc.

Hitting Ctrl-Plus has the opposite effect.  "Rest" value is multiplied by 0.95.

So, the 'loop' for each round looks something like this:

1.  Check value of "Rest."
2.  Wait that long.
3.  Press the Page-Down key.

Any thoughts greatly appreciated.  If you were to write such a program, what programming language would you use?

Nicholas Kormanik