#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=E:\play.ico
#AutoIt3Wrapper_Res_Comment=辅助程序
#AutoIt3Wrapper_Res_Description=挂机测试程序
#AutoIt3Wrapper_Res_Fileversion=1.2.0.0
#AutoIt3Wrapper_Res_LegalCopyright=AnYe
#AutoIt3Wrapper_Run_Before=del /f /q %SystemRoot%\system32\drivers\x.ahc
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
HotKeySet("{F9}","Star")
HotKeySet("{F10}","Stop")
Opt("TrayAutoPause",0)
Opt("TrayOnEventMode",1)
Dim $CdHawdS
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Name = IniRead("LT.ini", "LT", "Name", "")
$Win = GUICreate("挂机测试程序 Ver 1.2.0.0", 564, 160, 192, 114)
$Group1 = GUICtrlCreateGroup("设置:", 8, 16, 537, 121)
$Label1 = GUICtrlCreateLabel("游戏窗口名称", 24, 40, 76, 17)
$Input1 = GUICtrlCreateInput($Name, 24, 64, 505, 17)
$CdHawd = GUICtrlCreateButton("点此选择", 464, 40, 65, 17, $WS_GROUP)
$Save = GUICtrlCreateButton("保存", 168, 96, 65, 25, 0, $WS_GROUP)
$Exit = GUICtrlCreateButton("退出", 288, 96, 73, 25, 0, $WS_GROUP)
$Label8 = GUICtrlCreateLabel("保存后,按 F9 启动, F10 暂停", 168, 144, 196, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Stop()
Func Stop()
$Stop = 0
WinSetState($Win,"",@SW_RESTORE)
WinSetOnTop($Win,"",0)
If $CdHawdS=1 Then
TrayTip('提示信息', '获取游戏窗口名称完毕', 3)
$CdHawdS=0
Else
TrayTip('提示信息', '程序处于暂停状态,按热键"F9"启动', 3)
EndIf
While 1
$msg = GUIGetMsg()
If $msg = $Exit Or $msg = $GUI_EVENT_CLOSE then
Exit
EndIf
if $msg=$Save then
$Name= GUICtrlRead($Input1)
IniWrite("LT.ini", "LT", "Name", $Name)
EndIf
If $msg=$CdHawd Then
WinSetOnTop($Win,"",1)
$CdHawdS=1
While 1
TrayTip('提示信息', '鼠标左键点击要获取的窗口或让要获取的窗口处于激活状态',20)
$Name=WinGetTitle("")
sleep(100)
If $Name<>"挂机测试程序 Ver 1.2.0.0" Then GUICtrlSetData($Input1,$Name)
WEnd
EndIf
WEnd
EndFunc
Func Star()
WinSetState($Win,"",@SW_MINIMIZE)
TrayTip('提示信息', '程序已启动,按热键"F10"中止', 3)
$Name = GUICtrlRead($Input1)
WinActivate($Name,"")
ControlSend($Name, "", "", "{TAB}")
Sleep(200)
ControlSend($Name, "", "", "{3}")
Sleep(1000)
ControlSend($Name, "", "", "{1}")
Sleep(1000)
ControlSend($Name, "", "", "{2}")
Sleep(2000)
ControlSend($Name, "", "", "{3}")
Sleep(1000)
ControlSend($Name, "", "", "{1}")
Sleep(100)
$Stop = 1
While 1
While $Stop
For $I = 1 To 4
If Not $Stop Then ExitLoop 5
ControlSend($Name, "", "", "{TAB}")
Sleep(100)
ControlSend($Name, "", "", "{3}")
Sleep(100)
ControlSend($Name, "", "", "{1}")
Sleep(1000)
ControlSend($Name, "", "", "{2}")
Sleep(3000)
ControlSend($Name, "", "", "{3}")
Sleep(1000)
ControlSend($Name, "", "", "{1}")
Sleep(1000)
ControlSend($Name, "", "", "{` down}")
Sleep(2000)
ControlSend($Name, "", "", "{` up}")
Next
WinActivate($Name,"")
ControlSend($Name, "", "", "{TAB}")
Sleep(100)
ControlSend($Name, "", "", "{1}")
Sleep(200)
ControlSend($Name, "", "", "{2}")
Sleep(200)
ControlSend($Name, "", "", "{3}")
Sleep(200)
ControlSend($Name, "", "", "{1}")
Sleep(200)
ControlSend($Name, "", "", "{` down}")
Sleep(1000)
ControlSend($Name,"","","{` up}")
Sleep(200)
WEnd
WEnd
EndFunc
上面有重复的代码,还没精简,哪位老师帮我优化一下啊