Colleagueに、毎月やらなければならない一連の作業の自動化ができないか、と言われ
つくりました。
・自動ログイン
・指定のボタンを自動click
・id,nameのないボタンをclassでclick
・formaction有り
etc...
完璧でないところがワタシ的(笑)
最近のHPは、、、面倒な作りだな〜
いや、これが新しいということなのかもしれない。。。
by VBS ... 2018.07

=====================================================

'パスワード保存したくない人向け、入力させる
If strPassword = ”” Then
   strPassword = InputBox(”パスワードを入れてください”)
End If


'IEの起動

    Dim objIE  '変数を定義します。
    
    Dim myShell,SWC
    Set myShell = CreateObject(”Shell.Application”)
    SWC = myShell.Windows.Count
    
    
    Set objIE = WScript.CreateObject(”InternetExplorer.Application”)
    objIE.Visible = True      '可視、Trueで見えるようにします。
    
    
'処理したいページを表示します。
    objIE.Navigate ”https://xxxx.xxxx.xxx/”

'ページの表示完了を待ちます。
    While objIE.ReadyState <> 4 Or objIE.Busy = True
        WScript.Sleep  4000
    Wend

'ユーザーID(name=u)にセットする。
    Set objU = objIE.Document.getElementById(”inputのID”)
    If Not objU Is Nothing Then
   		objU.Value = (ユーザID)
   		Set objU = Nothing
	else
		MsgBox ”IEを起動しなおししてください”
		WScript.Quit
	end If






'パスワードにセットする。

	Dim objP
    Set objP = objIE.Document.getElementById(”inputのID”)
    If Not objP Is Nothing Then
	    objP.Value = (password)
    	Set objP = Nothing
	else
	end If


'********************************************
'ログインボタンを探す
'IDを持っているので「ID」 で探す


	Dim objINPUT
    Set objINPUT = objIE.document.getElementById(”buttonのID”)
    If Not objINPUT Is Nothing Then
	    objINPUT.Click
    	Set objINPUT = Nothing
	else
	end If


'ページの表示完了を待ちます。
    While objIE.ReadyState <> 4 Or objIE.Busy = True
        WScript.Sleep  4000
    Wend


'プルダウンリストより、List Customersを表示 ---> customers/listAll にjump
'
	objIE.Navigate2 ”jumpしたいURL”


'ページの表示完了を待ちます。
    While objIE.ReadyState <> 4 Or objIE.Busy = True 
            WScript.Sleep 5000
    Wend



'View のclick
    objIE.document.getElementsByClassname(”clickしたいボタンのclass”)(0).click


	
'ページの表示完了を待ちます。
    While objIE.ReadyState <> 4 Or objIE.Busy = True
        WScript.Sleep  5000
    Wend



'Pricing のclick
	Dim objRE
	Set objRE=CreateObject(”VBScript.RegExp”)
	objRE.Pattern=”比較したい文字列”
	For Each objLINK In objIE.Document.Links
 		If objRE.Test(objLINK.InnerText) Then
 			objLINK.Click
 			Exit For
 		End If
 	Next

    While objIE.ReadyState <> 4 Or objIE.Busy = True
        WScript.Sleep  10000
    Wend



' Generate Excel のclick
	Dim objA
	Dim objE
	Set objE=CreateObject(”VBScript.RegExp”)
	objE.Pattern=”比較したい文字列”
	flg=0

	Set objA = objIE.Document.getElementsByTagName(”button”)

	on error resume next

	For n = 0 To objA.Length - 1
		If objE.Test(objA(n).Text) then
			'objA(n).Click
				objIE.Navigate2 ”URL、、、formactionはformのactionより優先される”
			Exit For
		End If
	Next


'Dim objWS
'Set objWS = WScript.CreateObject(”WScript.Shell”)
'While True
'    If objWS.AppActivate(”を開く”) Then     'firefox用だった(;_;)
'        WScript.StdOut.WriteLine ”実行”
'        WScript.Sleep 500
'        objWS.SendKeys ”%(S)”
'        WScript.Sleep 500
'        objWS.SendKeys ”{ENTER}”
'    End If
'    WScript.Sleep 1000
'Wend



	On Error Goto 0