>>102192427
Oh. This actually works:
Use Add-Type once like so.
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Clicker {
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
public const int MOUSEEVENTF_RIGHTDOWN = 0x0008; // press down the right mouse button
public const int MOUSEEVENTF_RIGHTUP = 0x0010; // release the right mouse button
public static void RightClick() {
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
}
"@
Then you can simulate right clicks with [Clicker]::RightClick()
. You'll have to use Add-Type again if you close the Powershell window.