我把介面做好之後!放到按鍵精靈裡然後作成小精靈!
可是打開小精靈的時候!有個視窗跑出來說"此鍵值已被集合物件中的某元件使用"
我把VB指令和精靈裡的指令給大家看看!
Type ControlData
Name As String
Value As String
End Type
Public FormSizeCX, FormSizeCY As Long
Public Function GetControlData() As Collection
Set GetControlData = ControlDataCollection
End Function
Private Sub Image1_Click()
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub UserControl_Initialize()
FormSizeCX = Width
FormSizeCY = Height
OnInitialize
End Sub
Private Sub OnInitialize()
Combo1.ListIndex = 1
End Sub
Public Sub OnSave()
ClearControlData
SaveControlData Check1.Name, Check1
SaveControlData Check2.Name, Check2
SaveControlData Check3.Name, Check3
SaveControlData Combo1.Name, Combo1.ListIndex
SaveControlData Combo2.Name, Combo2.ListIndex
SaveControlData Combo3.Name, Combo3.ListIndex
SaveControlData Check1.Name, Text1
SaveControlData Check2.Name, Text2
SaveControlData Check3.Name, Text3
SaveControlData Check4.Name, Text4
SaveControlData Check5.Name, Text5
SaveControlData Check6.Name, Text6
SaveControlData Check7.Name, Text7
SaveControlData Check8.Name, Text8
SaveControlData Check9.Name, Text9
SaveControlData Check10.Name, Text10
SaveControlData Check11.Name, Text11
SaveControlData Check12.Name, Text12
End Sub
Public Sub OnLoad()
Check1 = LoadControlData(Check1.Name)
Check2 = LoadControlData(Check2.Name)
Check3 = LoadControlData(Check3.Name)
Combo1.ListIndex = LoadControlData(Combo1.Name)
Combo2.ListIndex = LoadControlData(Combo2.Name)
Combo3.ListIndex = LoadControlData(Combo3.Name)
Text1 = LoadControlData(Text1.Name)
Text2 = LoadControlData(Text2.Name)
Text3 = LoadControlData(Text3.Name)
Text4 = LoadControlData(Text4.Name)
Text5 = LoadControlData(Text5.Name)
Text6 = LoadControlData(Text6.Name)
Text7 = LoadControlData(Text7.Name)
Text8 = LoadControlData(Text8.Name)
Text9 = LoadControlData(Text9.Name)
Text10 = LoadControlData(Text10.Name)
Text11 = LoadControlData(Text11.Name)
Text12 = LoadControlData(Text12.Name)
End Sub
再來是模主的部分
Option Explicit
Public ControlDataCollection As New Collection
Public Sub SaveControlData(ControlName As String, ControlValue As Variant)
If VarType(ControlValue) = vbBoolean Then
ControlValue = CInt(ControlValue)
End If
Dim TempControlData As ControlData
With TempControlData
.Name = ControlName
.Value = ControlValue
End With
ControlDataCollection.Add TempControlData, ControlName
End Sub
Public Function LoadControlData(ControlName As String) As String
LoadControlData = ControlDataCollection(ControlName).Value
End Function
Public Sub ClearControlData()
On Error Resume Next
Set ControlDataCollection = Nothing
Set ControlDataCollection = New Collection
End Sub
再來是精靈裡的!
//-----------------------使用者定義----------------------
UserVar Text1=FFFFFF
UserVar Text2=FFFFFF
UserVar Text3=FFFFFF
UserVar Combo1=DropList{無|112|113|114|115|116|117|118|119|120|121}=0
UserVar Combo2=DropList{無|112|113|114|115|116|117|118|119|120|121}=0
UserVar Combo3=DropList{無|112|113|114|115|116|117|118|119|120|121}=0
UserVar Text4=100
UserVar Text5=100
UserVar Text6=100
UserVar Text7=00
UserVar Text8= 00
UserVar Text9=FFFFFF
UserVar Text10=00
UserVar Text11=00
UserVar Text12=FFFFFF
// -----------------------主程式開始----------------------------------
Rem start
// 在範圍搜尋怪物 ,找怪的顏色,並將鼠標移至怪物,進行打怪
VBSCall FindCenterColor(0,0,800,600,Text1,x,y)
If x>=0 and y>=0
MoveTo x y
LeftDoubleClick 1
Gosub 打怪
VBS ts=ts+1
EndIf
VBSCall FindCenterColor(0,0,800,600,Text2,x,y)
If x>=0 and y>=0
MoveTo x y
LeftDoubleClick 1
Gosub 打怪
VBS ts=ts+1
EndIf
VBSCall FindCenterColor(0,0,800,600,Text3,x,y)
If x>=0 and y>=0
MoveTo x y
LeftDoubleClick 1
Gosub 打怪
VBS ts=ts+1
EndIf
Goto start
// ----------------副程序--------------------
Sub 打怪
Rem 怪物血條
// 按滑鼠左鍵打2下怪
KeyPress 49,1
Delay 500
KeyPress Comdo1,1
Delay Text 4
KeyPress Combo2,1
Delay Text 5
KeyPress Combo3,1
Delay Text 6
Gosub 補血
// 怪物血條
IfColor 346,37,8585E5,2
Goto 怪物血條
EndIf
Return 打怪
Sub 補血
IfColor Text7,Text8,Text9,2
// 按鍵3
KeyPress 51,1
EndIf
Return 補藍
IfColor Text10,Text11,Text12,2
// 按鍵4
KeyPress 52,1
EndIf
Return
想請高手幫我看看! |