我需要运行AutoIt脚本,然后设法运行.bat文件。因为我需要excel等待这个脚本完成,但现在我需要它在一段时间后完成shell。
代码VBA
Sub FnPutDataInClipBoard()
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim TimeStep As Integer: TimeStep = 60000
Dim objData As New MSForms.DataObject
Dim strText
Dim i As Integer
i = 2
Do
strText = Cells(i, 1).Value
objData.SetText strText
objData.PutInClipboard
If Cells(i, 2).Value = "r" Then
wsh.Run ThisWorkbook.Path & "\code2.bat", windowStyle, waitOnReturn
ElseIf Cells(i, 2).Value = "R" Then
wsh.Run ThisWorkbook.Path & "\code2.bat", windowStyle, waitOnReturn
Else
wsh.Run ThisWorkbook.Path & "\code.bat", windowStyle, waitOnReturn
'Shell "cmd.exe /k cd " & ThisWorkbook.Path & "&&code.bat"
End If
i = i + 1
Loop Until Cells(i, 1).Value = ""
End Sub
Code Bat
D:
cd Program Files\autoit-v3\install
AutoIt3 "C:\Users\oi344916\Desktop\encerrar.au3"
exit
Code AutoIt
#include <AutoItConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
Local $hora = @HOUR
Local $hora1 = @HOUR
Local $min = @MIN
Local $min1 = @MIN - 1
Local $mes = @MON
Local $ano = StringRight(@YEAR,2)
Local $dia = @MDAY
Local $hDLL = DllOpen("user32.dll")
Local $i = 0
Local $s = "oi"
Local $BA = ClipGet()
WinActivate("Selecao Atividades - SGFT")
WinSetState("Selecao Atividades - SGFT","",@SW_MAXIMIZE)
;MouseMove(26,144)
MouseClick("middle",26,144,1,2)
MouseMove(1395,852)
MouseDown("LEFT")
MouseUp("LEFT")
WinWaitActive("Atencao","",3)
If WinActive("Atencao") Then
Sleep(400)
Send("{ENTER}")
Sleep(400)
MouseClick("middle",26,144,1,2)
Send("{DEL 9}")
Send("{BACKSPACE 9}")
Else
WinWaitActive("BA: "&$BA)
If WinActive("BA: "&$BA&" - CONSULTA") Then
WinSetState("[CLASS:XWinClass]","",@SW_MAXIMIZE)
Sleep(400)
Send("{ENTER}")
Else
WinSetState("BA: "&$BA,"",@SW_MAXIMIZE)
;;;;; verifica se tem uma informação
;MouseClick("left",677,354,2,2)
;MouseClick("right",696,15,1,2)
;MouseClick("left",700,203,1,2)
;MouseClick("left",946,247,1,2)
;MouseClick("left",1096,247,1,2)
;$GI = ClipGet()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; Add Tec ;;;;;;;;;;;;;;;;
Sleep(500)
If WinActive("Advertencia") Then
Send("{ENTER}")
EndIf
$yu = 0
If $yu = 1 Then
MouseClick("left",159,70,1,2)
WinWaitActive("Programar Executor - SGFT","",15)
If WinActive("Programar Executor - SGFT")=0 Then
MouseClick("left",371,110,1,2)
Send("{BACKSPACE}")
Send("m")
MouseClick("left",1395,852,1,2)
Sleep(2000)
$yu = 0
EndIf
If $yu = 1 Then
WinSetState("Programar Executor - SGFT","",@SW_MAXIMIZE)
MouseClick("left",117,228,1,2)
Send("oi344916")
Send("{ENTER}")
Send("{SPACE}")
WinWaitClose("Programar Executor - SGFT")
EndIf
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Sleep(500)
If WinActive("Advertencia") Then
Send("{ENTER}")
EndIf
Do
$rt = 1
MouseClick("left",744,109,1,2)
Sleep(400)
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Send("{BACKSPACE}")
Sleep(400)
Send("espi")
Sleep(400)
Send("{ENTER}")
$min1 = @MIN - 1
$hora1 = @HOUR - 1
If $min1 < 0 Then
$min1 = 59
EndIf
Sleep(600)
Send("p")
Sleep(300)
Send("p")
Sleep(300)
Send("+{TAB}")
Sleep(400)
Send("{DELETE}")
Sleep(400)
Send("{DELETE}")
Sleep(300)
If $min <= 10 Then
if $min1 = 59 Then
Send("+{TAB}")
Sleep(400)
Send("{DELETE}")
Sleep(400)
Send("{DELETE}")
Sleep(300)
Send($hora1)
Send($min1)
Else
Send("0")
Send($min1)
EndIf
Else
Send($min1)
EndIf
Sleep(300)
Send("p")
Sleep(300)
Send("p")
Sleep(300)
Send("{DEL 5}")
Sleep(300)
Send("{BACKSPACE 5}")
Sleep(300)
Send("01216")
$n = 16
Send("+{TAB " & $n & "}")
WinSetState("[CLASS:XWinClass]","",@SW_MAXIMIZE)
MouseMove(1395,852)
MouseDown("LEFT")
MouseUp("LEFT")
; WinSetState("[CLASS:XWinClass]","",@SW_RESTORE)
WinWaitActive("SGFT")
Send("{SPACE}")
WinWaitActive("SGFT","",8)
Send("{SPACE}")
Sleep(2000)
If WinActive("Atencao") Then
;;;;;;;; Remover Ficticio ;;;;;;;;
MouseClick("left",336,215,1,2)
Sleep(500)
MouseClick("left",187,72,1,2)
Sleep(2000)
$rt = 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndIf
Until $rt = 1
EndIf
MouseClick("left",1422,10,1,2)
WinWaitClose("BA: "&$BA)
EndIf
任何人都可以帮助我吗?