0

I have some Windows 10 LTSC/IoT digital signs starting the ShareX screen capture application on boot like so:

"C:\Program Files\ShareX\ShareX.exe" -silent -startautocapture

After the Autocapture fires the Destination config is set to post the image to a URL but when network outages occur the ShareX UI spawns at a higher z-index than the Four Winds digital sign software display and remains there until manually closed or minimized.

I have been over the ShareX docs but this behavior isn't mentioned and the Custom Uploader options only include specifying an error message to display. Anyone have ideas on suppression or minimizing the UI? Possibly a PowerShell trick for shifting the focus?

jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
  • 1
    Have a look at [this answer](https://stackoverflow.com/a/51157662/7571258). You may replace `SC_CLOSE` by `SC_MINIMIZE`. For that, add the definition as `public const int SC_MINIMIZE = 0xF020;`. – zett42 Sep 02 '22 at 10:18

1 Answers1

0

Per @zett42 comment I started out with this answer. Unfortunately neither ShareX nor ShareX 8.14 is apparently the correct ConsoleWindowClass.

[int]$handle = [WPIA.ConsoleUtils]::FindWindow('ConsoleWindowClass','ShareX 8.14')

In the end this answer got it working using

$handle = $fw::FindWindow([IntPtr]::Zero, 'ShareX 8.14' )

Since this has a version number in the name I will need to sort out an enumeration strategy to iterate over the open windows and do substring matching but for now this succeeds.

I am very new to PowerShell so this may be ungracefully done.

$sig = @'
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(IntPtr sClassName, String sAppName);
    [DllImport("user32.dll", CharSet = CharSet.Unicode)]
    public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
    [DllImport("kernel32.dll")]
    public static extern uint GetLastError();
    public const int WM_SYSCOMMAND = 0x0112;
    public const int SC_MINIMIZE = 0xF020;
'@

$fw = Add-Type -Namespace WPIA  -Name ConsoleUtils -MemberDefinition $sig -PassThru
$wname='ShareX 14.1' # any existing window name
[int] $handle = $fw::FindWindow([IntPtr]::Zero, $wname ) # returns the Window Handle
if ($handle -gt 0)
{
[void][WPIA.ConsoleUtils]::SendMessage($handle, [WPIA.ConsoleUtils]::WM_SYSCOMMAND, [WPIA.ConsoleUtils]::SC_MINIMIZE, 0)
}
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139