That's very simple, as Exergist has done all the hard work already.
If you just need the active screen resolution in a set of variables, the inline function can be simplified to something like
using System.Windows.Forms;
public class VAInline
{
public void main()
{
Form f = null; // Declare Form f
try // Attempt the following...
{
f = new MyForm(VA); // Create new MyForm instance
}
catch { VA.WriteToLog("error!", "red"); } // Output info to event log
finally // Perform after completing try
{
f.Close(); // Close the form
}
// Output active screen width and height to VoiceAttack variables
VA.SetInt("~activeScreenWidth", MyForm.ActiveScreen.Bounds.Width);
VA.SetInt("~activeScreenHeight", MyForm.ActiveScreen.Bounds.Height);
}
}
class MyForm : Form
{
public static Screen ActiveScreen {set; get;} // Declare public variable for storing ActiveScreen
public MyForm(dynamic VA)
{
this.StartPosition = FormStartPosition.CenterScreen; // Set the start position of the form to the center of the screen
ActiveScreen = Screen.FromControl(this); // Capture the screen that contains the (not shown) form
}
}
// References:
// https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.screen?view=netframework-4.7.2
// https://stackoverflow.com/questions/1121600/how-do-i-determine-which-monitor-my-net-windows-forms-program-is-running-on
Which would output to integer variables named "~activeScreenWidth" and "~activeScreenHeight" (note that these are command-scoped variables, I.E. they'll only be available to that instance of the command; remove the "~" prefix if you want to make them global, and are certain that won't cause conflicts)