toggle_dualdisp.vbs
author Shingo W. Kagami
Thu, 21 Jan 2010 14:04:22 +0900
changeset 4 1b55a5510213
permissions -rw-r--r--
Batch files dualdisp_*.bat have been removed (and replaced by zsh aliases).
Shingo@2
     1
Dim action
Shingo@2
     2
action = "asis"
Shingo@2
     3
Shingo@2
     4
If WScript.Arguments.Count <> 1 then
Shingo@2
     5
   WScript.quit
Shingo@2
     6
End If
Shingo@2
     7
Shingo@2
     8
If WScript.Arguments.item(0) = "on" Then
Shingo@2
     9
    action = "on"
Shingo@2
    10
Else
Shingo@2
    11
    action = "off"
Shingo@2
    12
End If
Shingo@2
    13
Shingo@2
    14
Shingo@2
    15
' Dim Locator
Shingo@2
    16
' Dim Service
Shingo@2
    17
' Dim QfeSet
Shingo@2
    18
' Dim Qfe
Shingo@2
    19
Shingo@2
    20
' Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Shingo@2
    21
' Set Service = Locator.ConnectServer
Shingo@2
    22
' Set QfeSet = Service.ExecQuery("Select * From Win32_DesktopMonitor")
Shingo@2
    23
Shingo@2
    24
' Dim accum
Shingo@2
    25
' accum = 0
Shingo@2
    26
Shingo@2
    27
' If Qfeset.Count = 2 Then
Shingo@2
    28
'     For Each Qfe In QfeSet
Shingo@2
    29
'         accum = accum * 10
Shingo@2
    30
'         accum = accum + Qfe.Availability        
Shingo@2
    31
'     Next
Shingo@2
    32
'     If accum = 38 Or accum = 83 Then
Shingo@2
    33
'         action = "on"
Shingo@2
    34
'     ElseIf accum = 33 Then
Shingo@2
    35
'         action = "off"
Shingo@2
    36
'     End If
Shingo@2
    37
' End If
Shingo@2
    38
Shingo@2
    39
Dim objWsh
Shingo@2
    40
Set objWsh = WScript.CreateObject("WScript.Shell")
Shingo@2
    41
objWsh.Run "control.exe desk.cpl ,4"
Shingo@2
    42
Do Until objWsh.AppActivate("画面のプロパティ")
Shingo@2
    43
    WScript.Sleep 100
Shingo@2
    44
Loop
Shingo@2
    45
Shingo@2
    46
If action = "on" Then
Shingo@2
    47
    objWsh.SendKeys "{TAB}"
Shingo@2
    48
    objWsh.SendKeys "2"
Shingo@2
    49
    objWsh.SendKeys "{TAB 4}"
Shingo@2
    50
    objWsh.SendKeys " "
Shingo@2
    51
    objWsh.SendKeys "{UP 19}"
Shingo@2
    52
    objWsh.SendKeys "{LEFT 29}"
Shingo@2
    53
    objWsh.SendKeys "{DOWN 7}"
Shingo@2
    54
    objWsh.SendKeys "{TAB 9}"
Shingo@2
    55
    'objWsh.SendKeys "{ENTER}"
Shingo@2
    56
ElseIf action = "off" Then
Shingo@2
    57
    objWsh.SendKeys "{TAB}"
Shingo@2
    58
    objWsh.SendKeys "2"
Shingo@2
    59
    objWsh.SendKeys "{TAB 5}"
Shingo@2
    60
    objWsh.SendKeys " "
Shingo@2
    61
    objWsh.SendKeys "{TAB 8}"
Shingo@2
    62
    'objWsh.SendKeys "{ENTER}"
Shingo@2
    63
End If
Shingo@2
    64