Giter VIP home page Giter VIP logo

ahkpedal's Introduction

AhkPedal

AhkPedal is an AutoHotkey library meant to facilitate interaction with a USB foot pedal. It allows for arbitrary functions to be run upon a foot pedal button being pressed.

Setup

I can only test on foot pedals I own, so for now this only works with the Infinity IN-USB-2 foot pedal. Additionally, please note that the library will only work on 64-bit machines.

Installation

Place the AhkPedal.ahk file in your library directory. If you manage your libraries in a different way then you should already know what to do here.

Usage

Import the library with #include <AhkPedal>. This brings the AhkPedal class into scope. Use new AhkPedal() to get access to the API. Upon instantiation, an AhkPedal will automatically connect to the USB device and register itself to wait for messages from it.

After creating the AhkPedal, you may use its method SetHandler to register a new pedal handler. Its first argument is the (zero-based) index of the pedal button to assign to, going from left to right (so the left pedal would be 0, the center, 1, and the right, 2). SetHandler additionally takes either or both of the optional arguments onPress and onRelease; these should be a name of a function to call on the respective event.

When instantiating a new AhkPedal, you may use the optional parameter allowRelease to define whether button release events are handled in addition to the normal button press events. By default, it is true. If you encounter issues like the foot pedal becoming unresponsive if you release it too quickly after a press, try setting it to false.

Example

#include <AhkPedal>

pedal := new AhkPedal()

; Send the Enter key when  the center pedal button is pressed.
pedal.SetHandler(1, onPress:="CenterButtonPressed")

CenterButtonPressed() {
    send {Enter}
}

Acknowledgements

I would not have been able to come up with the Windows API-related parts of the code without musings from the underground's code. Furthermore, AutoHotkey forum user just me provided relevant 64-bit compatible code.

ahkpedal's People

Contributors

zacharied avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.