OK. I managed to come up with the script, below, after reading StdoutRead function. But I'm getting the error "subscript used on non accessible variable". in line 24 even though it checks out in Autoit's syntax check function.
#RequireAdmin
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
Local $setdpiPath = "C:\Bin\Scripts\AU3\SetDpi.exe"
Local $currentDPI = 100
Local $toggleDPI = 150
While 1
$currentDPI = ToggleDPI($setdpiPath, $currentDPI, $toggleDPI)
MsgBox($MB_ICONINFORMATION, "DPI Changed", "Current DPI: " & $currentDPI)
Sleep(3000)
WEnd
Func ToggleDPI($exePath, $current, $toggle)
Local $cmd, $pid, $output
; Get current DPI
$pid = Run(@ComSpec & " /c " & $exePath & " get", "", @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($pid)
$output = StdoutRead($pid)
; Extract current DPI from output
$current = Number(StringRegExp($output, "Current Resolution: (\d+)", 1)[0] ? StringRegExp($output, "Current Resolution: (\d+)", 1)[0] : $current)
; Toggle DPI
If $current == 100 Then
$cmd = $exePath & " " & $toggle
$current = $toggle
Else
$cmd = $exePath & " 100"
$current = 100
EndIf
$pid = Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($pid)
Return $current
EndFunc