VBScript自动编程文件上传 [英] VBScript Autoit programming file upload
问题描述
$ files1 =C:\TeamBuilding\Team Games .jpg
$ files2 =C:\TeamBuilding\Team Prayer.jpg
$ oIE.getelementbyid(file)。upload $ files1,$ files2
然后在图片上传之后,表单被提交。显然上面的代码是一个幻想:D我只需要脚本部分上传图片,而不是点击上传按钮。我的Autoit脚本将修改此表单的innerHTML以添加用于自动上传的脚本。这是可行的吗?
总结:不要点击上传文件按钮,我想要一个脚本来上传某些.jpg文件。现在我正在做的是手动点击上传文件按钮,然后选择所有的JPEG文件。有人建议一个脚本,将点击上传按钮,然后键入每个图像的路径,但我已经尝试过这些,是一个头痛,我要求在VB脚本(因为Autoit似乎是VBScript语言)。一旦我得到这个脚本,我会做的只是修改我公司网站的innerHTML,而不是简单的< input type =filename =filemultiple => / code>它会自动上传图片而无需用户手动放置图片
这是你开始的地方。
$ $ p $ #RequireAdmin;将为您的脚本提供权限提升(有时需要)
#include < IE.au3>
Opt(WinTitleMatchMode,2); 1 =开始,2 = subStr,3 =精确,4 =高级,-1至-4 = Nocase
Opt(WinSearchChildren,1); 0 = no,1 =也搜索孩子
$ oIE = _IEAttach(MyUploadPageTitle,windowtitle);获取文件输入字段的对象
$ b _IEAction($ oInputFile,focus)
$($ o $,$ file) b $ b $ hIE = _IEPropertyGet($ oIE,hwnd)
ControlSend($ hIE,,Internet Explorer_Server1,)
WinWait(Choose File, ,30)
Sleep(1000)
WinActivate(选择文件)
ControlSetText(选择文件,,[CLASS:Edit; INSTANCE:1], (FileToUpload)
Sleep(1000)
WinActivate(选择文件)
ControlSend(选择文件,,,{ENTER})
WinWaitClose(选择文件,,5)
...
Hi guys, our company's website has this file upload button for uploading multiple images. How can I create a script that automatically selects the images then uploads them? I already know the path of each images on the client's PC. I just don't want to script a click on the file upload button since I get a headache trying to make that work. My current goal is to script it in Autoit with something like:
$files1 = "C:\TeamBuilding\Team Games.jpg"
$files2 = "C:\TeamBuilding\Team Prayer.jpg"
$oIE.getelementbyid("file").upload $files1, $files2
Then after the image upload the form is submitted. Obviously the code above is a fantasy :D I just need the part to script uploading the images instead of clicking the upload button. My Autoit script will modify the innerHTML of this form to add the script for auto-upload. Is this doable?
Summary: Instead of clicking the "Upload File" button I want a script to upload certain .jpg files. Right now what I'm doing is manually clicking the "Upload File" button then selecting all the JPEG files. Somebody suggested a script that will click the upload button then types the path of each images but I already tried those, was a headache, I'm asking for a script in VB (since Autoit seem to be VBScript language). Once I get that script, what I will do is just modify the innerHTML of my company's site so instead of a plain <input type="file" name="file" multiple="">
it will automatically upload the pictures without having the user manually placed the pictures
This is where you start.
#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
#include <IE.au3>
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
$oIE = _IEAttach("MyUploadPageTitle","windowtitle"); do _IEAttach()
oInputFile = _IEGetObjByName($oIE, "file");get an object of a file input field
_IEAction($oInputFile, "focus")
$hIE = _IEPropertyGet($oIE, "hwnd")
ControlSend($hIE, "", "Internet Explorer_Server1", " ")
WinWait("Choose File", "", 30)
Sleep(1000)
WinActivate("Choose File")
ControlSetText("Choose File", "", "[CLASS:Edit; INSTANCE:1]", $FileToUpload )
Sleep(1000)
WinActivate("Choose File")
ControlSend("Choose File", "", "", "{ENTER}")
WinWaitClose("Choose File", "", 5)
...
这篇关于VBScript自动编程文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!