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 use hookWndProc()

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

Joined: 10 Feb 2018
Posts: 38

PostPosted: Thu Feb 22, 2018 5:47 am    Post subject: how to use hookWndProc() Reply with quote

i can use this with C++
but,don't know the params in lua,
anyone can post a sample?
thanks

_________________
A wild programmer
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Feb 22, 2018 10:05 am    Post subject: Reply with quote

it's currently not working as I intended (quite buggy, and for some reason crashes on first run but not on second) but if it worked, it'd be like this:
Code:

cetutwindow=findWindow(nil,"Cheat Engine Tutorial v3.4") --first window of the tutorial
if getWindowProcessID(cetutwindow)~=getOpenedProcessID() then
  showMessage('wrong window')
  return
end

-- Hooks a window's wndproc procedure. The given function will receive all functions.  Return 0 to say you handled it. 1 to let the default windows handler deal with it. Or anything else, to let the original handler deal with it.  Besides the return value, you can also return hWnd, Msg, lParam and wParam, modified, or nil for the original value.  Set ASYNC to true if you don't want to run this in the CE GUI. (faster, but you can't touch gui objects)
function myfilter(hwnd, msg, wparam, lparam)
  local s=string.format("%x",msg)
  if msg==0x0201 then
    s=s..":Down"
    print(s)
  end

  return 2 --let the target deal with it normally (1 to not let the target deal with it specially, but let windows do it.  0 for no handling at all)
end

hookWndProc(cetutwindow, myfilter, false)

_________________
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
movss
Cheater
Reputation: 0

Joined: 10 Feb 2018
Posts: 38

PostPosted: Sat Feb 24, 2018 1:52 am    Post subject: Reply with quote

Dark Byte wrote:
it's currently not working as I intended (quite buggy, and for some reason crashes on first run but not on second) but if it worked, i\
[/code]


thank you DB,
i think the prototype of this function is SetwindowLong and CALLBACK WindowProc
LONG SetWindowLong(
HWND hWnd, // handle to window
int nIndex, // offset of value to set
LONG dwNewLong // new value);


LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter);

_________________
A wild programmer
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