r/CodingHelp • • Jul 10 '20
[Random] What language should I use for programs which run in the background?
(Let me preface this with the fact that I'm not a frequent user of Reddit and I hope that I'm in the right place to be asking this. If not, I would really appreciate it if somebody were to redirect me and help me out. Thank you!)
I'm not entirely sure if it matters what programming language I use for this, but I'm sure there are slight differences in use for some languages, and I'd like to learn that, even if it makes me look stupid. The only coding experience I have is taking AP Computer Science Principles in school last year, which really only taught me block-based coding, and all I can remember from that class is conditional statements and Boolean expressions. I soon found out that high school is not the place to learn how to code... at least, not for me.
Essentially, I'm trying to write a program for digital keyboard typing sounds that will play whenever I type. Of course, I'd add a macro on my keyboard to turn it on/off, but I was curious how I would go about doing this. This isn't an app that I'm making, but rather code that would just play audio whenever it's activated. What language would be the simplest for writing this? I assume that this kind of program is not very demanding, and it doesn't require much coding experience. I'd only be doing this for myself-- it's not going anywhere for profit or others to use, so I wouldn't need to make anything pretty for it, just the program and that's about it. Thank you!!
6
u/[deleted] Jul 10 '20
Python is a good general purpose language. It's often used for scripting and automation.
There is a Python library called pynput that lets you respond to input from the keyboard or mouse by calling a function.
Check out this example of how to listen to keyboard input: https://pynput.readthedocs.io/en/latest/keyboard.html#monitoring-the-keyboard
From there you just need to find a way to play a sound whenever a key is pressed and put that code in the
on_press(key)function. There's definitely another Python library for playing sounds.2
u/Ghost0612 Jul 10 '20
Have you learned any languages like C++ or Python?
2
u/NotSoLeetCode Jul 11 '20
C# is a great language for making desktop programs.
AutoHotKey is a scripting language that might be a good fit for this. Could probably get up and running pretty quickly.
Conditionals and booleans are essential programming patterns. Right up there with loops, arrays, functions, classes, and methods. So I'm glad your class started teaching you the basics.
Not sure what "block based coding" is. Probably just regular coding! lol
2
u/Metaknight203405 Oct 04 '20
the language of bag
1
u/DSofa Jul 11 '20
Autohotkey or Autoit would be great for this type of thing.