Jump to content

CopyWink

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by CopyWink

  1. @Nine. Your code didn't work for me but thanks for the reply. But your code made me realize that I was overthinking this toggle issue from the beginning: I think the easiest way to toggle is just to assign a hotkey with the proper DPI command rather than put it in the context menu as a selection as I originally planned. Thanks again.
  2. 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
  3. I am trying ty create a a script to toggle my PC screen DPi resolution with the app "SetDpi.exe", which sets the DPI by simply entering the command: SetDpi.exe 125. If I run the command "setdpi.exe get" I get a printout of the current screen resolution, say, "Current Resolution: 150". How do I write a script that can toggle between that value and 100 dpi? I looked at the AutoIt function "$gToggleState" and I do not understand it at all. So, yes, I tried to do my research but failed.
×
×
  • Create New...