如果您可以将 Excel 文件转换为以行分隔的文本文件,那么这很容易通过将文件读取到数组中来实现,然后在 while 循环中根据数组值操作数据。
例子:
Links.txt
www.google.com
www.facebook.com
www.youtube.com
www.tumblr.com
www.amarokstudios.com
OpenLinks.au3
#include <file.au3>
; Create an empty array to store the links later on in the script.
DIM $aArray
; Read you Links.txt file to an array, if there is an error, display an error message.
If _FileReadToArray(@ScriptDir & "\Links.txt", $aArray) then
Else
MsgBox(0,"Error","An error occurred trying to read your file to an array!")
EndIf
; Now, all of the links should be stored in the array called "$aArray". The size of the array is stored in $aArray[0], the first link is in $aArray[1], second in $aArray[2], and so on.
; Now, we are going to declare the starting size of the array, so the loop knows how many times to run the code.
$i = $aArray[0]
; Next, we will declare the link to start on. Since the first link is stored in $aArray[1], we will set the value to 1.
$link = 1
; Now we will create a while loop that will run while the array size is larger than zero.
While $i > 0
; Open the Windows RUN box
Send("#r")
Sleep(250)
; Send the value of $aArray[$link]. Since we previously set $link equal to 1, it will send the value of $aArray[1], which as we said earlier, would contain the first link on our list.
Send($aArray[$link])
; Send the enter key
Send("{ENTER}")
; Sleep for 1 second to prevent code from overlapping itself
Sleep(1000)
#CS
You can put code here to manipulate the data on each website. There are many different ways to do this. For example, if the location for each piece of data is the same, you could simple write one script here that will execute each time a new page loads.
Another method is to create an if statement to check which website is currently loaded, then writing the logic For each page. Tedious, but well worth it if you are going to be doing this for the same pages.
#CE
; Add the value of 1 to the current link variable so the script can move on to the next link. For example, the first value of $aArray[$link] was equal to $aArray[1], but adding 1 to it would change $aArray[$link] to $aArray[2]
$link += 1
; Subtract 1 from the total array size so the loop knows how many more times to execute.
$i -= 1
; End the loop
WEnd
这里是没有 cmets 的代码,所以你可以看看它是如何工作的。
#include <file.au3>
Dim $aArray
If _FileReadToArray(@ScriptDir & "\Links.txt",$aArray) then
Else
MsgBox(0,"Error","Error from Function")
EndIf
$i = $aArray[0]
$link = 1
while $i > 0
Send("#r")
Sleep(250)
Send($aArray[$link])
Send("{Enter}")
Sleep(1000)
; Your code to manipulate data here
$link += 1
$i -= 1
WEnd
我知道这并不能具体回答您的问题,但我希望它为您提供了一个合理的选择。使用这种方法,您无需下载任何 UDF,而且代码非常短。
如果您有任何问题,请随时告诉我。我不介意帮助你解决这个问题,直到它适合你!