Dim $1, $2, $3, $4, $5, $6, $i, $s
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <Excel.au3>
#include <ButtonConstants.au3> ;按钮框的样式
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form1.kxf
$Form1_1 = GUICreate("核算工具", 185, 210, 281, 167)
$Input1 = GUICtrlCreateInput("", 68, 60, 109, 21)
$Label1 = GUICtrlCreateLabel("结算表格:", 8, 66, 60, 17)
$Label2 = GUICtrlCreateLabel("方向:", 8, 97, 40, 17)
$Label7 = GUICtrlCreateLabel("方向:", 8, 157, 40, 17)
$Combo1 = GUICtrlCreateCombo(" ", 48, 91, 41, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "左|右")
$Combo2 = GUICtrlCreateCombo(" ", 48, 153, 41, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "左|右")
$Label4 = GUICtrlCreateLabel("工单表格:", 8, 128, 60, 17)
$Input3 = GUICtrlCreateInput("", 68, 122, 109, 21)
$Label3 = GUICtrlCreateLabel("F1为电话", 53, 8, 73, 17)
$Label5 = GUICtrlCreateLabel("` 为注册", 53, 24, 76, 17)
$Label6 = GUICtrlCreateLabel("F2为姓名", 53, 40, 76, 17)
$Label8 = GUICtrlCreateLabel("次数:", 98, 97, 40, 17)
$Label9 = GUICtrlCreateLabel("次数:", 98, 157, 40, 17)
$Input2 = GUICtrlCreateInput("", 135, 91, 41, 21) ;输出次
$Input4 = GUICtrlCreateInput("", 135, 153, 41, 21) ;输入次
$stop = GUICtrlCreateButton("停止(&T)", 55, 180, 81, 23, 1)
GUICtrlSetState($stop, $GUI_HIDE)
$go = GUICtrlCreateButton("开始(&S)", 55, 180, 81, 23, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label1
Case $Label2
Case $Label3
Case $go
go()
Case $stop
stop()
EndSwitch
WEnd
Func go()
$1 = GUICtrlRead($Input1)
$2 = GUICtrlRead($Input2)
$3 = GUICtrlRead($Input3)
$4 = GUICtrlRead($Input4)
If GUICtrlRead($Combo1) = "左" Then
$5 = "left"
ElseIf GUICtrlRead($Combo1) = "右" Then
$5 = "right"
ElseIf GUICtrlRead($Combo1) = " " Then
$5 = " "
EndIf
If GUICtrlRead($Combo2) = "左" Then
$6 = "left"
ElseIf GUICtrlRead($Combo2) = "右" Then
$6 = "right"
ElseIf GUICtrlRead($Combo2) = " " Then
$6 = " "
EndIf
GUICtrlSetState($Input1, $GUI_DISABLE)
GUICtrlSetState($Input2, $GUI_DISABLE)
GUICtrlSetState($Input3, $GUI_DISABLE)
GUICtrlSetState($Input4, $GUI_DISABLE)
GUICtrlSetState($Combo1, $GUI_DISABLE)
GUICtrlSetState($Combo2, $GUI_DISABLE)
GUICtrlSetState($go, $GUI_HIDE)
GUICtrlSetState($stop, $GUI_SHOW + $GUI_FOCUS)
HotKeySet("{F2}", "gui")
WinSetState("核算工具", "", @SW_MINIMIZE)
EndFunc ;==>go
Func stop()
GUICtrlSetState($Input1, $GUI_ENABLE)
GUICtrlSetState($Input2, $GUI_ENABLE)
GUICtrlSetState($Input3, $GUI_ENABLE)
GUICtrlSetState($Input4, $GUI_ENABLE)
GUICtrlSetState($Combo1, $GUI_ENABLE)
GUICtrlSetState($Combo2, $GUI_ENABLE)
GUICtrlSetState($go, $GUI_SHOW)
GUICtrlSetState($stop, $GUI_HIDE)
HotKeySet("{F2}")
EndFunc ;==>stop
Func gui()
$i = 1
$S = InputBox("次数提示", "请输入查询总数")
Local $sFilePath1 = @ScriptDir & "" & $1 ;此文件应该已存在
Local $oExce1 = _ExcelBookOpen($sFilePath1)
Local $sFilePath2 = @ScriptDir & "" & $3 ;此文件应该已存在
Local $oExce2 = _ExcelBookOpen($sFilePath2)
Sleep(1500)
While $i <= $S
Sleep(500)
Local $sCellValue = _ExcelReadCell($oExce1, $i +19, 2)
Send("^f")
Send($sCellValue)
Send("!f")
WinActivate($3)
Sleep(500)
If WinExists("Microsoft Excel", "Microsoft Office Excel 找不到正在搜索的数据") = 1 Then
Send("{space}")
Sleep(200)
Send("{esc}")
Sleep(500)
WinActivate($1)
Else
Sleep(500)
Send("{esc}")
Sleep(200)
Send("{" & $6 & " " & $4 & "}")
Sleep(500)
; Local $sCellValue2 = _ExcelReadCell($oExce2,,6,)
Sleep(200)
Send("^c")
Local $sCellValue2 = Send("^c")
Sleep(500)
WinActivate($1)
Sleep(500)
_ExcelWriteCell($oExce1, $sCellValue2, $i +19, 4)
Sleep(500)
EndIf
Sleep(200)
Sleep(200)
$i = $i + 1
If $i > $S Then
MsgBox(4096, "操作完成", "已操作 " & $S & " 次")
EndIf
WEnd
EndFunc ;==>gui