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 


[HELP] Sending a mouse press to another window

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaVinci 69
How do I cheat?
Reputation: 0

Joined: 18 Apr 2019
Posts: 4

PostPosted: Thu Apr 16, 2020 2:42 pm    Post subject: [HELP] Sending a mouse press to another window Reply with quote

Hi, I want to send a mouse press to another window in background.

I tried this but failed
Code:
WM_LBUTTONDOWN = 0x0201
WM_LBUTTONUP = 0x0202
WM_SETTEXT = 0x000C
WM_CLOSE = 0x0010
WM_KEYDOWN = 0x0100

function postMessage(hwnd,  wMsg, wParam, lParam)
 return executeCodeLocalEx("user32.SendMessageA", hwnd,  wMsg, wParam, lParam)
end

function FindWindowN(lpClassName, lpWindowName)
 return executeCodeLocalEx("user32.FindWindowA", lpClassName, lpWindowName)
end

function FindWindowExAZ(hWnd1, hWnd2, lpsz1, lpsz2)
 return executeCodeLocalEx("user32.FindWindowExA", hWnd1, hWnd2, lpsz1, lpsz2)
end

function test()
 local iHwnd = FindWindowN("Calculator", 0)
 local iHwndChild  = FindWindowExAZ(iHwnd, 0, "Windows.UI.Core.CoreWindow", 0)
 x,y = 10,50
 lParam = (y * 16) + x

 postMessage(iHwndChild, WM_LBUTTONDOWN, 0, lParam)
 postMessage(iHwndChild, WM_LBUTTONUP, 0, lParam)
end


test()


Thanks!
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Apr 17, 2020 6:55 am    Post subject: This post has 1 review(s) Reply with quote

If you want to send more than strings to another window using postMessage or sendMessage then you need to learn about MEMORY MAPPED and WM_COPYDATA, copyDataStruct, etc.

From your script. what you trying to do is send variables to Calculator windows, this is not simple. But if you want to send keystroke or mouse click to Calculator window, this is an example using CE Lua scripting:

Code:
ps1 = 'start calc.exe'
p1 = os.execute(ps1)
sleep(1000)
openProcess('calc.exe')
w=getWindow(getForegroundWindow(), GW_HWNDFIRST)
pid=getOpenedProcessID()

while w and (w~=0) do
 if (getWindowProcessID(w)==pid) and (executeCodeLocal("IsWindowVisible",w)~=0) then

    keyDown(VK_LBUTTON)
    keyDown(VK_1)
    sleep(100)

    keyUp(VK_LBUTTON)
    keyUp(VK_1)
    sleep(100)

    keyDown(VK_LBUTTON)
    keyDown(VK_0)
    sleep(100)

    keyUp(VK_LBUTTON)
    keyUp(VK_0)

    keyDown(VK_LBUTTON)
    keyDown(VK_ADD)
    sleep(100)

    keyUp(VK_LBUTTON)
    keyUp(VK_ADD)

    keyDown(VK_LBUTTON)
    keyDown(VK_1)
    sleep(100)

    keyUp(VK_LBUTTON)
    keyUp(VK_1)
    sleep(100)

    keyDown(VK_LBUTTON)
    keyDown(VK_0)
    sleep(100)

    keyUp(VK_LBUTTON)
    keyUp(VK_0)

    keyDown(VK_LBUTTON)
    keyDown(VK_ADD)
    sleep(100)
end
 w=getWindow(w, GW_HWNDNEXT)
end


Same if using VBS script:

Code:
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500


If you plan to do hacks progress directly on game windows, maybe you can use the hooking method or use AHK, Autoit, etc.

_________________
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