Author Topic: Plugin debugging  (Read 4843 times)

janjan

  • Newbie
  • *
  • Posts: 42
Plugin debugging
« on: May 16, 2020, 03:50:25 AM »
Hi,
I am trying to go over the section concerning the plugin and I opened the supplied sample plugin in VS.
Since this is a class library, how can i debug it?
Is there a simple sample for a plugin +  an option to debug it in VS.
+ I am new to VS...
« Last Edit: May 16, 2020, 01:33:48 PM by Gary »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Plugin debuggind
« Reply #1 on: May 16, 2020, 10:41:17 AM »
To debug a VoiceAttack plugin, there are few things you'll need to do.  First, you'll need to make sure that the plugin outputs the .dll into VoiceAttack's folder structure.  That means that the plugin dll needs to go into VA's Apps folder within a subfolder:

C:\Program Files (x86)\VoiceAttack\Apps\MyPluginFolder

You get the dll into that folder by going into the plugin's project settings, down to the Build tab and setting this in the Output path box.

Build the plugin once so that the dll appears in that folder.  You may have to adjust security settings depending on your machine.  To do that, just right click on the new folder you created in the Apps folder, select, 'properties' then 'security' and set All Users (or whatever) to 'Full Control' (or however you want to set up your own security settings).

Open VA, turn on plugin support (restart VA).  Open the plugin manager and select the new plugin you just built.

Next, open the plugin's project settings, go down to the Debug tab and set the, 'Start external program' value to the path of VA (usually C:\Program Files (x86)\VoiceAttack\VoiceAttack.exe).

Set a breakpoint somewhere like in the init or displayname functions so you can see things happening.

You can now just, 'run' the plugin project.  VA will be launched and then the plugin's display or init will be run (cant remember which is first).


I'll need to update the VA documentation to reflect this, as it makes the horrible assumption that if you're down this far in the weeds you've probably done this before.  Again - horrible assumption :(

janjan

  • Newbie
  • *
  • Posts: 42
Re: Plugin debuggind
« Reply #2 on: May 16, 2020, 12:12:56 PM »
Ok I'll try this.
I have 3 more related question.

1. When I create a C# inline function I start the VS project as a Console Application (hope this is the right way)
So far I was testing my code in VS and cope paste to VA with some a few changes.
E.g. in VS I cannot use:
Code: [Select]
VA.SetText("TILS_Field", tField)
since 'VA does not exist in the current context'
The same goes for and VA method.
Assuming the  "Console Application" is the right approach for creating inline functions, how do I add the VA namespace (or is it an object?) to my VS code so that I will not need to modify the code when I copy to VA or even be able to debug with VA.

2. This one is related to plugins.
I understand that "VA_Invoke1" defines what happens when a certain VA command is initiated.
In the winamp example there is a switch statement according to the initiating VA commands.
Say you have a small plugin ~300 lines of code.
What would be the advantage of using a plugin (is it more complicated to setup and perhaps debug in VS?) ,over a compiled C# code, as an inline command, with the same structure - a switch case according to a variable value?

3. This one is related to plugins.
I asked this in the forum but I wan to make sure.
Suppose I define
Code: [Select]
String[] Airport ... in my plugin "VA_Init1" function.
Will the Airport array be accessible for every command which executes an external plugin or will I need to redefine it every time?


Thank you!!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Plugin debuggind
« Reply #3 on: May 16, 2020, 01:31:07 PM »
1) There is no VoiceAttack API available, unfortunately - It's not to that point yet (only have plugins and inline functions so far).  VA also doesn't include debugging tools or anything like that, as its purpose was to simply provide a quick means of getting something done that wasn't available yet in the user interface.  That is the intent wasn't to run your data center or build a database out of it - although you *could* (and some are doing some very elaborate things), it wasn't something that was considered when it was built.  Hope that makes sense.

2)  There is no advantage other than having Visual Studio to help you build your dll- plugins came first as a way to do all the stuff above.  Inline functions came much later as a quicker way to do smaller tasks without having to build the Death Star ;)

3)  I'm thinking you can access modular-scoped variables from within the plugin, however, I would advise that you use concurrent collections if that's what you're going to do- otherwise you'll be in for a lot of pain (since VA can/will call your plugin from multiple threads). 

janjan

  • Newbie
  • *
  • Posts: 42
Re: Plugin debugging
« Reply #4 on: May 18, 2020, 12:15:53 PM »
Hi,
I've does as you suggested:
Next, open the plugin's project settings, go down to the Debug tab and set the, 'Start external program' value to the path of VA (usually C:\Program Files (x86)\VoiceAttack\VoiceAttack.exe).

Set a breakpoint somewhere like in the init or displayname functions so you can see things happening.

You can now just, 'run' the plugin project.  VA will be launched and then the plugin's display or init will be run (cant remember which is first).

VA does start from withing VS but it does not stop on my breakpoints.
Any idea what can be wrong?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Plugin debugging
« Reply #5 on: May 18, 2020, 12:44:50 PM »
Put a breakpoint in the, 'VA_DisplayName()' function, as that always gets read. If that's not getting called, it's possible that the plugin is either not in the right directory (in a subfolder under Apps) or VA does not have plugin support turned on with your plugin selected in the plugin manager.

janjan

  • Newbie
  • *
  • Posts: 42
Re: Plugin debugging
« Reply #6 on: May 18, 2020, 01:10:57 PM »
I ended up hooking to the actual process and that did it.
Or it may have been the fact the I reopened VS as admin. I think the latter is vital for that to work.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Plugin debugging
« Reply #7 on: May 18, 2020, 01:12:13 PM »
it may have been the fact the I reopened VS as admin.
It shouldn't be, unless you're running VoiceAttack as admin.

janjan

  • Newbie
  • *
  • Posts: 42
Re: Plugin debugging
« Reply #8 on: May 18, 2020, 01:53:46 PM »
I am running it as admin.
Don't remember is it was VA recommendation or VIACOM.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Plugin debugging
« Reply #9 on: May 18, 2020, 02:19:13 PM »
If you run VA not as an admin and it still works with VAICOM/DCA, you'll want to not run as admin (it's not necessary).

janjan

  • Newbie
  • *
  • Posts: 42
Re: Plugin debugging
« Reply #10 on: May 18, 2020, 10:52:26 PM »
Vaicom manual specifically write:
"Make sure VoiceAttack runs as administrator and plugin support is enabled."

CrossWiseRanger

  • Newbie
  • *
  • Posts: 13
Re: Plugin debugging
« Reply #11 on: October 23, 2020, 09:08:39 AM »
Additionally in VS debugging.

Debug --> Attach to Process --> scroll down and select the process, click attach.