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 


How to get process/window size or position in LUA [HELP]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Nighthawyun
Cheater
Reputation: 0

Joined: 21 Jan 2019
Posts: 27

PostPosted: Sun May 05, 2019 1:47 am    Post subject: How to get process/window size or position in LUA [HELP] Reply with quote

how to get process current position? with lua pls help
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun May 05, 2019 3:33 am    Post subject: Reply with quote

Code:

local windows={}
local w=getWindow(getForegroundWindow(),GW_HWNDFIRST);
local i=0
local pid=getOpenedProcessID()

while (w~=0) and (i<10000) do
  if getWindowProcessID(w)==pid then
    windows[#windows+1]=w
  end

  w=getWindow(w,GW_HWNDNEXT);
  i=i+1
end

--windows contains a windowlist of the target process

--in next CE version you can do executeCodeLocalEx which is more efficient, but for now use executeCodeEx which runs inside the target

local i
local rectaddress=allocateMemory(16)
local addr=getAddress("GetWindowRect")

for i=1,#windows do
  local r=executeCodeEx(0,nil,addr,{type=0,value=windows[i]},{type=0,value=rectaddress})
  if (r~=nil) and (r~=0) then
    local left=readInteger(rectaddress)
    local top=readInteger(rectaddress+4)
    local right=readInteger(rectaddress+8)
    local bottom=readInteger(rectaddress+12)

    local s=string.format("%s is located at %d,%d with a width of %d and height of %d", getWindowCaption(windows[i]), left,top,right-left,bottom-top)
    print(s)
  end
end

deAlloc(rectaddress)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Nighthawyun
Cheater
Reputation: 0

Joined: 21 Jan 2019
Posts: 27

PostPosted: Thu May 09, 2019 4:45 am    Post subject: Reply with quote

omg ty
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