Page 1 of 1
Handle proc
Posted: Sat Aug 29, 2015 9:29 pm
by ZZZZZ
Just wondering how do I get the handle proc of the Micromacro window that is executing said code? Trying to use
process.terminate(handle proc) to close MM when the ArcheAge window it is attached to closes.
Tried
Code: Select all
process.terminate(window.getAppHwnd())
but getAppHwnd returns a number and I need userdata which I have no idea how to acquire
Code: Select all
Failed to run init function, err code: 7 (Runtime error)
aatest.lua:38: bad argument #1 to 'terminate' (userdata expected, got number)
stack traceback:
[C]: in field 'terminate'
aatest.lua:38: in function <aatest.lua:31>
Probably some simple function that I havn't seen ^.^
Re: Handle proc
Posted: Sat Aug 29, 2015 9:47 pm
by rock5
I don't have mm2 installed but from looking at the documentation
open
procHandle process.open(number procId)
Attempt to open and return a handle to a process for reading/writing. Accepts only the process's ID.
Maybe you can use
Code: Select all
handle = process.open(window.getAppHwnd())
process.terminate(handle)
I'm not sure but maybe you can also use
Re: Handle proc
Posted: Sat Aug 29, 2015 9:59 pm
by ZZZZZ
Na no go.
Code: Select all
Failed to run init function, err code: 7 (Runtime error)
aatest.lua:40: bad argument #1 to 'terminate' (userdata expected, got nil)
stack traceback:
[C]: in field 'terminate'
aatest.lua:40: in function <aatest.lua:31>
and
Code: Select all
Failed to run init function, err code: 7 (Runtime error)
aatest.lua:39: attempt to index a nil value (global 'handle')
stack traceback:
aatest.lua:39: in function <aatest.lua:31>
Re: Handle proc
Posted: Sat Aug 29, 2015 10:17 pm
by Administrator
Try this:
Code: Select all
local procId = process.findByWindow(window.getAppHwnd());
local proc = process.open(procId);
process.terminate(proc);
Re: Handle proc
Posted: Sat Aug 29, 2015 10:25 pm
by ZZZZZ
Woo that worked! Thank you very much, spent way too long trying to figure that out lol
Re: Handle proc
Posted: Sat Aug 29, 2015 11:43 pm
by Administrator
Is there a reason you're forcefully terminating like that though? I imagine you could also just do t his:
That should terminate things slightly more gracefully.