Author Topic: AutoHotkey "Integration" with VoiceAttack  (Read 793 times)

Exergist

  • Moderator
  • Sr. Member
  • *****
  • Posts: 344
  • Can you dig it?
AutoHotkey "Integration" with VoiceAttack
« on: July 19, 2018, 09:16:33 am »
What is it?
The attached VoiceAttack profile provides the means to use AutoHotkey functionality (version 1.1.29.01 as of this writing) within the VoiceAttack environment through C# inline functions. This project (VA-AHK.Integration) expands VoiceAttack's capabilities (i.e., directly leverage AutoHotkey functionality for use by VoiceAttack), provides more control over AutoHotkey processing, and enables easy communication between AutoHotkey and VoiceAttack. And you don't even need to have the AutoHotkey software installed.

So in summary this functionality may be useful for folks who use AutoHotkey scripts in conjunction with VoiceAttack and want:
  • Greater control over AutoHotkey script execution via VoiceAttack, which is handy especially for running VoiceAttack actions/commands in series with AutoHotkey scripts
  • A simple framework for passing variable data back and forth between AutoHotkey and VoiceAttack

Why would you do this?
During the early development of the (now obsolete) Physical keyboard & mouse input blocking profile I did a lot of research on how to use AutoHotkey to accomplish the task. In doing so I discovered amazing-andrew's AutoHotkey.Interop project on GitHub and I decided to take on the challenge of adapting his work for use with VoiceAttack.

I'm guessing that 2% (or less) of users will be interested in this...but that's okay ;)

So how do I use it?
If you're still with me down here then you can check out the attached VoiceAttack package as well as the associated VA-AHK.Integration GithHub repository. The README on GitHub provides a good overview of the project as well as details about how the functionality works at a high level. The profile included in the package contains example commands as well as the required supplementary files. I've provided thorough comments for every command action line in VoiceAttack and code line in the inline functions, so you should be able to follow along and learn how VA.AHK-Integration works and understand its capabilities. In short, the included commands demonstrate:
  • Execution of raw AutoHotkey code
  • Exeuction of an AutoHotkey script
  • A wide range of functionality packed into a single VoiceAttack command and inline function
  • A simple example showing the functionality spread across multiple VoiceAttack commands and inline functions
Please note that the VA-AHK.Integration package includes three libraries (.dll files) for use by the profile. Two of them are the 32 and 64-bit AutoHotkey libraries (both named AutoHotkey.dll and obtained from HotKeyIt's AutoHotkey_H Repository), and the third is the VA.AutoHotkey.Interop.dll (modified from amazing-andrew's AutoHotkey.Interop) for interfacing between C# and the AutoHotkey libraries. The commands automatically handle the moving of the VA.AutoHotkey.Interop.dll into VoiceAttack's Shared\Assemblies folder, and VA.AutoHotkey.Interop.dll will automatically locate and access the required AutoHotkey.dll. All appropriate links, credits, and source code may be found via the VA-AHK.Integration README on GitHub.

I've done a lot of testing in Windows 7 and 10 and everything appears to work as expected, though I don't have many AutoHotkey scripts available to further evaluate the functionality. If you have any questions or encounter any bugs or other unexpected behavior please let me know.

I have been developing this project on and off for quite a few months, so I'm glad to finally be able to release it. Enjoy! :)
« Last Edit: July 23, 2018, 07:41:48 am by Exergist »

Emiricol

  • Newbie
  • *
  • Posts: 1
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #1 on: July 19, 2018, 01:21:00 pm »
This could be cool. What sorts of things are you using AutoHotkey for within VA?

Exergist

  • Moderator
  • Sr. Member
  • *****
  • Posts: 344
  • Can you dig it?
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #2 on: July 19, 2018, 10:36:39 pm »
To be honest I don't personally use AHK with VA, and when I say that out loud it does sound nuts that I developed this project. But it was a good challenge to say the least.  :)

I know there are folks that are skilled at using AHK that like to use it in conjunction with the excellent UI and additional control that VA offers. Hopefully something like this project will be useful to some folks out there.
« Last Edit: July 20, 2018, 11:02:17 am by Exergist »

mikauzora

  • Newbie
  • *
  • Posts: 2
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #3 on: October 18, 2018, 12:53:55 pm »
Dude i just met VA, like 1 week ago, and was craving to integrate it with ahk.

Inserting input with "quickinput" is nice, but does not feel awsome yet. your idea was just what i needed.

ill check out and give feedback soon!

Thank you!

Exergist

  • Moderator
  • Sr. Member
  • *****
  • Posts: 344
  • Can you dig it?
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #4 on: October 22, 2018, 07:03:31 am »
@mikauzora - I'm glad you see value in it! Hopefully the examples and included comments illustrate how to use everything. Also feel free to PM me if you have specific questions or run into glaring problems during your development.

Cheers!

mikauzora

  • Newbie
  • *
  • Posts: 2
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #5 on: October 24, 2018, 08:51:17 am »
Thanks a lot!

I have a question: i could install everything and test the example scripts.

I understand it's possible to run another instance of AHK through VA, which is very nice, BUT, in most cases for the time being, that's not what i really need.

I have a main script, with the functions i use during my day. What i need is activate the functions with VA, like, sending a message to my main script.

For instance, i have a function that gives me a report.

to activate it in AHK, my shortcut is

vrpt

whenever i type that, the report is given.

With VA, instead of typing, i say: "give me report". VA understands what i said, and types "vrpt" for me, then the shortcut is activated from my main AHK thread, lets put it this way.

So, what i really need was a "low level" message from VA, directly to my already running AHK script.

If it was a conversation, it would be like:

VA says: "hello Main.ahk, please execute this hotkey for me -> vrpt "

I hope i was clear in my intent! Do you have any clue know how i would achieve this? In my mind it looks a simple task (in essence), but i don't know the model on how to write it.

This is justified because i will need some more complex tasks to be done, so i would rather do all the thread creating/managing inside the main script, and only call it with VA.

Thanks for your help!


Exergist

  • Moderator
  • Sr. Member
  • *****
  • Posts: 344
  • Can you dig it?
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #6 on: October 25, 2018, 07:37:07 am »
So as I understand it you basically want to directly execute a portion of AHK code from VA. You currently have that code tied to a hotkey combination "vrpt." Essentially you want to call the hotkey's code without invoking the hotkey itself.

I don't believe invoking a hotkey's code without triggering the hotkey itself is possible (I have a question on the subject pending on the AHK forums, and I'll update this post if needed). But what if you take the "vrpt" code and move it into a function (vrptFunction)? Then perhaps you can call the function from the hotkey (still maintaining the "vrpt" functionality) as well as invoke the function using VA-AHK.Integration ==> ahk.ExecFunction("vrptFunction")? That would eliminate the typing middleman.

So in this case the conversation would be:
VA says: "hello Main.ahk, please execute vrptFunction for me" (which then executes the code that was previously in your vrpt hotkey).

Hopefully that works for your application :)