Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://forum.cheatengine.org/viewtopic.php?t=606184
- hm, PostMessage should be able to manage it.
- http://tools.stefankueng.com/SendMessage.html works
- Though I tried creating this for x64 notepad and it didn't so clearly I've done something wrong
- [code]local WM_KEYDOWN = 0x0100
- local WM_KEYUP = 0x0101
- local WM_CHAR = 0x102
- local pmsScript = [[
- [ENABLE]
- alloc(postMessageStub,$1000)
- registerSymbol(postMessageStub)
- postMessageStub:
- push rbp
- mov rbp, rsp
- mov edx, [rcx+8]
- mov r8, [rcx+10]
- mov r9, [rcx+18]
- mov rcx, [rcx+0]
- sub rsp, 20
- call PostMessageA
- add rsp, 20
- pop rbp
- ret
- [DISABLE]
- unregisterSymbol(postMessageStub)
- dealloc(postMessageStub)
- ]]
- success, pms = autoAssemble(pmsScript)
- if not success then error('failed to create stub!') end
- PostMessage = function(hwnd, msg, wparam, lparam)
- local postMessageMem = allocateMemory(32)
- writeQword(postMessageMem+0, hwnd)
- writeQword(postMessageMem+8, msg)
- writeQword(postMessageMem+16, wparam)
- writeQword(postMessageMem+24, lparam)
- executeCode('PostMessageStub',postMessageMem)
- deAlloc(postMessageMem)
- end
- local hwnd = 0
- local t = createTimer()
- t.Interval = 100
- local sendCount = 0
- t.OnTimer = function(t)
- if hwnd == 0 then -- check if current foreground window is attached process's
- if getForegroundProcess() == getOpenedProcessID() then
- hwnd = getForegroundWindow()
- print('found')
- end
- else -- once we have the hwnd
- sendCount = sendCount + 1
- if sendCount >= 10 then
- t.destroy()
- autoAssemble(pmsScript, pms)
- print('done')
- return
- end
- PostMessage(hwnd, WM_KEYDOWN, VK_A, 1) -- VK_A = 65
- end
- end[/code]
- Though I was able to use shellExecute to run that program from the command line essentially:
- [code]local cmd = os.getenv('userprofile') .. '\\Desktop\\SendMessage-1.1.2.exe'
- local params ='/message:256 /wparam:65 /lparam:1 /post /windowclass:Edit /processname:' .. process
- shellExecute(cmd, params)
- [/code]
- 65 is the code for 'a', F1 is 112 but I wanted something easier to test with. It also didn't work without the /windowclass but you can get that by running the SendMessage program and dragging the target/reticle to the game. Of course, once you get the window handle once
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement