Poll

How do I set up variable input of numbers?

What ist option 1?
0 (0%)
What is option 2?
0 (0%)

Total Members Voted: 0

Author Topic: Variable to keypress  (Read 2439 times)

Omawarikun

  • Newbie
  • *
  • Posts: 2
Variable to keypress
« on: November 21, 2020, 12:29:22 AM »
Been searching for 2 days now. Maybe just the wrong places, so sorry for bothering...
My game control options have keys for fixed cockpit views (yes its FS2020) as follows:
keypress = CTRL-1 for first instrument view
and this continues until
keypress = CTRL-9 lastly
So "if I say": "Instrument 5", I want CTRL-5 to be pressed. (Short way, not by typing 10 commands)
This is what I setup:

Set text [CmdText] to '{CMD}'
Set integer [CmdVal] value to the converted value of {TXTNUM:CmdTxt}
Write [Orange] 'value is {INT:CmdVal}' to log        #yes, gives the correct number!
Press down Left Ctrl key
Press variable key(s) [INT:CmdVal] and hold for 0,05 seconds and release
Release Left Ctrl key

Give me a hint please, for how to press the named key together with Ctrl....
Thank you!
Omawarikun

Chaos Introvert

  • Newbie
  • *
  • Posts: 7
Re: Variable to keypress
« Reply #1 on: November 21, 2020, 01:04:15 AM »
This should work:

Set up a command with "When I say" as: instrument [1..10]

Enter this sequence of steps (event log output is optional of course):

Code: [Select]
Set text [KeyPress] to '[CTRL]{TXTWORDTONUM:"{CMDSEGMENT:1}"}'
Write [Blue] 'KeyPress = {TXT:KeyPress}' to log
Press variable key(s) [KeyPress] and hold for 0.5 seconds and release

You can encode multiple keypresses into one variable. Do a search in the manual for "Variable Keypress (Advanced)" for more info on that.

EDIT: What got you was the lack of {TXTWORDTONUM} - VA recognizes numbers under ten as words ("one", "two", etc.) instead of digits.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Variable to keypress
« Reply #2 on: November 21, 2020, 03:03:48 AM »
Normally the speech recognition engine will use the format from the predefined phrase, E.G. "instrument [1..10]" should output digits ("instrument 1", and so on), rather than words ("instrument one", etc..).

When using dictation (including wildcards in command names), single-digit numbers will be output as words, and numbers with more digits will be output as a set of digits. This is the behavior built into the Microsoft speech recognition engine, and what the "{TXTWORDTONUM:}" token is designed to work around.

Omawarikun

  • Newbie
  • *
  • Posts: 2
Re: Variable to keypress
« Reply #3 on: November 21, 2020, 04:10:07 AM »
Thanks to both of you. Its working now very nicely.
I looked it up in the manual pdf. To be honest I don't
really understand it. Wish there was a "for Dummies"
guide but maybe its my lousy English.
Have a nice weekend!
Omawarikun