Author Topic: Save Keystrokes and pauses to a VARIABLE  (Read 12187 times)

Castleberg

  • Newbie
  • *
  • Posts: 37
Save Keystrokes and pauses to a VARIABLE
« on: September 27, 2016, 09:04:31 PM »
I recently discovered Quick Input, and it has really improved my profile (allowed me to cut considerable delay out of my commands).  Perhaps this should be under the "feature request" section, but I figured I would try here first, in case I'm just missing something...

So, my question is: Is there any way to accomplish saving a string of key commands (with pauses) to a variable, or am I stuck creating a command for each, and executing said command for each Macro? 

To give a little more background...

I have eliminated all my Keybinding Commands in favor of a single command that assigns keybindings to txt variables, that when needed, I activate using quick input with a token.

Example:

In my Keybinding Command:
Code: [Select]
---Panel Navigation
Set Text [UI_Panel_Up] to 'w' (save value to profile)
Set Text [UI_Panel_Down] to 's' (save value to profile)
Set Text [UI_Panel_Left] to 'a' (save value to profile)
Set Text [UI_Panel_Right] to 'd' (save value to profile)
Set Text [UI_Select] to ' ' (save value to profile)
Set Text [UI_Back] to '[BACKSPACE]' (save value to profile)
Set Text [UI_Tab_Next] to 'e' (save value to profile)
Set Text [UI_Tab_Prev] to 'q' (save value to profile)



Then, when in my executing command, as an example, I might do this:
((I left the old code in for comparison of my thought process--I apologize for the clutter but I thought it would help get the point acrossed.  Instead of Calling another command, which then executes keystrokes, I use the quick input to directly execute said keystrokes.  Several loop tests, and real world stopwatch tests, showed this to be over twice as fast...))

Code: [Select]
Quick Input, '{TXT:UI_Panel_Left}'
          DISABLED - Execute command, '((Left Panel))' (and wait until it completes)
Pause 0.5 seconds
Quick Input, '{TXT:UI_Tab_Next}'
          DISABLED - Execute command, '((UI Next))' (and wait until it completes)
Pause 0.3 seconds
Quick Input, '{TXT:UI_Tab_Next}'
          DISABLED - Execute command, '((UI Next))' (and wait until it completes)
Pause 0.3 seconds
Quick Input, '{TXT:UI_Select}'
          DISABLED - Execute command, '((UI Accept))' (and wait until it completes)
Pause 0.03 seconds
Quick Input, '{TXT:UI_Panel_Down}'
          DISABLED - Execute command, '((UI Down))' (and wait until it completes)
Pause 0.03 seconds
Quick Input, '{TXT:UI_Select}'
          DISABLED - Execute command, '((UI Accept))' (and wait until it completes)
Pause 0.03 seconds


Now I come to the natural conclusion of my logic.  What if instead of having a command that functions as a macro, stringing together my individual TXT variables into a series of actions, I simply created a variable that, itself, was this string of actions and activated THAT with a quick action. 

However, despite my multiple attempts I can not get this to work (which will lead me to the "Feature request" Portion.
1) Directly Writing the variable just as I do the keybinding txt : No good, it needs to update when the keybinding command is updated, it cant be hard coded key commands. I did not think you could assign a variable using Tokens, That is a nice discovery! and would have saved me a lot of work (Note: Developer should really add a little heads up in the menu like in the Quick Input. I just assumed since it wasn't there you couldn't do it...)  But, I run into the same problem as in #3-->No pauses
2)TXTCONCAT : No good, seems to be limited to 2 variables
3)EXP : Promising.
    a) I can't write anything directly to a variable. i.e....

