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 


FindWindow (user32.dll vs CE default)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Mar 11, 2020 10:00 pm    Post subject: FindWindow (user32.dll vs CE default) Reply with quote

I try to implementing window API lib. user32.FindWindow() to compare with CE default FindWindow function.

Example:
Code:
function findwindow(sClassName, sAppName)
  return executeCodeLocalEx('user32.FindWindow', sClassName, sAppName)
end

function setforegroundwindow(hWnd)
  return executeCodeLocalEx('user32.SetForegroundWindow', hWnd)
end

function enumchildwindows(hWndParent, Delegate, lpEnumFunc, lParam)
  return executeCodeLocalEx('user32.EnumChildWindows', hWndParent, Delegate, lpEnumFunc, lParam)
end

function getwindowtext(hWnd, s, nMaxCount) -- s = stringBuilder
  return executeCodeLocalEx('user32.GetWindowText', hWnd, s, nMaxCount)
end

function getwindowtextlength(hWnd)
  return executeCodeLocalEx('user32.GetWindowTextLength', hWnd)
end

function getgesktopwindow()
  EntryPoint="GetDesktopWindow"
  return executeCodeLocalEx('user32.GetDesktopWindow', EntryPoint)
end

function MessageBox(title,text,uType)
 return executeCodeLocalEx("user32.MessageBoxA", MainForm.Handle, text, title, uType)
end

--- Applies to example
appform = createForm()
appform.setSize(200,100)
appform.Caption = 'Find Window'
appform.Position = 'poScreenCenter'

editbox = createEdit(appform)
editbox.setPosition(10,10)
editbox.setSize(180,30)
editbox.Text =""

button1 = createButton(appform)
button1.setPosition(50,60)
button1.setSize(100,30)
button1.Caption = 'Execute'

--- Variables and functions
function findWnds()
 local txt = editbox.Text
 if txt == "" then return nil end
 local CallingWindow = findwindow(nil, txt)
 local txtValue = getwindowtext(CallingWindow, txt, 256)
 MessageBox(tostring(txtValue), "Contains text of control : "..txt, 1)
 return 1
end

function clearance()
 closeCE()
 return caFree
end

--- Event
appform.show()
appform.OnClose = clearance
button1.OnClick = findWnds


But when execute the function, I got this error: "Error: Failure determining what user32.FindWindow means"
Why executeCodeLocalEx('user32.FindWindow', sClassName, sAppName) not identified by CE?

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Wed Mar 11, 2020 11:06 pm    Post subject: Reply with quote

Try user32.FindWindowA
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 12, 2020 12:47 am    Post subject: Reply with quote

Thanks, Parkour

It's fixed. need to change to 'FindWindowA' and also 'GetWindowTextA'

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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