|
3#
楼主 |
发表于 2014-1-8 16:52:46
|
只看该作者
sendkeys方法不能打开选择框,但是可以上传文件。
网上找了下autoit的代码,现在贴出来供大家参考:
$FileName=IniRead ( "config.ini", "ToolConfig", "FileName", "11.java" )
While 1
WinWaitActive("文件","")
If WinExists("文件") Then
ControlGetFocus("文件")
ControlFocus ( "文件", "", "" )
ControlFocus ( "文件", "", "[CLASS:ComboBox; INSTANCE:1]" )
ControlSend("文件", "", "[CLASS:ComboBox; INSTANCE:1]","桌面")
$y=ControlClick ( "文件", "", "[CLASS:ComboBox; INSTANCE:1]")
Sleep(4000)
ControlFocus ( "文件", "", "[CLASS:Edit; INSTANCE:1]" )
Send($FileName)
Sleep(2000)
$y=ControlClick ( "文件", "打开", "[CLASS:Button; INSTANCE:2]")
ExitLoop
EndIf
Wend
然后再新建一个config.ini 的文件
[ToolConfig]
FileName = 11.java
将autoit源文件生成file.exe文件,放到c盘下。
在java中调用代码为:Runtime.getRuntime().exec("c:\\file.exe").waitFor(); |
|