Code: [Select]
{EXP: set var1 to '{TXT:UI_Panel_Left}'+'{TXT:UI_Tab_Next}'+'{TXT:UI_Tab_Next}'...}
I know that is made up, and doesn't exist, but you get my point. 1) I can't use a token in a token, or even (from what I can tell), in a set variable dialogue (i.e As per above, I discovered this IS possible.

Code: [Select]
set txtvar1 to  '{TXT:UI_Panel_Left}'+'{TXT:UI_Tab_Next}'+'{TXT:UI_Tab_Next}'...
What I did do, is use the write to FILE command, and pass this to a variable, like so:

Code: [Select]
Write, '{EXP:'{TXT:UI_Panel_Up}'+'{TXT:UI_Panel_Up}'+'{TXT:UI_Panel_Up}'}' to file

Set Text [Up] to [C:\Program Files (x86)\VoiceAttack\Profiles\testingOutput]

Quick Input, '{TXT:Up}'


Great!  It works!  Although, now I would have to dedicate a folder full of files somewhere near my profile to be a macro repository of sorts...but it would be doable.  Except...

There are NO PAUSES.  When testing it be writing to the log all is well...but when using it in game, well, you can imagine...

So, Back to my original problem/question.  How can I write keystrokes, or more importantly PAUSES, to a variable.  Ideally I would not have to save a string of keystrokes to an outside file, and then pass that file's text to another variable   As per above this shouldn't be necessary anymore...(it would be grand if I could just say
Code: [Select]
set TxtVar1 to '{TXT:var2}'+'{TXT:var3}'+'{TXT:Var4}'...[/s]

But I would settle for the ability to write a pause....i.e.

Instead of This
Code: [Select]
'{TXT:UI_Panel_Up}'+'{TXT:UI_Panel_Up}'+'{TXT:UI_Panel_Down}'+'{TXT:UI_Panel_Down}
I Get something Like This... (completely hypothetical)
Code: [Select]
'{Keystroke(.03;1):UI_Panel_Up}'+'{Pause(.03)}'+''{Keystroke(.03):UI_Panel_Up}'+'{Pause(.03)}'+'{Keystroke(.03):UI_Panel_Down}'+'{Pause(.03)}'+''{Keystroke(.03):UI_Panel_Down}'+'{Pause(.03)}
In This, the Token "Keystroke" Retreives the keystroke information, including length of press, (.03) and type of press (1) from the Variable UI_Panel_Up.  (type of press "1" being "press/release, "2", "press", 3 being "hold", "4" being "toggle", etc.).  Then, the second Token "pause" would allow me to specify a pause in seconds.

So, my question is: Is there any way to accomplish this end goal, or am I stuck using A Seperate Command for each Macro? 

I.e.

command "Open Market"
Quick Input, '{TXT:UI_Panel_Up}{TXT:UI_Panel_Up}.....'

Then When I want to do that "Execute Command Open Market"

Perhaps I am making a lot of hoopla over nothing, certainly I can accomplish my end goal with the later, and simply make a single command for each macro. Where each macro is a series of quick inputs.  However, given how much time my routines save using quick input on the first level...

Given
Code: [Select]
Set Text [UI_Panel_Up] to 'w' (save value to profile)

and the command "UP":

Code: [Select]
Press w and hold for 0.03 seconds and release
it takes less than half the time to complete

Code: [Select]
Quick Input, '{TXT:UI_Panel_UP}'
 with a .03 second quick input pause, than it does to complete

Code: [Select]
Execute command, 'UP'
I suspect strongly if I were able to pass the same time savings to my macros, by executing them via a variable and quick input (or some other new function), everything would be a lot more snappy. (And easier to code, as I find copy/paste combined with Quick Input is REALLY QUICK. Vs. selecting a execute command in a large list is...not so much.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #1 on: September 28, 2016, 10:21:27 AM »
Note: Developer should really add a little heads up in the menu like in the Quick Input. I just assumed since it wasn't there you couldn't do it...)
The tooltip for the "Text" field in the "Set a Text Value" action clearly states "Note that you can also use any combination of tokens here as well."; The documentation also notes "This value can also contain other tokens that are replaced out when the command runs".

am I stuck using A Seperate Command for each Macro?
I'm not sure I understand; You want to use VoiceAttack to trigger commands by speech, but you don't want to use commands?
Can you clarify?

Castleberg

  • Newbie
  • *
  • Posts: 37
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #2 on: September 28, 2016, 11:41:53 AM »
Sorry about the ambiguity.

My issue is that I am using voice attack to save considerable time with trading in elite dangerous. In addition to the common commands like requesting dock, etc, I have several commands set up to automate my trading. The market screen has upwards of 100 entries, so my command goes something like this: (dumbed down because I'm responding on my phone from work...)

"All V"
Execute open market (series of keystrokes)
Execute sell V (loop runs to go down 50-80 rows to the trade, selects, holds key to sell units, confirms)
Execute buy v (similar to above, but buys new stock)
Execute exit menu
Execute set nav v (series of commands with pauses to set my next coarse)
Execute launch

In a nutshell, +/-. That has worked fine, and would continue to work. However, my commands were all hard coded before (press d, press space, etc). I switched to create a keybinding commands (i.e. Cmd = "ui_up", that when executed does, "press w key for .03 seconds". So I swapped all my hard coded keystrokes for this, such that my code went from something akin to this:

Code: [Select]
Press and release d key for .03 seconds

To something akin to this:

Code: [Select]
Execute command ui_up and wait to complete

Great. Now I can just update all the key binding commands and bam, my code will work.
Except that calling out to a new command every time added considerable time. Namely, my script that would execute in 5 seconds or so now took 10-15. I could literally just do it myself faster.

This is because, I think, my command has a loop (because there are so many rows to scroll down), that looks something like this:

Code: [Select]
Loop while counter is less than TargetRow
Ui_down
Set counter to counter plus 1
End loop

Thus, when executing the command, it calls out to another command some 50-80 times. I noted that when I use quick input to accomplish the same thing, like this:

Code: [Select]
Loop while counter is less than TargetRow
Quick Input '{TXT:ui_down}
Set counter to counter plus 1
End loop

(Where ui_down is a txt variable set to "d"), this same code completed in a fraction of the time.

So my comment that I would be stuck using seperate commands, was alluding to this. While more logical, it simply did not execute as quickly. Basically it takes about twice as long.  My testing reveals (about as I'm at work)

Entering keystroke in executing command               : baseline
Using quick input to call txt variable.                       : 1.1x baseline
Calling another command to that executes keystroke: 2-3 x baseline

While for a simple on-off command this might only be a second wait, for a loop that cycles a hundred times, that extra time starts to really add up.

So, if possible, I would like to program certain "time dependent" macros into a txt variable, but to do that I need a token of some sort to cause a pause, beyond the single command in the quick input dialogue (to account for, say, a dialogue that takes 1.5 seconds to load).

So, saying I want to use voice attack to execute commands, but I don't want to use commands is an over-simplication. But, it is safe to say I would like to be able to use quick input to execute multi key strokes for simple macros when needed.

Of course, I could just use the quick input for these situations where i need to use long loops, but I thought perhaps there was a more efficient way around my problem (the problem being time to execute, not ability to execute).

Regarding your remark on the "heads up" the only thing I saw, and I just reopened it, is a line that says,

"Set a text value
Set a text value to be used with various features, such as text-to-speech. This value can be accessed in various areas by using {txt:variable name} tokens."

That is the only thing on the dialogue. Compare that to the quick input dialogue that, while I don't have it in front of me, is very clear that tokens can be used in quick input.

A moot point, not worth dwelling on, but I just assumed based on the wording that the set variable dialogues reference to tokens are letting you know it can be "accessed" via token, as apposed to "set" via token. Again, not important at this point :)


The bottom line (perhaps some of my ignorant / faulty logic can be circumvented here...) is that I need to be able to activate a series of keystrokes, with pauses, as fast as possible, faster than calling out to a seperate command will apparently allow.

If I can't get it working as I hope, I'll just resort to not calling out and using a quick input for individual keystrokes with the built in pause function to accomplish this, but it will be much more messy, and much less modular. :(


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #3 on: September 28, 2016, 12:46:44 PM »
The bottom line (perhaps some of my ignorant / faulty logic can be circumvented here...) is that I need to be able to activate a series of keystrokes, with pauses, as fast as possible, faster than calling out to a seperate command will apparently allow.
If that's the bottom line, I still don't understand the problem.

Code: [Select]
Press A key and hold for 0,01 seconds and release
Pause 0,5 seconds
Press B key and hold for 0,01 seconds and release
Pause 0,5 seconds
Press C key and hold for 0,01 seconds and release
Is how VoiceAttack was designed. Admittedly it's more unwieldy than just writing everything out(which is what the "{EXP:}" token has mutated into for advanced use), but I'd argue it's a fair compromise between complexity and functionality.

Whether you're using "Press A key and hold for 0,01 seconds and release" or "Quick Input '{TXT:KeyA}" doesn't change anything, you're still making a list of actions to be executed in sequence.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #4 on: September 28, 2016, 04:36:16 PM »
TL;DR -  Sorry... on a time crunch o_O

Are we saying we just want a pause indicator for quick input?  Like [PAUSE:.01] or something like that?  I know there's no pause between keystrokes, as the intent was to dump out text as fast as possible.  I don't think it would be that difficult to pop that in there if that's all that is needed.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #5 on: September 28, 2016, 04:55:42 PM »
Are we saying we just want a pause indicator for quick input?  Like [PAUSE:.01] or something like that?
Basically: Yes.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #6 on: September 28, 2016, 05:02:44 PM »
Ok, cool ;)  I'll pop it in for the next release.

Castleberg

  • Newbie
  • *
  • Posts: 37
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #7 on: September 28, 2016, 06:19:44 PM »
 :) :) :)

Thanks guys!

And Pfeil, thanks for the time and help. Sorry my ability to clarify was so poor.

The example you gave, if limited to a single command would indeed be identical, and I would have no issue. Problem being that my key bindings, by design, are in one command, and called by another command. The problem being that the code:

Quote
Press A key and hold for 0,01 seconds and release
Pause 0,5 seconds
Press B key and hold for 0,01 seconds and release
Pause 0,5 seconds
Press C key and hold for 0,01 seconds and release

That you referenced adds about 10+ seconds to my time to complete the command(excluding any pauses). Because it is not in the command being used.  I execute command b, from within command a, in a loop, over 100 times. If I was doing a simple action, say arming a weapon, etc this would be a minimal inconvienance, if even noticible. But when doing a complex action (for example scrolling down 75 times, over another 20 times, then back up 50 times or so...that requires a loop that will execute hundreds of times. That .2  second delay to launch 'Pfeil's cmd' just turned into a 15  second wait time as the loop executes that external command on every loop cycle.

Admittedly, if I hard code image input into command a, I am fine. But then, that defeats the purpose of a flexible keybinding, and to a larger extent, a modular macro. (I have a macro to launch menu a, a different one for menu b, etc. so when I want to anger a value, instead of saying "up up up left up select down down space space" I'll say "execute menu 1, down down toggle".

So, to say the least, the addition of the pause tokens in quick input will be much appreciated!

Thanks you guys :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #8 on: September 28, 2016, 07:05:22 PM »
I understand how calling a command in a loop would make for poor performance, that's why I said
Code: [Select]
Whether you're using "Press A key and hold for 0,01 seconds and release" or "Quick Input '{TXT:KeyA}" doesn't change anything
From my point of view you had already solved your problem by using quick input, which can be used in exactly the same manner as a static keypress:
Code: [Select]
Quick Input '{TXT:KeyA}'
Pause 0,5 seconds
Quick Input '{TXT:KeyB}'
Pause 0,5 seconds
Quick Input '{TXT:KeyC}'

What I had trouble wrapping my head around was your intent to use Quick Input to implement an improvised subroutine system. I understand how such functionality can be very useful indeed, however it's the manner in which it's presented to the user that worries me.

Perhaps at some point in the future, the ability to create profile-wide subroutines and functions(to which parameters could be passed, and possibly called as a token) will be implemented natively.

Castleberg

  • Newbie
  • *
  • Posts: 37
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #9 on: September 28, 2016, 08:17:28 PM »
Well, I certainly can't argue with that.

The implementation would have been...macgyvered, to say the least.

My thought was it would save a lot of work to save the entire keystring to a single variable, that I could call all at once from quick input. But your point is well taken.

I look forward to the next release!

Btw, Gary...
I assume it Would it be possible to use the same token if imbedded in a txt variable?

Ie given 3 txt variables:
variable1 that contains "ww[BACKSPACE]{pause,0.5}ww"
Variable2 that contains "ww[BACKSPACE]"
Variable3 that contains "ww"

Would function the same when placed in quick input like this:
Code: [Select]
{TXT:variable1}Would function the same as a quick input (when implemented) of a txt variable2
Code: [Select]
{TXT:variable2}{pause,0.5}{TXT:variable3}
At least that would be my hope, although something tells me that might be asking too much.

However, surely you could see the utility of being able to store entire sequences in a txt variable (or event write said variable to a file that can be stored, shared, etc. and then immediately called upon in any profile....mhhhhh

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #10 on: September 28, 2016, 08:56:06 PM »
Btw, Gary...
I assume it Would it be possible to use the same token if imbedded in a txt variable?
Admittedly, I'm not Gary, but I feel I can answer based on the information provided:

The way Gary put it, it'll be something like "[PAUSE:.01]".
The important thing to note is that it's actually not a token as such(thus the square brackets); Tokens are processed just about anywhere within VoiceAttack(command names excluded), whereas this would work the same way "special characters...that do not have a character representation" do, like "[BACKSPACE]" in your example, and only be processed within the Quick Input action.

So the short answer is: Yes, it is possible to use the "token"/"special character" within a text variable.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #11 on: October 01, 2016, 06:53:18 PM »
The new beta has a [Pause:seconds] indicator for Quick Input:

[Pause:0.5]   will pause one half second, [Pause:2.5] will pause 2.5 seconds

Hope that works for you ;)


Just a note...   Pfeil is like Gary on steroids.  I have no clue what all this stuff does o_O


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #12 on: October 01, 2016, 07:52:27 PM »
I have no clue what all this stuff does o_O


 ::)


I hate to spoil a new release(no, really), but this new indicator suffers from the "classic" decimal separator issue; "[PAUSE:0.5]" will pause 5 seconds, "[PAUSE:1.5]" 15 seconds.

« Last Edit: October 01, 2016, 07:59:00 PM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #13 on: October 01, 2016, 08:26:10 PM »
I may have asked this before, but are you using an English version of Windows?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #14 on: October 01, 2016, 08:45:18 PM »
Installed from an "EN" ISO, System Locale("Language for non-Unicode programs") is set to "English (United Kingdom)"(which shouldn't matter to most modern software anyways), though of course the "Formats" tab(and the Additional settings) are set to local units.

I believe I PMd you a detailed list of my "Region and Language" options.


Though, looking at the decimal issue again, this is different. When using a comma(the decimal separator for my system, which regrettably I had not tried), the "[PAUSE:]" indicator works as expected, whereas with decimal conversion accepts neither "." nor ",".

I'd prefer if "." worked, as that'd be consistent for sharing actions and profiles, as otherwise it wouldn't work on an American system for example.
« Last Edit: October 01, 2016, 08:54:33 PM by Pfeil »

Castleberg

  • Newbie
  • *
  • Posts: 37
Re: Save Keystrokes and pauses to a VARIABLE
« Reply #15 on: October 01, 2016, 08:58:15 PM »
The new beta has a [Pause:seconds] indicator for Quick Input:

[Pause:0.5]   will pause one half second, [Pause:2.5] will pause 2.5 seconds

Hope that works for you ;)


Just a note...   Pfeil is like Gary on steroids.  I have no clue what all this stuff does o_O

Thanks a ton Gary!

Very impressed by your responsiveness and attentiveness to the forums, serious cuddos. Happy to support a developer like you anytime. I will tinker with the new pause a bit, but I'm sure I can make great use of it!!

Thanks again!