📄 mod03pubfun.bas
字号:
Attribute VB_Name = "Mod03PubFun"
Option Explicit
''改变窗口标题
Sub ChangeCaption()
On Error Resume Next
Dim srnd As Long, Strk As String, sl As Long, mstr As String
Strk = "abcdefghijklmnopqrstuvwxyzABCDEFGHIGJKLMNOPQRSTUVWXYZ1234567890"
sl = Len(Strk)
Dim i As Long, n As Long
Randomize
n = Int(Rnd(1) * 10) + 10
For i = 0 To n
Randomize
srnd = Int(Rnd(1) * sl)
If srnd >= 1 And srnd <= sl Then mstr = mstr & Mid(Strk, srnd, Int(Rnd(2)) + 1)
Next i
Main.Caption = mstr
End Sub
''遍历窗口
Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Boolean
On Error Resume Next
Dim TempWinName As String, TempPartName As String
TempWinName = String(80, 0)
Call GetWindowText(hWnd, TempWinName, 80)
TempWinName = Left(TempWinName, InStr(TempWinName, Chr(0)) - 1)
If Len(TempWinName) > 0 And UCase(TempWinName) = GameTitle Then
Main.List0(0).AddItem hWnd
TempPartName = ReadPartName(hWnd)
If Len(TempPartName) > 0 Then
Main.CboManName.AddItem TempPartName
End If
End If
EnumWindowsProc = True
End Function
''等待
Function Wait(mtime As Long) As Long
On Error Resume Next
If mtime = 0 Then Wait = 0: Exit Function
Dim Savetime As Double
Savetime = timeGetTime '记下开始时的时间
DoEvents
While timeGetTime < Savetime + mtime '循环等待
DoEvents '转让控制权,以便让操作系统处理其它的事件。
Sleep 1
DoEvents
Wend
Wait = 1
End Function
''去除尾部chr$(0)函数
Function KillChr0(Ans As String) As String
On Error Resume Next
Dim i As Long
i = InStr(Ans, vbNullChar)
If i Then
KillChr0 = Left$(Ans, i - 1)
Else
KillChr0 = Ans
End If
End Function
''浮点转整形
Function Float2Int(Ans As Single) As Long
On Error Resume Next
CopyMemory Float2Int, Ans, 4
End Function
'判断方向
Function cDirection(cWayX As Integer, cWayY As Integer) As String
On Error Resume Next
Dim cWay As String
cWay = "←↑→↓↖↗↘↙"
If cWayX > 0 Then
If cWayY > 0 Then
cWay = "↙"
ElseIf cWayY = 0 Then
cWay = "←"
Else
cWay = "↖"
End If
ElseIf cWayX = 0 Then
If cWayY > 0 Then
cWay = "↓"
ElseIf cWayY = 0 Then
cWay = "·"
Else
cWay = "↑"
End If
Else
If cWayY > 0 Then
cWay = "↘"
ElseIf cWayY = 0 Then
cWay = "→"
Else
cWay = "↗"
End If
End If
cDirection = cWay
End Function
''获取指定Npc信息
Function SeleNpcInfo(NpcName As String, Item As String) As String
On Error Resume Next
Dim i As Integer, TempNpcName As String, TempItem As String
ReadNpcInfo (1)
Wait 200
For i = 1 To Main.LVNpc(1).ListItems.Count
TempNpcName = Trim(Main.LVNpc(1).ListItems.Item(i).SubItems(Main.LVNpc(1).ColumnHeaders("Name").SubItemIndex))
If InStr(TempNpcName, NpcName) > 0 Then
TempItem = Trim(Main.LVNpc(1).ListItems.Item(i).SubItems(Main.LVNpc(1).ColumnHeaders(Item).SubItemIndex))
End If
Next i
SeleNpcInfo = TempItem
End Function
''开始按钮
Sub ComStart(StartOrStop As String)
On Error Resume Next
Select Case StartOrStop
Case "开始"
Main.ComMain(2).Caption = "停止"
Main.ComLuck(0).Enabled = False
Main.ComScript(2).Enabled = False
Main.CboManName.Enabled = False
Main.ComMain(0).Enabled = False
Main.TimeOnHook.Enabled = True
Main.TimeBuff.Enabled = True
Main.TimeNpc.Enabled = True
ReadTaskList "Task", "Task"
Main.LVPick(4).ListItems.Clear
Case "停止"
Main.ComMain(2).Caption = "开始"
Main.ComLuck(0).Enabled = True
Main.ComScript(2).Enabled = True
Main.CboManName.Enabled = True
Main.ComMain(0).Enabled = True
Main.TimeOnHook.Enabled = False
Main.TimeScript.Enabled = False
Main.TimeBuff.Enabled = False
Main.TimeNpc.Enabled = False
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -