Thanks to the VoiceAttack help document and the interwebs I found a way to use a VoiceAttack VB.net inline function to obtain the filepath for the active window's executable file. The code is as such:
Referenced Assemblies: System.dll;System.Core.dll;System.Data.dll;System.Data.DataSetExtensions.dll;System.Deployment.dll;System.Drawing.dll;System.Net.Http.dll;System.Windows.Forms.dll;System.Xml.dll;System.Xml.Linq.dll
'Adapted from code by jay20aiii ==> http://www.vbforums.com/showthread.php?668460-Get-path-of-active-window
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Drawing
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Linq
Imports System.Xml.Linq
Imports System.Threading.Tasks
Public Class VAInline
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hWnd As IntPtr, ByRef lpdwProcessId As UInt32) As UInt32
Private Declare Function GetForegroundWindow Lib "user32.dll" Alias "GetForegroundWindow" () As IntPtr
Public Sub Main()
'Get the ForeGround Window
Dim hWnd As IntPtr = GetForegroundWindow()
Dim ProcessID As UInt32 = Nothing
'Get the Window's Process using it's ID (obtained using the GetWindowThreadProcessId API)
GetWindowThreadProcessId(hWnd, ProcessID)
Dim Proc As Process = Process.GetProcessById(ProcessID)
'Send the filename back to VoiceAttack and store in a text variable
VA.SetText("application path", Proc.MainModule.FileName)
End Sub
End Class
This seems to work great for getting the executable filepath for 32 bit applications. However it doesn't work for 64 bit applications.
I have nearly zero knowledge about VB.net (and C#), and I was hoping that the community might help me figure out how to get the executable filepath for a 64 bit application through VoiceAttack.
Thanks!