VBScript Autoit 编程文件上传 [英] VBScript Autoit programming file upload

查看:24
本文介绍了VBScript Autoit 编程文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我们公司的网站有上传多张图片的文件上传按钮.如何创建自动选择图像然后上传它们的脚本?我已经知道客户端 PC 上每个图像的路径.我只是不想编写单击文件上传按钮的脚本,因为我在尝试使其工作时感到头疼.我目前的目标是在 Autoit 中编写如下脚本:

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:TeamBuildingTeam Games.jpg"
$files2 = "C:TeamBuildingTeam Prayer.jpg"
$oIE.getelementbyid("file").upload $files1, $files2

然后在图像上传后提交表单.显然,上面的代码是一个幻想:D 我只需要编写上传图像的脚本部分,而不是单击上传按钮.我的 Autoit 脚本将修改此表单的 innerHTML 以添加用于自动上传的脚本.这可行吗?

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?

总结:我想要一个脚本来上传某些 .jpg 文件,而不是点击上传文件"按钮.现在我正在做的是手动单击上传文件"按钮,然后选择所有 JPEG 文件.有人建议了一个脚本,该脚本将单击上传按钮然后键入每个图像的路径,但我已经尝试过这些,很头疼,我在 VB 中要求一个脚本(因为 Autoit 似乎是 VBScript 语言).一旦我得到那个脚本,我要做的就是修改我公司网站的innerHTML,而不是简单的<input type="file" name="file" multiple="">它会自动上传图片,无需用户手动放置图片

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

推荐答案

这是你的起点.

        #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 Autoit 编程文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