Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: need help AHK Script to change monitor mirroring/extended desktops.  (Read 1442 times)

0 Members and 1 Guest are viewing this topic.

Maximus

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1391
  • Last login:May 26, 2017, 05:32:05 pm
  • Plans are for fools!!!!
    • Arcade Icons
I know when I'm out of my depth on something and need to ask the experts, and this is a bit of a doozy.  :dizzy:

I have a 4 monitor setup on my video card...

1. 1080x1920 Primary Desktop
2. 1280x720 Extended Desktop
3. 1280x720 Extended Desktop
4. 1280x720 Extended Desktop

I would like to have an AHK script that will allow me to press one key to toggle through the following multi monitor changes for monitor 4.

a. Monitor 4 is an extended desktop
b. Monitor 4 is a duplicate of monitor 2
c. Monitor 4 is a duplicate of monitor 3

I'm using a single NVidia Video Card to drive all of these displays (Kepler based) but I don't even know if there is scripting available to make these types of changes.

I found this script for ultramon which seems like it will be helpful for the mirror switching...

Code: [Select]
Const SOURCE_MON = 2 'number of the monitor which should get mirrored
TARGET_MONS = Array(3,4) 'number of the monitor(s) the source monitor should be mirrored on
Const MIRROR_EXE = "%ProgramFiles%\UltraMon\UMMirrorClient.exe" 'path and name of the mirroring executable

Set sh = CreateObject("WScript.Shell")
umVer = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion")

val = ""
For i = 0 To UBound(TARGET_MONS)
val = val & TARGET_MONS(i) & ":" & SOURCE_MON & ";"
Next

sh.RegWrite "HKCU\Software\Realtime Soft\UltraMon\" & umVer & "\Mirroring\Monitor\Mirror Monitors", val

sh.Run """" & MIRROR_EXE & """ /start monitor"


also there is a plugin for Ultramon called MirrorMon which looks like it has some nice extra variables...

Code: [Select]
Const MONITOR = 2 'number of the monitor that should be mirrored
Const MIRRORMON_EXE = "%ProgramFiles%\UltraMon\MirrorMon.exe" 'location of MirrorMon.exe
Const POSITION = "100,100" 'position (x and y coordinates) of the MirrorMon window
Const SIZE = "400,300" 'size (width and height) of the MirrorMon window
Const OPTIONS = "" 'options for MirrorMon window: m = maximized, f = fullscreen
Const ZOOM = "100" 'zoom factor in percent

Set sys = CreateObject("UltraMon.System")
Set sh = CreateObject("WScript.Shell")
Set mon = sys.Monitors(CLng(MONITOR) - 1)
cmd = """" & MIRRORMON_EXE & """ /s 1 " & mon.HMonitor & " /w " & POSITION & "," & SIZE & "," & OPTIONS & " /z " & ZOOM
sh.Run cmd

This script is supposed to toggle mirroring on or off, but I'm not sure if it will do what I need.

Code: [Select]
Const UM_MIRROR_EXE = "%ProgramFiles%\UltraMon\UMMirrorClient.exe"

Set sh = CreateObject("WScript.Shell")
umVer = CLng(0)
str = sh.RegRead("HKLM\Software\Realtime Soft\UltraMon\CurrentVersion")
If str <> "" Then
strParts = Split(str, ".")
str = "&H"
For i = 0 To 2
num = Hex(strParts(i))
If Len(num) = 1 Then num = "0" & num
str = str & num
Next
str = str & "00"
umVer = CLng(str)
End If

If umVer >= &H03000300 Then
'3.0.3 or later
Set wnd = CreateObject("UltraMon.Window")
running = wnd.Find("UltraMonMirrorMsgWnd", "UltraMonMirrorMsgWnd", 3, 0, 0)
If running = True Then
sh.Run("""" & UM_MIRROR_EXE & """ /stop")
Else
sh.Run("""" & UM_MIRROR_EXE & """ /start lastmode")
End If
Else
'3.0.2 or earlier

If sh.Run("""" & UM_MIRROR_EXE & """ /start",, True) = 2 Then
'mirroring already running, stop it
sh.Run("""" & UM_MIRROR_EXE & """ /stop")
End If
End If

There's a bunch of super useful UltraMon scripts on this page that look very interesting for multi-monitor setups.

http://www.realtimesoft.com/ultramon/scripts/
« Last Edit: June 05, 2013, 07:11:10 pm by Maximus »