Author Topic: Recognizing new words without manually importing anything  (Read 1815 times)

anoburn

  • Guest
Recognizing new words without manually importing anything
« on: January 30, 2019, 04:14:35 PM »
Not sure if this is even possible right now, but whatever:
My goal is to recognize words that aren't already in the profile. This could be used for inventory management in games, where another script searches a screenshot for text and remembers where each one is. It would be awesome to somehow say "Use item x" and have VA click the corresponding location or something like that.
My idea was to let my script write into a profile file, generating the needed commands. But I would have to import that profile manually in the GUI each time this method is used. Is there any way to do something like this completely automated?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Recognizing new words without manually importing anything
« Reply #1 on: January 30, 2019, 05:00:50 PM »
You can use tokens in command names to do this. The simplest way is to populate a text variable with the words or phrases you want to use and using the "{TXT:}" token.

The main caveat to this is that the profile needs to be reloaded to re-generate the phrase list(I.E. when the value of the variable changes, the profile must be reloaded before any new words/phrases in that variable become available, or old ones unavailable).

There is an action implemented specifically for use with this feature: "Reset the Active Profile". It will reload the profile without requiring any manual input from the user(as long as the command containing it is triggered in some way.

Reloading a profile does mean two things: Non-persistent profile-scoped variables(prefixed with ">") will be cleared, and any currently running commands will be stopped(including the one executing the "Reset the Active Profile" action, so you'll want to do that at the end of a command).

As variables are not initialized when a profile loads, you will likely also want to reload the profile after it loads the first time after VoiceAttack restarts(after setting the value of the variable(s) you've used in command names).
Reloading the profile also executes the command assigned to the "Execute a command each time this profile is loaded" option, so you'll want to use something like this:
Code: [Select]
Begin Boolean Compare : [>>reloadOnce] Equals False
    Set Boolean [>>reloadOnce] to True
    Reset the active profile
End Condition

This uses a persistent profile-scoped variable to make sure the profile is only reloaded automatically when the profile loads the first time in that VoiceAttack session(preventing an infinite loop).


Currently there is a bug in VoiceAttack v1.7.3 where adding the "Reset the Active Profile" action will add an empty keypress instead; To get around this you can import the command I've attached and copy the action to the command(s) you want to use it in.

anoburn

  • Guest
Re: Recognizing new words without manually importing anything
« Reply #2 on: January 30, 2019, 05:24:21 PM »
That's just what I was looking fort, thanks a lot! :)