Запустите приложения / игру внутри формы CE (форма Windows) - PullRequest
0 голосов
/ 22 февраля 2020

Я сделал небольшой проект VB Net, следуя инструкциям, чтобы открыть приложение windows внутри границ формы. Я перевел функции для управления приложением windows в Cheat Engine Lua синтаксис:

f = createForm()
f.setSize(640,500)
f.Caption = 'Test Apps Inside The Boundaries'

b = createButton(f)
b.setPosition(570,460)
b.setSize(60,30)
b.Caption = 'Launch'

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,'Calculator')
 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) ' Allow the process to open it's window
                appWin1 = p1.MainWindowHandle
                ' Put it into this form
                SetParent(appWin1, Me.Handle)
                ' Move the window to overlay it on this window
                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 для нажатия кнопки, как показано выше, и заставьте ее работать?

1 Ответ

0 голосов
/ 22 февраля 2020

решено:

function 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 = launch
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...