Author Topic: Full Keyboard Replacement Commands  (Read 2142 times)

VAStruggler

  • Guest
Full Keyboard Replacement Commands
« on: August 15, 2018, 08:44:50 PM »
Greetings,

I've been trying to get a full keyboard substitute in VA which I could have any key pressed for a certain amount of time, in 1 second increments up to 60, and then released, without having to create many hundreds of individual commands.

What I'm hoping, for instance, is to say, using the phonetic alphabet, "alpha two" to have the letter "a" pressed for two seconds, and if I just wanted a key quickly clicked, I would just say the key without a number after it, such as "alpha" or "backspace". Commands would be able to overlap

Any suggestions or examples I could look at? When I've I tried figuring out through the manual or forum searches, I sometimes felt like I got halfway to a solution, but couldn't figure out remaining problems, and just couldn't understand the simple syntax to construct some of these more complex commands. If I had an example for one or two keys, I could replicate or add the rest.

Many thanks.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Full Keyboard Replacement Commands
« Reply #1 on: August 17, 2018, 02:24:04 AM »
A way to do this without having individual commands for all keypresses:

When I say :
Code: [Select]
[Shift;Control;Alt;Enter;Backspace;Space] [1..60;];[Alpha;Bravo;Charlie;Delta;Echo;Foxtrot;Golf;Hotel;India;Juliet;Kilo;Lima;Mike;November;Oscar;Papa;Quebec;Romeo;Sierra;Tango;Uniform;Victor;Whiskey;Xray;Yankee;Zulu;One;Two;Three;Four;Five;Six;Seven;Eight;Nine;Zero] [1..60;]
Code: [Select]
Begin Text Compare : [{CMD}] Starts With 'Shift'
    Set Text [~key] to '[SHIFT]'
Else If Text Compare : [{CMD}] Starts With 'Control'
    Set Text [~key] to '[CTRL]'
Else If Text Compare : [{CMD}] Starts With 'Alt'
    Set Text [~key] to '[ALT]'
Else If Text Compare : [{CMD}] Starts With 'Enter'
    Set Text [~key] to '[ENTER]'
Else If Text Compare : [{CMD}] Starts With 'Backspace'
    Set Text [~key] to '[BACKSPACE]'
Else If Text Compare : [{CMD}] Starts With 'Space'
    Set Text [~key] to '[SPACE]'
Else If Text Compare : [{CMD}] Starts With 'One'
    Set Text [~key] to '1'
Else If Text Compare : [{CMD}] Starts With 'Two'
    Set Text [~key] to '2'
Else If Text Compare : [{CMD}] Starts With 'Three'
    Set Text [~key] to '3'
Else If Text Compare : [{CMD}] Starts With 'Four'
    Set Text [~key] to '4'
Else If Text Compare : [{CMD}] Starts With 'Five'
    Set Text [~key] to '5'
Else If Text Compare : [{CMD}] Starts With 'Six'
    Set Text [~key] to '6'
Else If Text Compare : [{CMD}] Starts With 'Seven'
    Set Text [~key] to '7'
Else If Text Compare : [{CMD}] Starts With 'Eight'
    Set Text [~key] to '8'
Else If Text Compare : [{CMD}] Starts With 'Nine'
    Set Text [~key] to '9'
Else If Text Compare : [{CMD}] Starts With 'Zero'
    Set Text [~key] to '0'
Else
    Set Text [~key] to '{TXTSUBSTR:"{CMD}":0:1}'
End Condition
Begin Text Compare : [{STATE_KEYSTATE:{TXTREPLACEVAR:"{TXTREPLACEVAR:~key:"[":""}":"]":""}}] Equals '1'
    Write [Blue] '{CMDSEGMENT:0} is already pressed' to log
End Condition - Exit when condition met
Press down variable key(s) [~key]
Begin Text Compare : [{TXTNUM:"{CMD}"}] Does Not Equal ''
    Set decimal [~holdTime] value to the converted value of {TXTNUM:"{CMD}"}
    Write [Blue] 'Holding {CMDSEGMENT:0} for {TXTNUM:"{CMD}"} seconds' to log
    Pause a variable number of seconds [~holdTime]
    Write [Blue] 'Releasing {CMDSEGMENT:0}' to log
Else
    Pause 0,01 seconds
End Condition
Release variable key(s) [~key]

Make sure you check the "Allow other commands to execute while this one is running" option.


Commands would be able to overlap
I'm not sure what you mean by this, but you can press or hold every key in the command as long as they're not held down already.

VAStruggler

  • Guest
Re: Full Keyboard Replacement Commands
« Reply #2 on: August 27, 2018, 02:27:11 PM »
Holy heck, Pfeil, thank you so much for writing this out. I'm sorry I didn't respond when you posted your reply, I thought I was signed up for email alerts, but it looks like I wasn't.

Thank you for putting this out there, I would not have been able to come up with it on my own.