我有一个AutoIt脚本,我从我的Java程序调用,它使用Selenium通过Web应用程序加载数据。该脚本用于使用文件中的值上载文件,但仅限于Java程序在前台运行时。这个程序很可能会在后台运行。
如何设置它以便在后台运行时程序可以正常工作?
爪哇:
Thread.sleep(2000); // wait for page load
Runtime.getRuntime().exec("C:\\Users\\Janet\\Documents\\uploadFile.exe " + uploadFile);
的AutoIt:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe
#AutoIt3Wrapper_Outfile_x64=C:\Users\Janet\Documents\uploadFile_x64a.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
ControlFocus("File Upload","","Edit1"); Name of the file upload window (Windows Popup Name: Open)
ControlSetText("File Upload","","Edit1",$CmdLineRaw); File name
Send("{ENTER}")
答案 0 :(得分:1)
我实际上是通过在命令之前使用Control这个词解决了这个问题。这是我的剧本。
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe
#AutoIt3Wrapper_Outfile_x64=C:\Users\Janet\Documents\uploadFile_x64a.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
;* Script Name: uploadFile.au3
;* Author: Janet Frank
;* Date Created: 04/04/16
;* Description:
;* This script receives a file name from a Java program that needs to upload a file for the purpose
;* of a profile image or an asset to the VTS site. The file name is passed from the Java program
;* via the command line used to execute this script. Using the $CmdLineRaw function the program can
;* extract that file name from the command line.
;
ControlFocus("File Upload","","Edit1"); Name of the file upload window (Windows Popup Name: File Upload)
ControlSetText("File Upload","","Edit1",$CmdLineRaw); File name passed from Java program
ControlSend("File Upload","","Button1","{Enter}") ;Press the Enter key whe on the Open button to exit the file explorer.
Exit