vbsの作法 その41
概要
vbsの作法調べてみた。
練習問題やってみた。
練習問題
中学生でも、使えるrpaツールを作れ。
日本語で、IE操作して、google開け。
写真
環境
windows7 64bit
命令文
「 https://www.google.co.jp 」を開く。
「 q 」を探索。
「 マセラティ 」と入力する。
実行
命令文の意味
「 https://www.google.co.jp 」を開く。
「 q 」を探索。
「 マセラティ 」と入力する。
実行
インターネットエクスプローラーで、google開く。
インプットボックスを名前で探せ。
マセラティと打つ。
エンターしろ。
サンプルコード
Dim oIE
Dim App6
Dim Appflg
Dim sh
Set oIE = CreateObject("InternetExplorer.application")
Set App6 = Createobject("OHIcompo6.srv")
Set sh = CreateObject("WScript.Shell")
WScript.ConnectObject App6, "App6_"
App6.text = "「 https://www.google.co.jp 」を開く。" & vbcrlf & "「 q 」を探索。" & vbcrlf & "「 マセラティ 」と入力する。" & vbcrlf & "実行"
Sub waitIE
Do While oIE.busy
WScript.Sleep(1000)
Loop
Do While oIE.Document.readyState <> "complete"
WScript.Sleep(1000)
Loop
End Sub
Sub App6_exit()
Appflg = 2
End Sub
Sub App6_ok()
Dim lines
Dim n
Dim line
Dim i
oIE.Width = 800
oIE.Height = 600
oIE.Left = 10
oIE.Top = 10
oIE.AddressBar = True
oIE.MenuBar = False
oIE.StatusBar = False
oIE.Toolbar = True
oIE.Visible = True
lines = Split(App6.text, vbCrLf)
For i = 0 To UBound(lines)
If Left(lines(i), 1) = "「" Then
line = Split(lines(i), " ")
If line(2) = "」を開く。" Then
oIE.Navigate line(1)
sh.Run "%windir%\System32\rundll32.exe MouseControll.dll, _SetMouseXY@16 100, 100"
sh.Run "%windir%\System32\rundll32.exe MouseControll.dll, _LeftClick@16"
Call waitIE
End If
If line(2) = "」を探索。" Then
n = line(1)
End If
If line(2) = "」と入力する。" Then
oIE.document.getElementsByName(n)(0).value = line(1)
End If
End If
If Left(lines(i), 2) = "実行" Then
sh.SendKeys "{enter}"
End If
WScript.Sleep 1000
Next
End Sub
Do
WScript.Sleep(100)
App6.ping
Loop until Appflg = 2
Set App6 = Nothing
Set sh = Nothing
Set oIE = Nothing
Dim oIE
Dim App6
Dim Appflg
Dim sh
Set oIE = CreateObject("InternetExplorer.application")
Set App6 = Createobject("OHIcompo6.srv")
Set sh = CreateObject("WScript.Shell")
WScript.ConnectObject App6, "App6_"
App6.text = "「 https://www.google.co.jp 」を開く。" & vbcrlf & "「 q 」を探索。" & vbcrlf & "「 マセラティ 」と入力する。" & vbcrlf & "実行"
Sub waitIE
Do While oIE.busy
WScript.Sleep(1000)
Loop
Do While oIE.Document.readyState <> "complete"
WScript.Sleep(1000)
Loop
End Sub
Sub App6_exit()
Appflg = 2
End Sub
Sub App6_ok()
Dim lines
Dim n
Dim line
Dim i
oIE.Width = 800
oIE.Height = 600
oIE.Left = 10
oIE.Top = 10
oIE.AddressBar = True
oIE.MenuBar = False
oIE.StatusBar = False
oIE.Toolbar = True
oIE.Visible = True
lines = Split(App6.text, vbCrLf)
For i = 0 To UBound(lines)
If Left(lines(i), 1) = "「" Then
line = Split(lines(i), " ")
If line(2) = "」を開く。" Then
oIE.Navigate line(1)
sh.Run "%windir%\System32\rundll32.exe MouseControll.dll, _SetMouseXY@16 100, 100"
sh.Run "%windir%\System32\rundll32.exe MouseControll.dll, _LeftClick@16"
Call waitIE
End If
If line(2) = "」を探索。" Then
n = line(1)
End If
If line(2) = "」と入力する。" Then
oIE.document.getElementsByName(n)(0).value = line(1)
End If
End If
If Left(lines(i), 2) = "実行" Then
sh.SendKeys "{enter}"
End If
WScript.Sleep 1000
Next
End Sub
Do
WScript.Sleep(100)
App6.ping
Loop until Appflg = 2
Set App6 = Nothing
Set sh = Nothing
Set oIE = Nothing
以上。
Author And Source
この問題について(vbsの作法 その41), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/e71d99619da9a3375113著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .