在 CE 表单(Windows Form)中启动应用程序/游戏
2020-2-22 5:33:53
收藏:0
阅读:228
评论:1
我按照教程做了一个小的 VB Net 项目,将窗口应用程序打开到窗体边界内。我已经将控制窗口应用程序的功能转换为 Cheat Engine Lua 语法:
f = createForm()
f.setSize(640,500)
f.Caption = '测试在边界内启动应用程序'
b = createButton(f)
b.setPosition(570,460)
b.setSize(60,30)
b.Caption = '启动'
function SetParent(hWndChild, hWndNewParent)
executeCodeLocalEx('SetParent', hWndChild, hWndNewParent)
end
function SetWindowPos(hwnd, hWndInsertAfter, x, y, cx, cy, wFlags)
executeCodeLocalEx('SetWindowPos', hwnd, hWndInsertAfter, x, y, cx, cy, wFlags)
end
function MoveWindow(hwnd, x, y, cx, cy, repaint)
local rp
if repaint then
rp=1
else
rp=0
end
executeCodeLocalEx('MoveWindow', hwnd, x, y, cx, cy, rp)
end
function launch()
local ps1 = os.execute'calculator.exe'
sleep(1000)
--- appWin1 = ps1.MainWindowHandle --- how this?
local appWin1 = findWindow(nil,'计算器')
SetParent(appWin1,f)
MoveWindow(appWin1, 0,0, f.Width/2, f.Height/2,true)
end
b.OnClick = launch
但是上面的代码无法工作。VB Net 中的代码如下:
NeedtoCELua = [[ Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Try
Dim ps1 As New ProcessStartInfo("notepad.exe")
ps1.WindowStyle = ProcessWindowStyle.Minimized
Dim p1 As Process = Process.Start(ps1)
Thread.Sleep(1000) ' 允许进程打开它的窗口
appWin1 = p1.MainWindowHandle
' 将它放到这个窗体中
SetParent(appWin1, Me.Handle)
' 移动窗口以将其叠加在此窗口上
MoveWindow(appWin1, 0, 0, Me.Width \ 2, Me.Height, True)
Private Sub Form8_Resize(ByVal sender As Object, ByVal e As EventArgs)
If Me.appWin1 <> IntPtr.Zero Then
MoveWindow(appWin1, 0, 0, Me.Width \ 2, Me.Height, True)
End If
If Me.appWin2 <> IntPtr.Zero Then
MoveWindow(appWin2, Me.Width \ 2, 0, Me.Width, Me.Height, True)
End If
'base.OnResize(e);
End Sub
]]
如何编写一个适当的函数在 CE Lua 中参考上面所示的 VB Net 函数来点击按钮并使其工作?
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

def launch(): ps1 = 'start notepad.exe' p1 = os.execute(ps1) sleep(1000) openProcess('notepad.exe') w=getWindow(getForegroundWindow(), GW_HWNDFIRST) pid=getOpenedProcessID() while w and (w~=0) do if (getWindowProcessID(w)==pid) and (executeCodeLocal("IsWindowVisible",w)~=0) then --print(w..' - '..getWindowCaption(w)..'('..getWindowClassName(w)..')') SetParent(w, f.handle) MoveWindow(w, 10, 20, 400, f.Height-100, 1) end w=getWindow(w, GW_HWNDNEXT) end end b.OnClick = launchdef launch(): ps1 = 'start notepad.exe' p1 = os.execute(ps1) sleep(1000) openProcess('notepad.exe') w = getWindow(getForegroundWindow(), GW_HWNDFIRST) pid = getOpenedProcessID() while w and (w~=0): if (getWindowProcessID(w) == pid) and (executeCodeLocal("IsWindowVisible", w) ~= 0): # print(w..' - '..getWindowCaption(w)..'('..getWindowClassName(w)..')') SetParent(w, f.handle) MoveWindow(w, 10, 20, 400, f.Height - 100, 1) w = getWindow(w, GW_HWNDNEXT) b.OnClick = launch此代码是一段 Python 代码,实现了启动记事本应用并将其窗口放到窗体的指定位置。
详细解释见 SOLVED: Code Challenge #18 - Launch Notepad and Move the Window。