Add scripts to control displays.
authorShingo W. Kagami
Thu, 21 Jan 2010 07:18:34 +0900
changeset 25ba7dd492647
parent 1 65d4a4dbb3e5
child 3 76409631fed5
Add scripts to control displays.
dualdisp_off.bat
dualdisp_on.bat
toggle_dualdisp.vbs
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dualdisp_off.bat	Thu Jan 21 07:18:34 2010 +0900
     1.3 @@ -0,0 +1,1 @@
     1.4 +wscript C:\cygwin\home\swk\bin\toggle_dualdisp.vbs off
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/dualdisp_on.bat	Thu Jan 21 07:18:34 2010 +0900
     2.3 @@ -0,0 +1,1 @@
     2.4 +wscript C:\cygwin\home\swk\bin\toggle_dualdisp.vbs on
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/toggle_dualdisp.vbs	Thu Jan 21 07:18:34 2010 +0900
     3.3 @@ -0,0 +1,64 @@
     3.4 +Dim action
     3.5 +action = "asis"
     3.6 +
     3.7 +If WScript.Arguments.Count <> 1 then
     3.8 +   WScript.quit
     3.9 +End If
    3.10 +
    3.11 +If WScript.Arguments.item(0) = "on" Then
    3.12 +    action = "on"
    3.13 +Else
    3.14 +    action = "off"
    3.15 +End If
    3.16 +
    3.17 +
    3.18 +' Dim Locator
    3.19 +' Dim Service
    3.20 +' Dim QfeSet
    3.21 +' Dim Qfe
    3.22 +
    3.23 +' Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
    3.24 +' Set Service = Locator.ConnectServer
    3.25 +' Set QfeSet = Service.ExecQuery("Select * From Win32_DesktopMonitor")
    3.26 +
    3.27 +' Dim accum
    3.28 +' accum = 0
    3.29 +
    3.30 +' If Qfeset.Count = 2 Then
    3.31 +'     For Each Qfe In QfeSet
    3.32 +'         accum = accum * 10
    3.33 +'         accum = accum + Qfe.Availability        
    3.34 +'     Next
    3.35 +'     If accum = 38 Or accum = 83 Then
    3.36 +'         action = "on"
    3.37 +'     ElseIf accum = 33 Then
    3.38 +'         action = "off"
    3.39 +'     End If
    3.40 +' End If
    3.41 +
    3.42 +Dim objWsh
    3.43 +Set objWsh = WScript.CreateObject("WScript.Shell")
    3.44 +objWsh.Run "control.exe desk.cpl ,4"
    3.45 +Do Until objWsh.AppActivate("画面のプロパティ")
    3.46 +    WScript.Sleep 100
    3.47 +Loop
    3.48 +
    3.49 +If action = "on" Then
    3.50 +    objWsh.SendKeys "{TAB}"
    3.51 +    objWsh.SendKeys "2"
    3.52 +    objWsh.SendKeys "{TAB 4}"
    3.53 +    objWsh.SendKeys " "
    3.54 +    objWsh.SendKeys "{UP 19}"
    3.55 +    objWsh.SendKeys "{LEFT 29}"
    3.56 +    objWsh.SendKeys "{DOWN 7}"
    3.57 +    objWsh.SendKeys "{TAB 9}"
    3.58 +    'objWsh.SendKeys "{ENTER}"
    3.59 +ElseIf action = "off" Then
    3.60 +    objWsh.SendKeys "{TAB}"
    3.61 +    objWsh.SendKeys "2"
    3.62 +    objWsh.SendKeys "{TAB 5}"
    3.63 +    objWsh.SendKeys " "
    3.64 +    objWsh.SendKeys "{TAB 8}"
    3.65 +    'objWsh.SendKeys "{ENTER}"
    3.66 +End If
    3.67 +