Last active
January 27, 2019 12:17
-
-
Save itsumoonazicode/6677df4c4286c5637162421bda14d314 to your computer and use it in GitHub Desktop.
勤務先のポータルサイトからメールのページへ飛ぶためのスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Dim objIE | |
'オブジェクトの作成 | |
Set objIE = CreateObject("InternetExplorer.Application") | |
'IEを表示させる。Trueで表示 | |
objIE.Visible = True | |
'指定したURLを開く | |
objIE.Navigate2 "表示させたいURL" | |
'新しいタブで表示 | |
' objIE.Navigate2 "https://weather.yahoo.co.jp/weather/", &H800 | |
' objIE.Navigate2 "https://transit.yahoo.co.jp/", &H800 | |
'ページが読み込まれるまで待つ | |
Do While objIE.Busy = True Or objIE.readyState <> 4 | |
WScript.Sleep 100 | |
Loop | |
'IDとパスワードを入力する | |
With objIE.document | |
.getElementsByName("loginName")(0).Value = "値が入る" | |
.getElementsByName("password")(0).Value = "値が入る" | |
End With | |
Dim objbutton | |
'button要素をコレクションとして取得 | |
Set objbutton = objIE.document.getElementById("btn_login") | |
objbutton.click | |
'ページが読み込まれるまで待つ | |
Do While objIE.Busy = True Or objIE.readyState <> 4 | |
WScript.Sleep 100 | |
Loop | |
' 指定したURLを開く | |
objIE.Navigate2 "表示させたいURL" | |
'ページが読み込まれるまで待つ | |
Do While objIE.Busy = True Or objIE.readyState <> 4 | |
WScript.Sleep 100 | |
Loop | |
'IDとパスワードを入力する | |
With objIE.document | |
.getElementsByName("username")(0).Value = "値が入る" | |
.getElementsByName("password")(0).Value = "値が入る" | |
End With | |
Dim mailLoginBtn | |
Set mailLoginBtn = objIE.document.getElementsByClassName("signinbutton")(0) | |
mailLoginBtn.click | |
'** ファイルに書き込み処理 | |
'** str ログメッセージ | |
'** 例: logging("str") | |
'************************************************** | |
Sub logging(str) | |
Dim fso, fi | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
'ファイルを開く | |
'もしも存在しない場合には作成する | |
Set fi = fso.OpenTextFile("ログファイル名", 8, true) | |
fi.WriteLine (Date() & " " & Time() & ": " & str) 'ログを書き込む | |
Set fi = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment