Offline
Newbie
Karma: 0
Posts: 6
|
 |
« on: January 25, 2013, 09:54:32 pm » |
I've written a simple script where I press a button, which in turn Serial.prints a keystroke. My next step is to use that to activate a keyboard shortcut...a combination of two keys pressed simultaneously.
So I'm wondering two things:
1. Is it possible to Serial.print something that's not a character, like Ctrl, Shift, or Command?
2. If so, can you Serial.print two keys at the same time, perhaps with a delay(1000) after Serial.printing the first key?
Or would you guys suggest a better way to go about this?
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 33
Posts: 3619
@ssh0le
|
 |
« Reply #1 on: January 25, 2013, 10:02:06 pm » |
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
Land of Oz
Offline
Newbie
Karma: 2
Posts: 42
I dream in Assembler
|
 |
« Reply #2 on: January 25, 2013, 10:04:13 pm » |
We did this in the "days of DOS". Take the interpreted key code character. There is a DOS service call that returns the scan code for non-printable keys... if thats any help to get you started.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 15
Posts: 1003
Arduino rocks
|
 |
« Reply #3 on: January 26, 2013, 02:30:05 am » |
What you're looking for is to turn your arduino into a USB keyboard. You can do it with an uno, but it's much easier with an arduino leonardo (google it in either case)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #4 on: January 26, 2013, 10:51:29 am » |
Hm, well then a follow-up: how would I get it to "press" a special key, like F6? On a friend's advice, I tried Serial.print("key_f6"); , but looking at the serial monitor, I think it's just printing key_f6 as a string.
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #5 on: January 26, 2013, 10:56:39 am » |
What WizenedEE said (did you see his message?)
With Uno you would need v-usb or equivalent. Leonardo or Teensy --> very easy.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #6 on: January 26, 2013, 05:51:14 pm » |
With Uno you would need v-usb or equivalent. Looks like I'm s.o.l. with my UNO then. As far as I can tell, I'd need to download a DFU Programmer first. I can't do that without installing MacPorts, and I can't install MacPorts without Xcode, and I can't install Xcode 4 (the only one Mac makes available now) on Mac 10.6. Grr. Any other thoughts? All I want to do is have Arduino send a signal to launch a script that plays a particular song (in iTunes, Quicktime, whatever application I can). I was thinking I could do it with a button: press the button, which signals a keyboard shortcut, which launches a script to play the song. So it looks like that approach is out, at least with my UNO/O.S. combination. Is there a whole different angle I could take?
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #7 on: January 26, 2013, 05:57:37 pm » |
I'm not so sure that you're SOL, but I'm getting out of my zone here-- I have used Teensy for things like that, it's dirt simple and it has usb dongle-like format...
|
|
|
|
|
Logged
|
|
|
|
|
Land of Oz
Offline
Newbie
Karma: 2
Posts: 42
I dream in Assembler
|
 |
« Reply #8 on: January 26, 2013, 06:54:27 pm » |
With Uno you would need v-usb or equivalent. Any other thoughts? All I want to do is have Arduino send a signal to launch a script that plays a particular song (in iTunes, Quicktime, whatever application I can). I was thinking I could do it with a button: press the button, which signals a keyboard shortcut, which launches a script to play the song. So it looks like that approach is out, at least with my UNO/O.S. combination. Is there a whole different angle I could take? Are you simply doing this as an intellectual exercise or just because you're bored ? Seems like an awful lot of work just to play a music download. I would just buy an old laptop and get a illegal COUGH ! real copy of Windoze or whatever and use that.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 30
Posts: 2901
I only know some basic electricity....
|
 |
« Reply #9 on: January 26, 2013, 07:08:12 pm » |
F6 is ASCII 246 decimal, 11110110 binary. Try writing that. http://www.ascii-code.com/
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #10 on: January 26, 2013, 07:26:36 pm » |
Are you simply doing this as an intellectual exercise or just because you're bored ? Seems like an awful lot of work just to play a music download. I would just buy an old laptop and get a illegal COUGH ! real copy of Windoze or whatever and use that. lol. Isn't everything an intellectual exercise?  I'm doing a silly project to learn about pairing a sensor and a computer, beyond the basic serial monitoring. I have a waterproof thermometer, and when it senses a pot of water has reached 100 deg. Celsius (that the water is boiling) I want it to tell the UNO to tell the computer to play an .mp3 clip of a James Brown yell.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #11 on: January 26, 2013, 07:33:08 pm » |
That's still basically a character, as opposed to the function key F6. Someone might have mentioned it up-thread or I saw it somewhere else today, but I've learned you can't print function keys, Crtl, Shift, etc. in the programming sense. At least not without turning my Arduino into a USB keyboard, per WizenedEE's reply and stuff I've read elsewhere.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 30
Posts: 2901
I only know some basic electricity....
|
 |
« Reply #12 on: January 26, 2013, 08:02:07 pm » |
So you tried and it didn't work. Because we all know that all PC programs work the same...
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #13 on: January 26, 2013, 08:07:02 pm » |
So you tried and it didn't work. Because we all know that all PC programs work the same...
Sorry?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 15
Posts: 1003
Arduino rocks
|
 |
« Reply #14 on: January 26, 2013, 11:07:14 pm » |
The serial monitor reads from the serial port and displays the character on a java TextBox. You can't generate a system-event, such as the one pressing F6 does, by displaying a character on a textbox.
|
|
|
|
|
Logged
|
|
|
|
|
|