gpt4 book ai didi

java - 我可以在后台运行 Autoit 脚本来上传文件吗

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:09 25 4
gpt4 key购买 nike

我有一个从我的 Java 程序调用的 AutoIt 脚本,它使用 Selenium 通过 Web 应用程序加载数据。该脚本使用文件中的值上传文件,但仅当 Java 程序在前台运行时才有效。该程序很可能会在后台运行。

如何设置程序才能在后台运行时正常运行?

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}")

最佳答案

我实际上通过在命令前使用“控制”一词解决了这个问题。这是我的脚本。

#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

关于java - 我可以在后台运行 Autoit 脚本来上传文件吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36625119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com