nimaid / lphk Goto Github PK
View Code? Open in Web Editor NEWA Novation Launchpad Macro Scripting System.
License: GNU General Public License v3.0
A Novation Launchpad Macro Scripting System.
License: GNU General Public License v3.0
I tried to set up a button to lock my computer using the key combination Windows + L.
The Code I used looks like this:
PRESS windows
TAP l
RELEASE windows
However it didn't do anything, but when I used a combination like Win + E (for opening a file explorer) it worked just fine...
Today i made a layout to play fortnite with my launchpad mini and i had two problems:
I assigned "TAP d" to a key and when i ran it... it muted the sound of the computer;
I assigned "TAP g" to another key and it started playing music in spotify.
I once tested this and i had no problems.
My OS: Windows 10
If I use SOUND, the sound file's pitch is lowered when it is played. And plus how can i toggle keys by commands? I want to toggle Q key(i'll use autohotkey as ctrl+F23 as there isn't q in LPHK) for voice chat in games, but I don't know how. By the way is toggling keys is supported?
+) plz make toggling lights
I cloned this on my mac. Python 3.6 in a virtual environment. Installed the dependencies, and then ran the script as in the instructions and get this error trace.
Traceback (most recent call last):
File "LPHK.py", line 56, in
main()
File "LPHK.py", line 52, in main
window.init(lp)
File "/Users/jandrews/Projects/innovation-cmd/LPHK/window.py", line 26, in init
make()
File "/Users/jandrews/Projects/innovation-cmd/LPHK/window.py", line 335, in make
app = Main_Window(root)
File "/Users/jandrews/Projects/innovation-cmd/LPHK/window.py", line 33, in init
self.info_image = tk.PhotoImage(file="resources/info.png").subsample(2, 2)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py", line 3539, in init
Image.init(self, 'photo', name, cnf, master, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py", line 3495, in init
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "resources/info.png"
If you edit the file and add @LOAD_LAYOUT fake.lpl
(make sure the file does not exist) the program will hold all command executions even after you have selected new layout and loaded your old layout
I'm having issues to get the mouse coordinates of where I want it to click.
This issue could be solved by adding a command to LPHK Script, that displays the current mouse coordinates somewhere.
As an example:
M_COORD
would show the current coordinates of the mouse in a pop-up window
If you could add this command, it would really help me programming my macro keys.
I have my novation launchpad MK2 plugged into my galliumos linux laptop, and for some reason, it can't be detected. here is the log:
chrx@chrx:~/Desktop/LPHK-master$ python3 LPHK.py
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib conf.c:3523:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so
ALSA lib seq.c:935:(snd_seq_open_noupdate) Unknown SEQ default
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib conf.c:3523:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so
ALSA lib seq.c:935:(snd_seq_open_noupdate) Unknown SEQ default
Traceback (most recent call last):
File "LPHK.py", line 58, in
main()
File "LPHK.py", line 56, in main
shutdown()
File "LPHK.py", line 49, in shutdown
os.execv(sys.executable, [""" + sys.executable + """] + sys.argv)
FileNotFoundError: [Errno 2] No such file or directory
Here is what it looks like when I type lsusb
chrx@chrx:~/Desktop/LPHK-master$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2a Intel Corp.
Bus 001 Device 002: ID 04f2:b567 Chicony Electronics Co., Ltd
Bus 001 Device 015: ID 1235:0069 Focusrite-Novation
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Any help is appreciated. Thank you.
If you hold down a button with a simple script (no delay , @ASYNC
or wait_unpressed etc) it will keep flashing until you release the button.
Script used in video
- TODO: for when AE supports tracking from hotkeys
- PRESS alt_gr
- TAP f20
- RELEASE alt_gr
Hello everyone,
The idea is to have a main script that at a fixed point (startup) wuold read all files in a sub-folder (/commands) and if the file has the right format (normal .py script + a specific header) it would import it as an available command/function in the LPHK language.
The script will check for the libs that it needs to run that specific script and install it via pip.
In the header, there will be a way to rename functions.
When using an importend function you need to use the name of the file "x" and the name of the function "y".
In the LPHK script, you will need to write x.y as a command.
When importing a file, the script will create a dictionary and associate a specific command with a custom name.
Something like function['WEB_NEW']=Web.open_ new.
Thanks to this, you'll be able to use the custon name and make the LPHK script look "nicer".
Script:
PRESS win
PRESS shift
TAP right
RELEASE shift
RELEASE win
Expected behavior from JS Key tracker (https://unixpapa.com/js/testkey.html):
keydown keyCode=91 ([) which=91 ([) charCode=0
keydown keyCode=16 which=16 charCode=0
keyup keyCode=39 (') which=39 (') charCode=0
keyup keyCode=16 which=16 charCode=0
keyup keyCode=91 ([) which=91 ([) charCode=0
91 is win, 16 is shift and 39 is right arrow
Actual behavior:
keydown keyCode=91 ([) which=91 ([) charCode=0
keydown keyCode=16 which=16 charCode=0
keyup keyCode=16 which=16 charCode=0
keyup keyCode=39 (') which=39 (') charCode=0
keydown keyCode=16 which=16 charCode=0
keyup keyCode=16 which=16 charCode=0
keyup keyCode=91 ([) which=91 ([) charCode=0
Notice the 2 extra lines at line 3 and 5. I've tried variants of PRESS
, TAP
, ASYNC
to no avail.
Edit: I'm using the Launchpad Pro (but other shortcuts seem to work fine, for example this script works fine:
PRESS ctrl
PRESS shift
TAP n
RELEASE shift
RELEASE ctrl
DELAY 0.5
PRESS ctrl
TAP k
TAP o
RELEASE ctrl
Currently investigating this issue, will update this issue when I have more info
pyautogui
could possibly fix this issue ( #11 (comment) )
@nimaid
OS: Ubuntu 18.04, fresh install. (Remember this)
PC: Thinkpad T430, i5 3320m, 16GB RAM, Samsung 256GB SSD
LP: LP MKII
Issue: I run the installer, it installs Conda fine. But when it tries to install LPHK, it doesn't create directories in ~/.conda and bitches to me that I don't have write permissions. I run as root, same issue. I run chown lyiriyah .conda
. Still bitches. So I create the directories, change the ownership to me and run it again. It completes successfully. I run RUN.bash and it loads and doesn't detect my Launchpad. Happy fun. I am installing Conda myself as I write this, maybe that will change something.
Hey !
When i use the "STRING" argument, i can't use accents like:
"STRING รฉ". The "รฉ" simply not appear :/
(sorry for my english, i'm french)
Thanks,
Mathitux
Hi,
I have an idea :
Make a function to change layout when you click on a button.
They can be good to have multiple board and easy to change layout.
(sorry for my english, i'm french)
great project
The is a typo in the shutting down function.
Wanted to commit a branch for it but that doesn't seem possible so here's the typo
Line 50 :
sys.exit("[LPHK] Sutting down...") -> sys.exit("[LPHK] Shutting down...")
OS: Ubuntu 18.04
Launchpad: MK2
Python versions (python --version)
System: Python 2.7.15+
Conda: Python 3.7.5
When pressing connect to launchpad the following error occurs, when switching usb ports and pressing redetect the program crashes
Program output (full output):
duncte123@duncte123 ~> bash
duncte123@duncte123:~$ conda activate LPHK
(LPHK) duncte123@duncte123:~$ python --version
Python 3.7.5
(LPHK) duncte123@duncte123:~/Desktop/LPHK$ git pull
remote: Enumerating objects: 58, done.
remote: Counting objects: 100% (58/58), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 53 (delta 37), reused 35 (delta 19), pack-reused 0
Unpacking objects: 100% (53/53), done.
From github.com:nimaid/LPHK
d52345a..cc4d1ca master -> origin/master
Updating d52345a..cc4d1ca
Fast-forward
README.md | 304 +++++++++++++++++++++------------------
install_beta/install_windows.bat | 57 ++++----
window.py | 15 +-
3 files changed, 210 insertions(+), 166 deletions(-)
(LPHK) duncte123@duncte123:~/Desktop/LPHK$ python LPHK.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib conf.c:3558:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so (/usr/lib/alsa-lib/libasound_module_conf_pulse.so: libasound_module_conf_pulse.so: cannot open shared object file: No such file or directory)
ALSA lib seq.c:935:(snd_seq_open_noupdate) Unknown SEQ default
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fa47d9ed740 (most recent call first):
Aborted (core dumped)
(LPHK) duncte123@duncte123:~/Desktop/LPHK$
LSUSB output:
duncte123@duncte123 ~> lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 002: ID 0bda:58d2 Realtek Semiconductor Corp.
Bus 001 Device 004: ID 1235:0069 Focusrite-Novation
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
duncte123@duncte123 ~>
Hi it would be nice if you could make it so that the sound could be played out of multiple outputs. so for example one through my headphones and one thorugh my mic (so that it would be an actual soundboard)
ty
I am putting a mp3 sound into the examples file and using this code:
SOUND examples\meme.mp3
Keep getting a error message saying that it can not be found.
I have the default wav files in there and they work fine with the:
SOUND examples\airhorn.wav
And it is in the exact same file location.
I've been using the application for a month now. And everytime I boot up, I need to launch the app, press the Live Mode pop-up for Launchpad Pro and then proceed to load my layout. I was thinking maybe there is a way to automate this, or even just load the last opened layout on the next boot.
Add the function to have a button to switch to another profile, or have the ability to open the profile with open file ability and load it up that way. I would love to have my right circular keys as buttons for 8 different profiles.
Hello
Is there a way to loop something while I press it? I want a volume up button that keeps going up untill I release the button.
Thanks in advance
Hi!
Firtst of all, thank you ever so much for this project! I really appreciate this ๐
Is there a function which allows for the command to repeat while the button is pressed?
For instance with vol_down.
While button is pushed down, repeat @simple vol_down until button is released.
Makes sense?
See attached log
LPHK.log
While testing the program out on windows I noticed that the key commands like TAP, PRESS and @SIMPLE
are only executed for the window that is currently focussed, this breaks using LPHK for stuff like controlling obs while you are streaming
Any way to make it so i can key in to load certain layouts on button press so i can switch between layouts faster?
So currently I'm trying to bind vrchat gestures to my launchpad, these keybinds are:
shift+f1 through 8 for left hand
right shift+f1 through 8 for right hand
left hand works like a dream with the code:
PRESS shift
PRESS f1
WAIT_UNPRESSED
RELEASE shift
RELEASE f1
right hand however cannot be bound since when i replace shift with shift_r it comes up with an error message saying the key does not exist.
regardless of a .wav file I used or one of the examples it stills shows that the file cannot be found.
It opens a command line for a split second, and then closes, with no output
I tried python LPHK.py, and got:
python LPHK.py
File "", line 1
python LPHK.py
^
SyntaxError: invalid syntax
With python3 LPHK.py:
python3 LPHK.py
File "", line 1
python3 LPHK.py
^
SyntaxError: invalid syntax
For some reason it won't allow spaces at the starts of lines, thanks GitHub
@nimaid, Now that I've got the hang of how to use this, would you be open to a PR with some more user friendly instructions when I have the time?
Hi,
The script recognize my genuine novation launchpad as a launchpad pro, therefore I'm unable to connect the launchpad to this script. Any ideas?
Okay, I get this isn't about your software but it still baffles me. When I open pip.exe, it opens, and closes immediately.
Is there any option to autostart LPHK on PC boot load a config/layout and run it in the Background
Is there anything planed for the future?
Does this work with the Launchpad Mini mk3?
Can you allow parameters for OPEN? I like to start serialsend.exe and give lots of info to the program. At the moment I get error, file not found.
The volume controls are not working on Mac.
System Version: macOS 10.15.5
Script: TAP vol_up
Log:
---------------- BEGIN LOG 15/07/2020 14:23:12 ----------------
LPHK - LaunchPad HotKey - A Novation Launchpad Macro Scripting System
Version: 0.3.0
Platform: Macintosh
Is compiled executable: False
Is portable: True
Operating path: /Users//downloads/LPHK-0.3.0
User path: /Users//downloads/LPHK-0.3.0
Program file path: /Users//downloads/LPHK-0.3.0
Program file: /Users//downloads/LPHK-0.3.0/LPHK.py
Log file (this file): /Users//downloads/LPHK-0.3.0/LPHK.log
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[scripts] (0, 7) No script running, starting script in background...
[scripts] (0, 7) Now running script...
[scripts] (0, 7) Tap key vol_up
[scripts] (0, 7) Script done running.
Ive tried to do this myself but im still a newbie to this sort of programming. Just thought id let you know I coulnt get this to work.
Hi!
I assigned simple buttons to the launchpad.
I want to use it with the game Elite: Dangerous.
If I press the assigned keyboard shortcuts on the Launchpad in a note, then I get the result directly. This means that the inputs via the launchpad actually work like a keyboard.
However, this does not work in the game.
The game does not accept any buttons from the launchpad.
Am I missing something here?
I absolutely love the concept of LPHK, but I only own a Launchpad Mini. Is it possible you can work towards a solution for Launchpad Mini? And if so, could I request a rough estimate on when I could use LPHK with Mini?
Thanks in advance.
Edit: I apologise, I had not read the readme thoroughly.
Hooked up my LP Mini and tried to connect but connection failed after many redetects.
i have only 15 colors to choose from and dont know how to get the color spectrum?
can someone help?
I use a MidiFighter3D, but this is undetected with it.
I'm unable to use , /, or ' as valid targets for a TAP or PRESS command. I believe this is because these characters are considered "special" and require escaping in order to use them as plain characters.
Upon checking in pynput using a short script you can see what pynput sees when you type a backslash:
from pynput import keyboard
def on_press(key):
... try:
... print('alphanumeric key {0} pressed'.format(
... key.char))
... except AttributeError:
... print('special key {0} pressed'.format(
... key))
...
def on_release(key):
... print('{0} released'.format(
... key))
... if key == keyboard.Key.esc:
... # Stop listener
... return False
...Collect events until released
... with keyboard.Listener(
... on_press=on_press,
... on_release=on_release) as listener:
... listener.join()
...
Key.enter released
alphanumeric key \ pressed
'\' released
alphanumeric key \ pressed
'\' released
Note the escaped version of the backslash: '\'.
The basic steps to the error where:
The following error occurs when i press the left, light up and down keys:
[scripts] (2, 0) Starting asynchronous script in background...
[scripts] (2, 0) Now running script...
[scripts] (2, 0) Simple keybind: prev_track
Exception in thread Thread-67637:
Traceback (most recent call last):
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/tmp/LPHK-master/scripts.py", line 523, in run_script
idx = main_logic(idx)
File "/tmp/LPHK-master/scripts.py", line 492, in main_logic
kb.press(key)
File "/tmp/LPHK-master/kb.py", line 23, in press
keyboard.press(key)
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/__init__.py", line 396, in press
send(hotkey, True, False)
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/__init__.py", line 383, in send
_os_keyboard.press(scan_codes[0])
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 158, in press
write_event(scan_code, True)
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 144, in write_event
build_device()
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 109, in build_device
ensure_root()
File "/home/MYUSER/.conda/envs/LPHK/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 174, in ensure_root
raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.
Trying to start LPHK with sudo brings a whole other problem along (tried it as suggested by @nimaid ):
(LPHK) [MYUSER@HOSTNAME LPHK-master]$ sudo /home/MYUSER/.conda/envs/LPHK/bin/python /tmp/LPHK-master/LPHK.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
Traceback (most recent call last):
File "/tmp/LPHK-master/LPHK.py", line 58, in <module>
main()
File "/tmp/LPHK-master/LPHK.py", line 53, in main
init()
File "/tmp/LPHK-master/LPHK.py", line 33, in init
sound.init(PATH)
File "/tmp/LPHK-master/sound.py", line 16, in init
m.init()
pygame.error: No available audio device
My setup is:
Please comment if additional information is needed - I'll try to respond asap.
Hi Ella,
I wanted to try out LPHK with my Launchpad Pro, with a custom firmware installed on it (https://github.com/mat1jaczyyy/lpp-performance-cfw) and when I try to launch LPHK, it recognizes my LP as a Launchpad Classic/Mini/S and first of all, the layout is all messed up and the buttons don't do anything. I'm also encountering this error when first starting LPHK.
Exception in thread Thread-2: Traceback (most recent call last): File "D:\Programmi\Miniconda3\envs\LPHK\lib\threading.py", line 926, in _bootstrap_inner self.run() File "D:\Programmi\Miniconda3\envs\LPHK\lib\threading.py", line 1177, in run self.function(*self.args, **self.kwargs) File "D:\Git Repositories\LPHK-master\lp_events.py", line 28, in run pressed[x][y] = False IndexError: list index out of range
I don't know what to do about it.
TheLifeGamingYT
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.