'-----------------------------------------
' 全局变量
'-----------------------------------------
Dim User(6)' 最多 7 个输入框
'-----------------------------------------
' 窗体加载事件
'-----------------------------------------
Sub Form1_Load()
' 初始化输入框
' 按键精灵不支持循环访问控件,所以每个控件单独写
Form1.InputBox1.Text = ""
Delay 50
Form1.InputBox1.SetCueBanner "请输入 TG用户名"
Form1.InputBox2.Text = ""
Delay 50
Form1.InputBox2.SetCueBanner "可选"
Form1.InputBox3.Text = ""
Delay 50
Form1.InputBox3.SetCueBanner "可选"
Form1.InputBox4.Text = ""
Delay 50
Form1.InputBox4.SetCueBanner "可选"
Form1.InputBox5.Text = ""
Delay 50
Form1.InputBox5.SetCueBanner "可选"
Form1.InputBox6.Text = ""
Delay 50
Form1.InputBox6.SetCueBanner "可选"
Form1.InputBox7.Text = ""
Delay 50
Form1.InputBox7.SetCueBanner "可选"
End Sub
'-----------------------------------------
' 启动按钮事件
'-----------------------------------------
Event Form1.Button1.Click
Dim idx
idx = 0
' 检查输入框1是否为空
If Trim(Form1.InputBox1.Text) = "" Then
MsgBox "请先在第一个输入框输入内容!"
Exit Event
End If
' 收集输入框内容
If Trim(Form1.InputBox1.Text) <> "" Then
User(idx) = Form1.InputBox1.Text
idx = idx + 1
End If
If Trim(Form1.InputBox2.Text) <> "" Then
User(idx) = Form1.InputBox2.Text
idx = idx + 1
End If
If Trim(Form1.InputBox3.Text) <> "" Then
User(idx) = Form1.InputBox3.Text
idx = idx + 1
End If
If Trim(Form1.InputBox4.Text) <> "" Then
User(idx) = Form1.InputBox4.Text
idx = idx + 1
End If
If Trim(Form1.InputBox5.Text) <> "" Then
User(idx) = Form1.InputBox5.Text
idx = idx + 1
End If
If Trim(Form1.InputBox6.Text) <> "" Then
User(idx) = Form1.InputBox6.Text
idx = idx + 1
End If
If Trim(Form1.InputBox7.Text) <> "" Then
User(idx) = Form1.InputBox7.Text
idx = idx + 1
End If
'--------------------------------------------
' 创建目录
Dim workDir
workDir = "C:\test_game"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(workDir) Then
fso.CreateFolder (workDir)
Delay 1000
End If
Delay 500
'--------------------------------------------
' 释放附件
PutAttachment workDir, "*.*"
PutAttachment AppPath & "\Plugin", "RegDll.dll"
PutAttachment AppPath & "\Plugin", "dm.dll"
' 大漠操作函数
'-----------------------------------------
Dim hwnd, x, y, sizeY, i, dm
'-----------------------------------------
' 大漠插件初始化
'-----------------------------------------
' 注册 DLL
Plugin.RegDll.Reg workDir & "\RegDll.dll"
Plugin.RegDll.Reg workDir & "\dm.dll"
' 创建 dm 对象
Set dm = CreateObject("dm.dmsoft")
'判断是否创建dm成功
If dm Is Nothing Then
MessageBox "创建大漠对象失败,无法执行!"
End If
x = 0
y = 239
sizeY = 800
For i = 0 To 6
If Trim(User(i)) <> "" Then
hwnd = dm.FindWindow("Qt51515QWindowIcon", User(i))
Delay 500
If hwnd > 0 Then
dm.BindWindow hwnd, "gdi2", "windows3", "windows", 101
Delay 200
Plugin.Window.Move hwnd, x, y
Delay 100
Plugin.Window.Size hwnd, 605, sizeY
Delay 50
'鼠标移动过去激活窗口
MoveTo x, y
Delay 50
LeftClick 1
Else
Call Plugin.Msg.Tips("未找到窗口")
Delay 1000
End If
x = x + 65
y = y - 30
sizeY = sizeY + 30
Else
Call Plugin.Msg.Tips("判断失败未循环")
Delay 1000
End If
Next
End Event
我的代码 为什么在调试的时候 可以正常使用,只要打包成小精灵 就无法运行了,点击启动完全没有反应 我加了弹窗提示 发现执行创建大漠对象完成后 就不执行了