topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday June 12, 2025, 7:59 am
  • 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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - nkormanik [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 23next
1
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 20, 2025, 12:29 AM »
All looks great, Vic!!

I hope others will comment as well.

2
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 09, 2025, 03:49 PM »
I guess your comments point to the need for expert programming and architecture.

Vic! has done a fine job with other projects.

Hope others on here will chime in with suggestions.


3
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 08, 2025, 04:38 PM »
Below is an enhanced Python version, complements of ChatGPT:

Using **PyQt** is an excellent choice for creating a robust, visually appealing, and fully functional GUI application. Below is an enhanced Python script leveraging **PyQt6**, which offers modern GUI features and is well-suited for a program like this.

---

### Python Program with PyQt6

```python
import sys
import pyautogui
import threading
import time
from PyQt6.QtWidgets import (
    QApplication,
    QMainWindow,
    QLabel,
    QPushButton,
    QVBoxLayout,
    QWidget,
    QSpinBox,
)
from PyQt6.QtCore import QTimer


class PageDownApp(QMainWindow):
    def __init__(self):
        super().__init__()

        # Initialize parameters
        self.n_delay = 5  # Delay in seconds
        self.is_running = False
        self.thread = None

        # Set up GUI
        self.setWindowTitle("Page Down Automation")
        self.setGeometry(100, 100, 400, 300)

        # Main layout
        layout = QVBoxLayout()

        # Status Label
        self.status_label = QLabel("Status: Stopped", self)
        self.status_label.setStyleSheet("font-size: 14px; color: black;")
        layout.addWidget(self.status_label)

        # Start Button
        self.start_button = QPushButton("Start", self)
        self.start_button.setStyleSheet("background-color: green; color: white; font-size: 14px;")
        self.start_button.clicked.connect(self.start_loop)
        layout.addWidget(self.start_button)

        # Stop Button
        self.stop_button = QPushButton("Stop", self)
        self.stop_button.setStyleSheet("background-color: red; color: white; font-size: 14px;")
        self.stop_button.clicked.connect(self.stop_loop)
        layout.addWidget(self.stop_button)

        # Delay Adjuster
        self.delay_label = QLabel("Set Delay (seconds):", self)
        self.delay_label.setStyleSheet("font-size: 14px;")
        layout.addWidget(self.delay_label)

        self.delay_spinbox = QSpinBox(self)
        self.delay_spinbox.setValue(self.n_delay)
        self.delay_spinbox.setRange(1, 60)  # Set delay range between 1-60 seconds
        self.delay_spinbox.valueChanged.connect(self.update_delay)
        layout.addWidget(self.delay_spinbox)

        # Exit Button
        self.exit_button = QPushButton("Exit", self)
        self.exit_button.setStyleSheet("background-color: gray; color: white; font-size: 14px;")
        self.exit_button.clicked.connect(self.exit_app)
        layout.addWidget(self.exit_button)

        # Set main layout
        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)

    def update_delay(self):
        """Update the delay value."""
        self.n_delay = self.delay_spinbox.value()
        self.update_status()

    def update_status(self):
        """Update the status label."""
        self.status_label.setText(
            f"Status: {'Running' if self.is_running else 'Stopped'} (Delay: {self.n_delay} sec)"
        )

    def start_loop(self):
        """Start the PgDn loop."""
        if self.is_running:
            return
        self.is_running = True
        self.update_status()
        self.thread = threading.Thread(target=self.page_down_loop, daemon=True)
        self.thread.start()

    def stop_loop(self):
        """Stop the PgDn loop."""
        self.is_running = False
        self.update_status()

    def page_down_loop(self):
        """Continuously send PgDn key presses."""
        while self.is_running:
            pyautogui.press("pagedown")
            time.sleep(self.n_delay)

    def exit_app(self):
        """Handle program exit."""
        self.stop_loop()
        QApplication.quit()


# Main program
if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = PageDownApp()
    window.show()
    sys.exit(app.exec())
```

---

### Features and Enhancements:

#### 1. **Modern GUI with PyQt6:**
   - PyQt6 provides a sleek, professional, and user-friendly interface.
   - The GUI includes labels, buttons, and a spin box for intuitive control.

#### 2. **Dynamic Delay Adjustment:**
   - The `QSpinBox` allows users to adjust the delay dynamically in seconds.
   - Delay updates are reflected immediately in the status label.

#### 3. **Threading for Responsiveness:**
   - The `threading.Thread` runs the Page Down loop in the background, keeping the GUI responsive.

#### 4. **Start/Stop Buttons:**
   - Clear start and stop buttons control the automation loop.
   - Buttons are color-coded (green for Start, red for Stop) for easy recognition.

#### 5. **Cross-Platform Compatibility:**
   - Python and PyQt6 work seamlessly on Windows, macOS, and Linux.
   - The program uses `pyautogui` for sending the `PgDn` key, which is also cross-platform.

#### 6. **Safe Exit:**
   - The program stops the loop safely and exits gracefully when the "Exit" button is clicked.

#### 7. **Customizable Range for Delay:**
   - Users can set the delay within a predefined range (1-60 seconds by default).
   - The range can be adjusted as needed.

#### 8. **Clear Visual Feedback:**
   - The status label updates dynamically to show whether the script is running and displays the current delay.

---

### Potential Future Enhancements:

1. **System Tray Integration:**
   - Use `pystray` to minimize the program to the system tray for background operation.

2. **Custom Key Simulation:**
   - Allow the user to specify which key (e.g., `PgDn`, `Arrow Down`) to simulate.

3. **Config Persistence:**
   - Save user preferences (e.g., delay) to a configuration file (`JSON`, `INI`, etc.) and load them on startup.

4. **Target Window Selection:**
   - Integrate with `pygetwindow` to specify a target window for sending key presses.

5. **Advanced Logging:**
   - Add logging with timestamps to track key presses and program activity.

6. **Enhanced GUI Features:**
   - Add a progress bar or visual indicator to show when the next key press will occur.
   - Include light and dark mode options.

---

This PyQt6-based version is user-friendly, powerful, and highly extensible, offering a significant improvement over both the AutoHotkey and earlier Python versions.

4
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 08, 2025, 04:32 PM »
Below is an 'enhanced' Autohotkey version, complements of ChatGPT:

The provided AutoHotkey script (Skwire's) is a simple and effective program to repeatedly send the "Page Down" key (`PgDn`) to a target window at adjustable intervals. It has some solid features, but there are several potential improvements for better functionality, flexibility, and user experience. Here's a breakdown of the current features and suggestions for improvement:

---

### Current Features:
1. **Auto Page Down Loop:**
   - The script repeatedly sends the `PgDn` key at intervals defined by `nDelay`.
   - The delay can be adjusted dynamically using keyboard shortcuts.

2. **Dynamic Delay Adjustment:**
   - Use `Ctrl + NumpadAdd` or `Ctrl + Equals` to decrease delay by 500 ms.
   - Use `Ctrl + NumpadSub` or `Ctrl + Dash` to increase delay by 500 ms.
   - The delay is displayed in the tray tooltip for feedback.

3. **Termination Shortcut:**
   - Use `Ctrl + ESC` to immediately exit the script.

4. **Efficient Performance Settings:**
   - `SetBatchLines, -1` and `SetControlDelay, -1` are used to enhance script performance.

5. **File Encoding:**
   - Ensures UTF-8-RAW encoding for compatibility.

---

### Suggestions for Improvement:

#### 1. **Add Bounds for `nDelay`:**
   Prevent the delay from being too small (e.g., less than 100 ms) or unreasonably large.
   ```ahk
   nDelay := Max(100, Min(nDelay, 10000)) ; Clamp delay between 100 ms and 10,000 ms.
   ```

#### 2. **Display Current Delay on Adjustment:**
   Include a notification or visual feedback to show the updated delay when it changes, beyond just the tooltip.
   ```ahk
   ToolTip, Delay adjusted to: %nDelay% ms
   SetTimer, RemoveToolTip, -1000 ; Automatically removes the tooltip after 1 second.
   ```

#### 3. **Add Start/Stop Toggle:**
   Allow users to pause and resume the loop with a toggle key.
   ```ahk
   toggle := true
   ^Space:: ; Ctrl + Space to toggle start/stop.
   toggle := !toggle
   if (toggle)
       SetTimer, PageDownLoop, % nDelay
   else
       SetTimer, PageDownLoop, Off
   Return
   ```

#### 4. **Enhanced Error Handling:**
   Include safeguards to ensure the script handles unexpected conditions, such as missing permissions or hidden target windows.

#### 5. **Customize Target Window:**
   Allow users to specify the target window for sending the `PgDn` key, instead of assuming the focused window.
   ```ahk
   WinGet, targetWindow, ID, A ; Get the active window.
   ```

#### 6. **Improved Tray Menu Options:**
   Add a tray menu to control the script directly without needing keyboard shortcuts.
   ```ahk
   Menu, Tray, Add, Start/Stop Loop, ToggleLoop
   Menu, Tray, Add, Increase Delay, IncreaseDelay
   Menu, Tray, Add, Decrease Delay, DecreaseDelay
   Menu, Tray, Add, Exit, ExitApp
   ```

#### 7. **Save/Restore Delay Setting:**
   Persist the delay setting between script sessions using an `.ini` file or similar approach.
   ```ahk
   IniRead, nDelay, Settings.ini, General, Delay, 5000
   OnExit, SaveSettings
   SaveSettings:
       IniWrite, %nDelay%, Settings.ini, General, Delay
   Return
   ```

#### 8. **Add Hotkey Feedback:**
   Add audible or visual feedback when using hotkeys for better user awareness.

#### 9. **Option to Adjust Step Size:**
   Allow dynamic adjustment of the increment/decrement step size (currently fixed at 500 ms).
   ```ahk
   stepSize := 500 ; Default step size for delay adjustment.
   ^+NumpadAdd::stepSize += 100 ; Ctrl + Shift + Numpad+ to increase step size.
   ^+NumpadSub::stepSize -= 100 ; Ctrl + Shift + Numpad- to decrease step size.
   ```

#### 10. **Prevent Simultaneous Inputs:**
   Avoid sending multiple `PgDn` inputs if the delay is too short and the target window is unresponsive.

#### 11. **Comments for Clarity:**
   Include detailed comments for better readability and maintainability.

---

### Revised Code with Improvements:

```ahk
#SingleInstance, Force
SetBatchLines, -1
SetControlDelay, -1
DetectHiddenWindows, On
SetWorkingDir, %A_ScriptDir%
FileEncoding, UTF-8-RAW

; Initialize variables
nDelay := 5000 ; Starting delay in milliseconds.
stepSize := 500 ; Step size for delay adjustment.
toggle := true ; Loop is active by default.

Menu, Tray, Tip, % "Delay: " . nDelay " ms"
Sleep, 5000 ; Initial delay to focus the target window.

; Main Loop
SetTimer, PageDownLoop, %nDelay%

PageDownLoop:
    if (toggle) {
        SendInput, {PgDn}
    }
Return

; Hotkeys to adjust delay
^NumpadAdd::
^=:: ; Increase speed
    nDelay := Max(100, nDelay - stepSize)
    UpdateDelay()
Return

^NumpadSub::
^-:: ; Decrease speed
    nDelay := Min(10000, nDelay + stepSize)
    UpdateDelay()
Return

; Pause/Resume toggle
^Space::
    toggle := !toggle
    if (toggle)
        SetTimer, PageDownLoop, % nDelay
    else
        SetTimer, PageDownLoop, Off
    ToolTip, Loop % (toggle ? "Resumed" : "Paused")
    SetTimer, RemoveToolTip, -1000
Return

; Adjust step size
^+NumpadAdd::
    stepSize := Min(1000, stepSize + 100)
    ToolTip, Step size: %stepSize% ms
    SetTimer, RemoveToolTip, -1000
Return

^+NumpadSub::
    stepSize := Max(100, stepSize - 100)
    ToolTip, Step size: %stepSize% ms
    SetTimer, RemoveToolTip, -1000
Return

; Exit script
^ESC::ExitApp

; Update delay and display feedback
UpdateDelay() {
    global nDelay
    Menu, Tray, Tip, % "Delay: " . nDelay " ms"
    ToolTip, Delay adjusted to: %nDelay% ms
    SetTimer, RemoveToolTip, -1000
}

RemoveToolTip:
    ToolTip
Return
```

---

### Key Improvements:
1. Added bounds for `nDelay`.
2. Enhanced visual feedback with `ToolTip`.
3. Introduced a toggle for starting/stopping the loop.
4. Added tray menu for user control.
5. Made delay adjustment step size configurable.
6. Included detailed comments for clarity.

This revised version is more user-friendly, robust, and flexible while maintaining high performance.

5
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 08, 2025, 04:20 PM »
My preference would be the option that serves the greatest needs out there.

In Windows presently there seems to be no native program for accomplishing what is outlined above, strangely, in my view.

In Android there is a very good reading program with such functionality built in -- Moon+ Reader.  Android programs can be run in Windows -- for at least the present, word is that Microsoft will dump this ability -- but it involves extra overhead and clunkiness.

Skwire's Autohotkey approach works, but is that the best solution for the greatest number of people?

Maybe some others here will have an opinion?

The very best solution would be for Calibre to build this function in.  Calibre does have 'auto scrolling', but it is just the entire page scrolling up one line at a time, which, to me, seems silly.  Far better to have the entire page changing, as works with page up and page down.

6
Post New Requests Here / Re: Variable-speed repeated button press
« on: January 07, 2025, 04:36 PM »
Sounds wonderful, Vic!

I hope you can accomplish this.  Hope others here toss in their two cents to make the mission clearer for as many users as possible.

Ctrl-plus = page-down rate a little faster in our reader program
Ctrl-minus = page-down rate a little slower in our reader program


I use Calibre for reading epubs.  I've requested for years for them to incorporate something like this.  Seems that it should be relatively easy.  I don't really understand why it's not.  What am I missing??

Guess you'll have to be the one.

Thanks!!


7
PublicDomainVic / Re: nkDot-corners v0.1.0
« on: May 26, 2024, 02:19 PM »
Enhancement Requests:

Speed dynamically adjustable while program is running.  Using up-arrow and down-arrow.  Increase or decrease the speed incrementally with each press of those buttons.  Default increment would be, say, 5% of the current speed.  Speed change only affects current session.  Next session returns to default that user has set.

Countdown timer, shown inconspicuously in the upper-left-hand corner of the window.  When time expires, the program quits entirely.  Resolution should be in seconds.  Zero-padded to minutes.  Example: 1:23, 0:45, 0:06, ...

Current speed shown in upper right-hand corner of the window.  Same font and style as the countdown timer.  Number will change if user presses the up-arrow or down-arrow.

No need for labels.  Just show the numbers.  User should know what the numbers mean.

Colors preference: Font = navy blue.

Red dot should not overwrite the numbers at the top.  There should be a small distance between the numbers and the red dot.  Perhaps 10-20 pixels or so.

Aside from not overwriting the numbers, the program can maintain corner-to-corner behavior.

Thanks much, Vic!

Nicholas Kormanik

 Eye Exercise.png

p.s. -- Ignore the figure in the middle of the red circle shown above.  I included that in another similar program created with Python.  I included that star figure to better ensure visual focusing during the execution of the program.


8
PublicDomainVic / Re: nkDot-corners v0.1.0
« on: April 18, 2024, 12:51 AM »
I really, really like nkDot-corners.  One possible 'enhancement' would be to allow for increasing animation speed using the Up Arrow key, decrease animation speed with the Down Arrow key.  Not completely necessary, however.

Here is another related program.  'Claude 3 Opus' helped me make it using Python.  It has the key functionality mentioned above.  I run it on a 4K monitor, so the settings are for that.  User can adjust to their preferences by editing the Python code.



9
Vic!, I discovered that Shift-S loads the next link in the list.

Very useful little program.  Thank you!

10
Vic!, for Urlister what are the hotkeys mentioned in the menu?  Are they global?  In other words, if one is currently in the browser and hits the hotkey for next url will Urlister proceed onto the next webpage?

Thanks!

11
PublicDomainVic / Re: Single Dot in Graphics Window
« on: November 01, 2023, 01:20 AM »
Wow, Vic!  My eyes are popping out.  But that's precisely what I asked for.

Monumental achievement.  You the best!

12
PublicDomainVic / Re: Single Dot in Graphics Window
« on: October 22, 2023, 01:45 AM »
Vic!  Attached is a Python version of what I have in mind (have to rename extension to .py).

It's asking a lot of you, but I really like nkDot-Random.  Beautifully smooth.  And easy to configure using your included editor.

So, hoping you will continue to have time to work on nkDot-Corners.

Thanks a million!
Nicholas


13
PublicDomainVic / Re: Single Dot in Graphics Window
« on: September 27, 2023, 05:59 PM »
Big smile, Vic!

You da man.

14
PublicDomainVic / Re: Single Dot in Graphics Window
« on: September 17, 2023, 06:11 PM »
Vic, I'd prefer nkDot-Corners be a separate program, so that when one double-clicks on it it just does its thing.  No muss no fuss.  Exactly as nkDot-Random does.

Hope it's not too difficult.

Thanks!

15
PublicDomainVic / Re: Single Dot in Graphics Window
« on: September 03, 2023, 02:30 AM »
nkDot-Random
nkDot-Corners

Super, Vic!  Really looking forward to it.

16
PublicDomainVic / Re: Timed Key Repeat, With Variable Timing
« on: September 03, 2023, 02:26 AM »
Pretty exciting, Vic!

17
PublicDomainVic / Re: Single Dot in Graphics Window
« on: August 24, 2023, 02:26 AM »
Vic, a possible enhancement request, if you might have the time.

Could be a separate program, very similar to the existing one.  Or could be an addition built into the present program.

Suppose the latter.  Incorporate: "Mode".

Existing mode is what exists presently.  Let's call it "Random".

A second mode, though, would be quite useful.  Let's call it "Corners".

(or a separate program called, perhaps, "Corners Dot".)

In this second mode, a single dot (exactly as in present program) appears in the North-West corner.  Then jumps to the South-East corner.  Then to the North-East corner.  And finally to the South-West corner.  After those four dots -- creating, basically, a large X -- process simply repeats for the allotted time.

Any thoughts?

Thanks!
Nicholas



18

Vic, the menu shows an option to use hotkeys.

Please explain how to do that; what hotkeys?


19
PublicDomainVic / Re: Single Dot in Graphics Window
« on: July 28, 2023, 03:24 AM »
Very nice little gem, Vic!

Thanks a million.

20
PublicDomainVic / Re: Single Dot in Graphics Window
« on: July 27, 2023, 03:46 AM »
Just curious, Vic....

Is the random pattern the same each and every time, or does it change each time?

Oftentimes a random number series starts with a 'seed.'  If the seed is the same each run, the runs are identical.

If the 'seed' comes from, say, the current time, down to the millisecond, the series will always be different.

21
PublicDomainVic / Re: Timed Key Repeat, With Variable Timing
« on: July 10, 2023, 01:22 AM »
No rush, Vic.  Thanks for the update.

At this point it seems it will have to be YOU that puts this together.

I've put basically the same request out to the general community, but not a nibble received.

The basic concept, shortened, is to just keep a loop going, pressing Enter.  Check with some variable on how much time to spend between presses.

The variable can be anywhere:  .ini file, environment variable, text file, etc.

First check the variable.  Let's suppose 5 seconds.
Wait that amount of time.
Press Enter.

Repeat.  Repeat.  Repeat.

Finally, I always want to ask, just in case, what coding language is best for such an assignment?


22
Post New Requests Here / 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




23
PublicDomainVic / Re: Timed Key Repeat, With Variable Timing
« on: May 26, 2023, 08:54 PM »
Previously others have chimed in on Vic's thread when I've suggested a little program.  Infact, someone beat Vic to the punch and came up with a real gem fast as lightning (Folder Renamer by KodeZwerg).  So, folks are apparently keeping an eye on Vic's neck of the woods here.

24
PublicDomainVic / Timed Key Repeat, With Variable Timing
« on: May 24, 2023, 02:59 AM »
Prologue:  To read maximally our eyes must move rapidly.  Some of us are lucky to naturally develop this at an early age.  It might still be possible for others of us to learn later.

The idea of the asked-for program is to help with reading development.

Disclaimer:  No guarantees.  Use at your own risk.

=====

The present program I use to read epubs is Calibre Viewer (CV).  Seems about the best currently available for Windows.

CV lacks a particular ability that I'd really like to have.  Maybe you, Vic!, or someone here can come up with a solution.

CV allows user to select keys for various actions.  Enter, for instance, can be used for Page Down.

I'd like the following:

Upon execution of the mini-program, perhaps via desktop shortcut...

(Program must remain focused on CV, by the way (possibly user selectable, for other programs, like Acrobat, Word, Edge, Chrome, etc.?).  Not focused on program itself, desktop, etc.)

...Press Enter (specific key possibly user selectable) repeatedly, with a particular amount of time between each press, say, 5 seconds (possibly user selectable).

(The above can easily be done using a standard macro program.  I use Macro Express.)

(Here is where things get really tricky, and coding expertise is required.)

While this repeat-Enter process is going on...

Press the keypad (-) key to slow down the process.  Say, for instance, by 5%.  (Possibly user selectable.)

Press the keypad (+) key to speed up the process.  Say, for instance, by 5%.  (Possibly user selectable.)

Continue on with the repeat-Enter process for a user selected time.  Say, for instance, 5 minutes.

After completion of the above, open a small window center screen that says, "Rapid Reading Time Completed!"  (or, possibly user selectable text message.)

Upon closing the small window, the program terminates entirely.

Any thoughts or suggestions greatly appreciated.

Nicholas Kormanik


25
PublicDomainVic / Re: Single Dot in Graphics Window
« on: May 23, 2023, 07:10 PM »
I love it, Vic!!  You continue to do the amazing!

Pages: [1] 2 3 4 5 6 ... 23next