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

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
AutoHotkey "Integration" with VoiceAttack
« on: July 19, 2018, 10: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 supplemental 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.

Support This and Future Efforts
If you find this profile useful, please consider buying me a cup of coffee. Thank you for your support!
 


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: June 02, 2020, 09:34:15 PM by Exergist »

Emiricol

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

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #2 on: July 19, 2018, 11: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, 12:02:17 PM by Exergist »

mikauzora

  • Guest
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #3 on: October 18, 2018, 01: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

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #4 on: October 22, 2018, 08: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

  • Guest
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #5 on: October 24, 2018, 09: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

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #6 on: October 25, 2018, 08: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 :)

CZiNTrPT

  • Guest
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #7 on: October 15, 2019, 09:57:07 AM »
Hi, outstanding work, I'm so glad I found it!

Can I use this to control vjoy via ahk? Like this eg: https://autohotkey.com/board/topic/87690-using-ahk-to-control-vjoy/page-3#entry566869 ?

I want to control my throttle via VA

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #8 on: October 15, 2019, 10:53:15 AM »
Have you looked into the joystick output plugin for VoiceAttack?

I don't know whether AutoHotkey would have additional functionality, but if you're looking to control a virtual joystick that plugin should work.

CZiNTrPT

  • Guest
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #9 on: October 15, 2019, 01:13:36 PM »
yes, but it didn't work anymore, the versions don't match :(

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #10 on: October 15, 2019, 01:20:04 PM »
When did you try it? Gary updated it in August to work with the (then) latest version of vJoy.

Aniv_D

  • Newbie
  • *
  • Posts: 18
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #11 on: September 16, 2021, 11:47:46 PM »
Hello!
I downloaded your VA-AHK. Integration_v1.0.1.vax and imported it into VoiceAttack. (Plugins are enabled, all files are present)
but an error is returned when running test commands.
could you tell me what the problem might be?
in the logs, it will write that "Unable to load AutoHotkey.dll"
Thanks.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #12 on: September 19, 2021, 09:22:47 PM »
I would have to dig through this to see what might be up. The log seems to indicate that it cannot find the AHK version.

Also keep in mind this is kind of a crazy project and the included AHK version is likely very outdated (and I don't have plans to continue updating it).

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: AutoHotkey "Integration" with VoiceAttack
« Reply #13 on: November 16, 2021, 02:47:35 PM »
Awesome work, man!  Thank you so much!  Just getting into AHK and so glad there is already something available for VA

Cheers!