Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#!/usr/bin/env python import sys, pygame, pygame.midi import os #for calling xte to 'sendkeys' My not be the best way, but works...on Linux...if you have xautomation installed # set up pygame pygame.init() pygame.midi.init() # list all midi devices for x in range( 0, pygame.midi.get_count() ): print pygame.midi.get_device_info(x) # open a specific midi device i = pygame.midi.Input(3) #change this to your device # run the event loop while True: if i.poll(): midi_events = i.read(10) if (midi_events[0][0][2] != 0): key = str(midi_events[0][0][1]) print "Key is " + key if (key == "43"): os.system("xte 'str test this out'") elif (key == "44"): os.system("xte 'str Hello World'") elif (key == "45"): os.system("xte 'str Hello Bob'") elif (key == "46"): os.system("xte 'str Good-bye bob'") elif (key == "47"): os.system("xte 'str World part 2'") elif (key == "48"): os.system("xte 'str Last one'") # wait 10ms - this is arbitrary, but wait(0) still resulted # in 100% cpu utilization pygame.time.wait(10)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)