Author Topic: Sendkeys - Keyboard Emulation  (Read 22485 times)

0 Members and 2 Guests are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Sendkeys - Keyboard Emulation
« on: October 18, 2010, 10:31:04 PM »
Here is the comprehensive reference for sendkeys.
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx

Here's the essential info:

To send letters or words just enter them in the text field

For special keys we use { } with the name of the key in it.  Examples:

{BREAK} {CAPSLOCK} {DELETE} or {DEL} {DOWN} {END} {ESC}

NOTE: USE THE PARAMETER HELPER TOOL IF YOU NEED HELP CONSTRUCTING YOUR KEY COMBO.  http://voxcommando.com/mediawiki/index.php?title=Parameter_Helper

To modify keys with ctrl alt shift precede them with these symbols:
SHIFT+
CTRL^
ALT%

So to type control k you would write:    ^k

If you want to simulate holding down shift and then pressing a bunch of keys you can use brackets:  +(ABC)

Some programs  don't responds well to sendkeys.  In this case you need to use InputKeys.  InputKeys works but it still needs to be developed more.  It's on my list of things to do.
« Last Edit: February 16, 2015, 04:42:43 PM by nime5ter »

stepppedup

  • $upporter
  • Jr. Member
  • *****
  • Posts: 48
  • Karma: 0
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #1 on: March 29, 2011, 03:44:42 PM »
Edit:  Ignore the key mappings below for SendKeys

Use XBMC.Btn.KB <string> as it's much faster.

You can find all of those <strings> at https://github.com/xbmc/xbmc/blob/master/system/keymaps/keyboard.xml

In the section below:

<keymap>
  <global>
    <keyboard>
      <p>Play</p>


So, Play would be.... XBMC.Btn.KB p


Hi JitterJames & Kalle & Wanilton -  

I have another one for you.  I'm trying to send the Home key to XBMC.

I've tried
XBMC.Btn.KB Home  (just like XBMC.Btn.KB tab worked),
XBMC.Btn.KB home
SendKeys {HOME} - and with single/ doublequotes around Home.

Any suggestions?

Also, where can I find a definitive guide to the codes:
SendKey(0xF024) (and the rest of these kinds of codes)
action (2) - and the rest of those codes as well?

Thanks a mill...

Can you confirm SendKey(0xF024)'s source is this?

home = SendKey(61476) 0xF024

From the following chart:

space = SendKey(61472) 0xF020
singlequote = SendKey(61662) 0xF0EE
, = SendKey(61628) 0xF0BC
- = SendKey(61629) 0xF0BD
. = SendKey(61630) 0xF0BE
/ = SendKey(61631) 0xF0BF
0 = SendKey(61488) 0xF030
1 = SendKey(61489) 0xF031
2 = SendKey(61490) 0xF032
3 = SendKey(61491) 0xF033
4 = SendKey(61492) 0xF034
5 = SendKey(61493) 0xF035
6 = SendKey(61494) 0xF036
7 = SendKey(61495) 0xF037
8 = SendKey(61496) 0xF038
9 = SendKey(61497) 0xF039
; = SendKey(61626) 0xF0BA
equals = SendKey(61627) 0xF0BB
A = SendKey(61505) 0xF041
B = SendKey(61506) 0xF042
C = SendKey(61507) 0xF043
D = SendKey(61508) 0xF044
E = SendKey(61509) 0xF045
F = SendKey(61510) 0xF046
G = SendKey(61511) 0xF047
H = SendKey(61512) 0xF048
I = SendKey(61513) 0xF049
J = SendKey(61514) 0xF04A
K = SendKey(61515) 0xF04B
L = SendKey(61516) 0xF04C
M = SendKey(61517) 0xF04D
N = SendKey(61518) 0xF04E
O = SendKey(61519) 0xF04F
P = SendKey(61520) 0xF050
Q = SendKey(61521) 0xF051
R = SendKey(61522) 0xF052
S = SendKey(61523) 0xF053
T = SendKey(61524) 0xF054
U = SendKey(61525) 0xF055
V = SendKey(61526) 0xF056
W = SendKey(61527) 0xF057
X = SendKey(61528) 0xF058
Y = SendKey(61529) 0xF059
Z = SendKey(61530) 0xF05A
[ = SendKey(61659) 0xF0DB
\ = SendKey(61660) 0xF0DC
] = SendKey(61661) 0xF0DD
_ = SendKey(61629) 0xF0BD
` = SendKey(61632) 0xF0C0
backspace = SendKey(61448) 0xF008
enter = SendKey(61453) 0xF00D
tab = SendKey(61449) 0xF009
control = SendKey(61457) 0xF011
alt = SendKey(61458) 0xF012
pausebreak = SendKey(61459) 0xF013
capslock = SendKey(61460) 0xF014
esc = SendKey(61467) 0xF01B
pageup = SendKey(61473) 0xF021
pagedown = SendKey(61474) 0xF022
end = SendKey(61475) 0xF023
home = SendKey(61476) 0xF024
leftarrow = SendKey(61477) 0xF025
uparrow = SendKey(61478) 0xF026
rightarrow = SendKey(61479) 0xF027
downarrow = SendKey(61480) 0xF028
printscreen = SendKey(61484) 0xF02C
insert = SendKey(61485) 0xF02D
delete = SendKey(61486) 0xF02E
window = SendKey(61531) 0xF05B
F1 = SendKey(61552) 0xF070
F2 = SendKey(61553) 0xF071
F3 = SendKey(61554) 0xF072
F4 = SendKey(61555) 0xF073
F5 = SendKey(61556) 0xF074
F6 = SendKey(61557) 0xF075
F7 = SendKey(61558) 0xF076
F8 = SendKey(61559) 0xF077
F9 = SendKey(61560) 0xF078
F10 = SendKey(61561) 0xF079
F11 = SendKey(61562) 0xF07A
F12 = SendKey(61563) 0xF07B
numlock = SendKey(61584) 0xF090
« Last Edit: March 29, 2011, 05:02:51 PM by stepppedup »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #2 on: March 29, 2011, 04:22:48 PM »
XBMC.Btn.KB Home

is correct and works.  This command is not case sensitive so home, Home, or HOME should all work.

sendkeys {home} is also correct but XBMC behaves unpredictably with sendkeys so you shouldn't use sendkeys with xmbc if you can help it.

XBMC.send   SendKey(0xF024) works ok, but I would prefer to use XBMC.Btn.KB since it is faster and more human readable.  The reason it is used in the play artist and play album commands is just a holdover from before VC implemented the XBMC.Btn.KB commands.

you have already linked from one of your own posts to the reference for this command.

http://wiki.xbmc.org/index.php?title=Web_Server_HTTP_API

where it says: "To send a keyboard event set buttoncode to 0xF000 (hex) and add the required key’s ASCII value."

here is just one of many references for ascii codes

http://www.asciitable.com/

but again, my first choice would be

XBMC.Btn.KB Home



stepppedup

  • $upporter
  • Jr. Member
  • *****
  • Posts: 48
  • Karma: 0
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #3 on: March 29, 2011, 04:39:31 PM »
Sweet - thank you!

Going to go rip out some of those send keys I've used now.... ;)

Forsaken_BA

  • Jr. Member
  • **
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #4 on: August 26, 2013, 04:27:41 PM »
Hi people, sorry for this noob question...

When I open XBMC I need to press ctrl+T in my keyboard to disable the 3D version. I want to create a voice command, like "disable 3d", to do this.

How can I do that?

Thanks.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #5 on: August 26, 2013, 04:36:15 PM »
you can use inputkeys, but only if XBMC is on the same machine as VoxCommando, and has focus.

Here is a command for control-T

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="216" name="press ctrl-t" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>InputKeys.Send</cmdType>
    <cmdString>{CONTROL}({t})</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>press ctrl-t</phrase>
</command>

RickyD333

  • Contributor
  • ***
  • Posts: 71
  • Karma: 2
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #6 on: May 09, 2015, 02:29:50 PM »
I've been trying to do a sendkeys of "ctrl+shift+." (that's a period at the end). So it's going to look something along the lines of "^+."

I know if I was going to do something like "ctrl+ab" I would do something like, "^(ab)", but I can't seem to apply the same procedure to "^+."

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #7 on: May 09, 2015, 03:11:01 PM »
either of these work using sendkeys:  (tested and confirmed in chrome)

Code: [Select]
+^.
Code: [Select]
+^(.)
or with inputkeys
Code: [Select]
{LCONTROL+LSHIFT}({OEM_PERIOD})
Note that if you want to use this to open a voice search, you need to have chrome open to a google search page and the page must have focus.  This has nothing to do with VC.

RickyD333

  • Contributor
  • ***
  • Posts: 71
  • Karma: 2
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #8 on: May 09, 2015, 03:50:57 PM »
hmmm, I think I noticed what my problem was. So I had used this command with no luck. So I sat here re-issuing the command several times and it eventually worked. It so far works several times in a row, however there are a number of times where Vox recognizes the command with over a 90% accuracy, and it appears in the history page that it is activating it, but no google voice search is performed. I'm not sure why this would happen... and the google search page certainly has focus.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #9 on: May 09, 2015, 04:13:16 PM »
If your cursor is in the address bar or in the main search field of the Google search page the keyboard shortcut does not work. You can try this without VC.
« Last Edit: May 09, 2015, 04:20:17 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

RickyD333

  • Contributor
  • ***
  • Posts: 71
  • Karma: 2
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #10 on: May 09, 2015, 04:49:26 PM »
My cursor is no where near the address bar. For testing I open up a google search page. Then say my command, "computer, google search" Which then should proceed to performing the sendkeys action, and it appears to do so every time, but google voice search does not activate every time. Just now I tested it to make sure the address bar wasn't being selected somehow and I got a recognition confidence level of 89%, yet it didn't work. Then I tried it again and got a level of 75% and it worked  :bonk
 

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #11 on: May 09, 2015, 05:01:04 PM »
I wouldn't get too caught up in confidence levels. Users often seem to focus on that number, but it has very limited meaning.

In your Options, you set a confidence level over which your commands will be executed. As long as the value registers as being over that amount when you issue your voice command, the command should execute.

Whether the command then accomplishes what you want it to is a different issue.

If you want, you can (a) post the XML for the command you're using, and (b) record a video demonstrating the problem. Maybe that will help us to help you diagnose the root cause.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

RickyD333

  • Contributor
  • ***
  • Posts: 71
  • Karma: 2
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #12 on: May 09, 2015, 06:00:36 PM »
Okay, I'll post the xml with a video post when I get the opportunity. It will take a bit for my video to upload because at the moment I only get 2mbps internet speed (I know!). I'm getting an upgrade next week to 18mbps.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #13 on: May 09, 2015, 06:16:20 PM »
Okay, I'll post the xml with a video post when I get the opportunity. It will take a bit for my video to upload because at the moment I only get 2mbps internet speed (I know!).

That's about twice, even three times, my upload speed.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #14 on: May 09, 2015, 07:11:24 PM »
Welcome to the third world.

Some people have to compress their video a bit before they upload it...  I know!

RickyD333

  • Contributor
  • ***
  • Posts: 71
  • Karma: 2
    • View Profile
Re: Sendkeys - Keyboard Emulation
« Reply #15 on: May 20, 2015, 04:12:17 PM »
So I just wanted to update (been super sick and busy with work, so vox took a back seat). For some reason the Google search command seems to get recognized 100% of the time. I made no changes to it, so I don't know why it's working or why it wasn't in the first place. But it's working and that's what I care about! So, yay :)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Sendkeys - Keyboard Emulation
« Reply #16 on: May 20, 2015, 04:20:19 PM »
Thanks for the update.

I guess I didn't understand from your posts the other day that the issue was one of command recognition. At the time, from your description it sounded like VC was recognizing your voice command just fine, but then the command wasn't doing what you wanted it to do.

Glad to hear the command is working for you now.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)