If it helps anyone else: Batch script, to change input director configs based on how many monitors are connected to the host.
My batch script, which I have triggered via a task scheduler task tied to the Kernel-PnP source with eventID 1010 ( i'm usually switching monitors by unplugging and replugging in different cables)
-Jolly
cls
title Switch Input Director Settings
REM ******************START MAKE SURE WE HAVE ADMIN RIGHTS***************
:init
setlocal DisableDelayedExpansion
set cmdInvoke=1
set winSysFolder=System32
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
if '%cmdInvoke%'=='1' goto InvokeCmd
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
goto ExecElevation
:InvokeCmd
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
f
:ExecElevation
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
REM ******************END MAKE SURE WE HAVE ADMIN RIGHTS***************
REM %TEMP%\dxdiag.txt /q /f >nul 2>nul
start "" /w dxdiag /t %TEMP%\dxdiag.txt
for /f "tokens=3" %%f in ('find /c"Monitor Name:" %TEMP%\dxdiag.txt') do set MONITOR_COUNT=%%f
echo %DATE% %TIME% %MONITOR_COUNT% >> c:\temp\moncount.log
net stop InputDirector
tskill inputdirector /A
if %MONITOR_COUNT% == 0 (
echo zero monitor connected
GOTO END
)
if %MONITOR_COUNT% == 1 (
echo one monitor connected
GOTO END
)
if %MONITOR_COUNT% == 2 (
echo two monitor connected
GOTO END
)
if %MONITOR_COUNT% == 3 (
echo third monitor connected
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Input Director" /v MasterMonitorGrid /f /d "01/02/0/0/N/0,11,18,22,+00/0,0,18,11,+01/" /reg:32
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Input Director" /v MasterMonitorLayout /f /d "01/03/18/0/N/0,11,18,22,+00/0,0,18,11,+01/18,2,36,19,+02/" /reg:32
)
if %MONITOR_COUNT% == 4 (
echo fourth monitor connected
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Input Director" /v MasterMonitorGrid /f /d "01/01/0/0/N/0,0,18,11,+00/" /reg:32
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Input Director" /v MasterMonitorLayout /f /d "01/04/0/0/N/18,11,36,22,+00/18,0,36,11,+01/36,2,54,19,+02/0,11,18,22,+03/" /reg:32
)
sc start InputDirector
start "inputdirector" "C:\Program Files (x86)\Input Director\InputDirector.exe" /MIN /hide
:END