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