Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


get attached program current position [help]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Lynxz Gaming
Expert Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 151

PostPosted: Fri Jan 18, 2019 10:27 am    Post subject: get attached program current position [help] Reply with quote

Hello,
how do i get attached program current position in Lua?
thanks

_________________
<3 Yuki Tanaka
Back to top
View user's profile Send private message
Nighthawyun
Newbie cheater
Reputation: 0

Joined: 21 Jan 2019
Posts: 17

PostPosted: Mon Jan 21, 2019 7:35 pm    Post subject: Reply with quote

hi lynxz do u know me?
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 151

PostPosted: Wed Jan 23, 2019 6:03 am    Post subject: Reply with quote

aww nighthawk
_________________
<3 Yuki Tanaka
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 361

Joined: 09 May 2003
Posts: 21407
Location: The netherlands

PostPosted: Wed Jan 23, 2019 10:28 am    Post subject: Reply with quote

if you mean x,y position of the window perhaps sendMessage can be used with a comnand to get coordinates (you'll also need to find the window)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Lynxz Gaming
Expert Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 151

PostPosted: Thu Jan 24, 2019 5:21 am    Post subject: Reply with quote

can you give me an example
_________________
<3 Yuki Tanaka
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 23

Joined: 10 Apr 2015
Posts: 761

PostPosted: Thu Jan 24, 2019 6:54 am    Post subject: Reply with quote

MAYBE, to get and show window / screen coordinate position.
Something like...

Code:
f = createForm()
f.width = 200
f.height = 100

lx = createLabel(f)
lx.left = 10
lx.top =10
lx.caption = 'X-pos : '

ly = createLabel(f)
ly.left = lx.width + 50
ly.top =10
ly.caption = 'Y-pos : '

MPos_X = createLabel(f)
MPos_X.top = 10
MPos_X.left = 50
MPos_X.caption = '0'
MPos_X.Font.Color = '0x0311FF'
MPos_X.Font.Style = 'fsBold'

MPos_Y = createLabel(f)
MPos_Y.top = 10
MPos_Y.left = 130
MPos_Y.caption = '0'
MPos_Y.Font.Color = '0x0311FF'
MPos_Y.Font.Style = 'fsBold'

btn1 = createButton(f)
btn1.left = 10
btn1.top = 40
btn1.width = 100
btn1.height = 30
btn1.caption = 'Start Over'

f:show()
--------------
local x, y = getMousePos()
MPos_X.caption = tostring(x)
MPos_Y.caption = tostring(y)

---------------
function startOver()
x=0
y=0
setMousePos({x=0,y=0})
MPos_X.caption = tostring(x)
MPos_Y.caption = tostring(y)
z=createTimer(nil)
z.Interval=100
z.OnTimer=function(z)
--x.destroy()
--y.destroy()
local x, y = getMousePos()
MPos_X.caption = tostring(x)
MPos_Y.caption = tostring(y)
end
z.Enabled=true
end
---------------

btn1.onClick = startOver

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 151

PostPosted: Fri Jan 25, 2019 7:54 am    Post subject: Reply with quote

Corroder, what i mean is how to get process windows coordinate, thx
_________________
<3 Yuki Tanaka
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 23

Joined: 10 Apr 2015
Posts: 761

PostPosted: Fri Jan 25, 2019 8:19 am    Post subject: Reply with quote

Oh, then I don't know how to do it with lua. May something there in LuaAPI.
But, this code with VB to get coordinate running in process (external app) :

Code:
Imports System.Runtime.InteropServices

Public Class Form1
    <DllImport("user32.dll", EntryPoint:="FindWindowW")> _
    Private Shared Function FindWindowW(<MarshalAs(UnmanagedType.LPTStr)> ByVal lpClassName As String, <MarshalAs(UnmanagedType.LPTStr)> ByVal lpWindowName As String) As IntPtr
    End Function

    <DllImport("user32.dll", EntryPoint:="GetWindowRect")> _
    Private Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lpRect As RECT) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure RECT
        Public left, top, right, bottom As Integer
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hWnd As IntPtr = FindWindowW(Nothing, "untitled - notepad")
        If hWnd <> IntPtr.Zero Then
            Dim wr As New RECT
            GetWindowRect(hWnd, wr)
            MessageBox.Show("The window position is - X=" & wr.left.ToString & "  Y=" & wr.top.ToString)
        Else
            MessageBox.Show("Window not found")
        End If
    End Sub
End Class

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites