1

I build a macro keyboard and one thing I do alot is add a set amount to numbers mostly in 3d modeling programs. I add and remove 0.25 and 0.125 all the time. I want to make a macro that copies selected text, adds or subtracts a value then pastes it back.

I known the simple copy and paste commands but how do I get my arduino program to grab that copied value?

Can this even be done?

4
  • What keys does it have, what is the current sketch (or related parts), how is text selected, can it handle multiple keys simultaneously? I miss the actual requirements and current code you have. – Michel Keijzers Feb 23 at 14:38
  • My keyboard has 9 keys and mutable modes I can put it in for different programs. How I want it to work is I select text on my screen its normal an z x or y I need to move by a set amount. I push one key on the arduino macro keyboard and it copies that text imports it as an int adds or subtracts the needed amount then pastes the edited value back. – Ben Crawford Feb 23 at 14:42
  • You can't. A keyboard is a one-way device. – Majenko Feb 23 at 15:02
  • "Can this even be done?" Not without help from the PC side. It's not like the clipboard stored in the keyboard. And there are no scan/codes or USB-HID messages that will cause the host to send a copy of the clipboard to the device. – timemage Feb 23 at 15:02
4

You have to write an application for your PC that

  • reads a number from the clipboard
  • adds some constant
  • puts the result back in the clipboard
  • quits

Then you have to configure you desktop environment in order to have this application launched from a keyboard shortcut.

Once you have done that, you can do the whole operation from a regular keyboard: Ctrl-C + Launcher shortcut + Ctrl-V.

If you can do it from a regular keyboard, you can do it from the Arduino emulating a regular keyboard.

Edit: The way you do the first two steps is very dependent on the OS running on your PC. On Linux, for example, the mentioned “application” can be a minimal shell script:

#!/bin/bash

x=$(xclip -o -selection clipboard)
xclip -i -selection clipboard <<< $(bc <<< "$x + 0.25")

These steps are, however, outside the scope of this site.

2
  • I guess I will see if I can make a blender plugin that does what I want and just have it bind to a key combo I can have they macro keyboard do – Ben Crawford Feb 23 at 16:49
  • 1
    Well, as long as we're just doing tech support: For what it's worth, in Blender you can click into the number, hit END and type +0.25 and ENTER or whatever other expression you want to do, * pi or / 2 etc. – timemage Feb 23 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.