Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Hot Button Clicker - Architecture Overview

This document provides a high-level overview of the technical architecture of the Hot Button Clicker application. It is intended for developers who want to understand how the application works internally.

---

## Core Components

The application is built around three main systems that work together to provide its functionality:

1. **Hot Button Detection System**
2. **Idle Monitoring System**
3. **Cursor and Window Management System**

Below is a detailed explanation of each component.

---

### 1. Hot Button Detection System

The core of the application is its ability to find and click predefined images on the screen. This system is responsible for the "hot button" functionality.

- **Technology:** This system is primarily powered by AutoHotkey's `ImageSearch` command.
- **Process Flow:**
1. **Image Definition:** The user captures a region of the screen using the "Add Hot Button" feature. This captured region is saved as a PNG image in the `hot_buttons/` directory.
2. **Screen Scanning:** When monitoring is active, the `ScanForHotButtons` function iterates through each image file in the `HotButtons` array.
3. **ImageSearch Execution:** For each image, `ImageSearch` scans the entire screen to find a matching region.
4. **Shade Variation:** The `*n` (shade variation) option is used with `ImageSearch`. The `n` is a value from 0 to 255, controlled by the "Shade Variation" setting in the GUI. This allows for inexact matches, which is useful if the button's color or lighting changes slightly. A value of `*0` would require a pixel-perfect match.
5. **Clicking:** If a match is found, the coordinates of the top-left corner of the image are returned. The application then calculates the center of the image (`FoundX + button.w/2`, `FoundY + button.h/2`) and programmatically clicks at that location.

---

### 2. Idle Monitoring System

To prevent the application from interfering with the user's work, it includes a system to detect user inactivity.

- **Technology:** This system relies on AutoHotkey's built-in variable `A_TimeIdlePhysical`.
- **Process Flow:**
1. **Idle Check:** At the beginning of each `ScanForHotButtons` cycle, the application checks the value of `A_TimeIdlePhysical`. This variable returns the number of milliseconds that have passed since the last physical keyboard or mouse input.
2. **Pausing:** If the idle time is less than a set threshold (currently 30,000 ms), the application assumes the user is active. It then temporarily disables the main scanning timer (`SetTimer(ScanForHotButtons, "Off")`).
3. **Resuming:** After pausing, a one-time, delayed timer is set using `SetTimer(EnableMonitoring, -10000)`. This timer calls the `EnableMonitoring` function after 10 seconds.
4. **Re-activation:** The `EnableMonitoring` function checks if monitoring is still supposed to be active and, if so, re-enables the main `ScanForHotButtons` timer. This creates a loop where the application "sleeps" and wakes up to check for inactivity, ensuring it only runs when the user is away.

---

### 3. Cursor and Window Management System

To ensure that the automated clicks do not disrupt the user's current context, the application saves and restores the state of the mouse cursor and the active window.

- **Technology:** This system uses AutoHotkey's `MouseGetPos`, `WinGetID`, `MouseMove`, and `WinActivate` commands.
- **Process Flow:**
1. **State Saving:** Immediately before a click is performed on a found hot button, the application calls:
- `MouseGetPos(&origX, &origY)` to store the current X and Y coordinates of the mouse cursor.
- `WinGetID("A")` to get the unique ID of the currently active window.
2. **Action Execution:** The application then moves the mouse to the center of the hot button and performs the click.
3. **State Restoration:** Immediately after the click, the application:
- Calls `MouseMove(origX, origY)` to return the cursor to its original position.
- Calls `WinActivate("ahk_id " activeWin)` to re-activate the window that was active before the click.

This ensures that the user's workflow is not interrupted, as the cursor and active window are restored to their original state almost instantly.
121 changes: 121 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that are welcoming, inclusive, and
respectful.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interaction in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].

[homepage]: https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
84 changes: 84 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributing to Hot Button Clicker

First off, thank you for considering contributing to Hot Button Clicker! Your help is greatly appreciated. This document provides a set of guidelines for contributing to the project.

---

## Code of Conduct

This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior.

---

## How Can I Contribute?

There are many ways to contribute, from writing code and documentation to reporting bugs and suggesting new features.

### Reporting Bugs

If you find a bug, please ensure it hasn't already been reported by searching the open issues. If you can't find an existing issue, please open a new one.

When filing a bug report, please include:

- A clear and descriptive title.
- A detailed description of the problem, including steps to reproduce it.
- The version of AutoHotkey you are using.
- Any error messages you encountered.

### Suggesting Enhancements

If you have an idea for a new feature or an improvement to an existing one, please open an issue to discuss it. This allows us to coordinate our efforts and ensure the feature aligns with the project's goals.

---

## Development Setup

To get started with development, you'll need to have AutoHotkey v2 installed on your system.

1. **Install AutoHotkey v2:**
- Download and install the latest version from the [official AutoHotkey website](https://www.autohotkey.com/v2/).

2. **Fork the Repository:**
- Click the "Fork" button at the top right of this page to create your own copy of the repository.

3. **Clone Your Fork:**
- Clone your forked repository to your local machine:
```sh
git clone https://github.com/your-username/hot-button-click.git
cd hot-button-click
```

4. **Run the Application:**
- You can run the application directly by executing `simple_ui.ahk` with AutoHotkey, or by using the provided `start.bat` script.

---

## Pull Request Process

1. **Create a New Branch:**
- Create a new branch for your changes:
```sh
git checkout -b feature/your-feature-name
```

2. **Make Your Changes:**
- Make your changes to the codebase. Ensure that your code follows the existing style and conventions.
- Add comments to any new functions or complex logic.

3. **Commit Your Changes:**
- Commit your changes with a clear and descriptive commit message:
```sh
git commit -m "Add: A brief description of your feature"
```

4. **Push to Your Fork:**
- Push your changes to your forked repository:
```sh
git push origin feature/your-feature-name
```

5. **Submit a Pull Request:**
- Open a pull request from your forked repository to the main project repository.
- Provide a detailed description of the changes you've made and reference any related issues.

Thank you for your contribution!
Loading