I have tried to use the command of "require" in Luamacros so as to extend the function, but get the error:
2018-10-01 13:01:18:883 [LUA] ERROR: Runtime error
error loading module 'winapi' from file 'C:\Users\WingKin\Dropbox\Small Tools\luamacros\winapi.dll':
?䤣???w?ҲաC
I think LuaMacros is responding to the command, but I have not idea about how to include the .dll file to the code because of the "?䤣???w?ҲաC" is unreadable. Any hints?
Require for "Require" Support
Re: Require for "Require" Support
This may not work like this as lua interpreter itself is plugged in to different program (luamacros.exe). Let me check if this can be somehow done...
Petr Medek
LUAmacros author
LUAmacros author
-
- Posts: 14
- Joined: 06 Feb 2018, 05:23
Re: Require for "Require" Support
Thanks for you reply!
-
- Posts: 14
- Joined: 06 Feb 2018, 05:23
Re: Require for "Require" Support
Finally, I find an imperfect solution for the inclusion of the external library.
Due to the absence of the return from lmc_spawn(). I would use the io.popen() as the channel in getting the return value.
For instance,
function getClipboard()
program = pythonw_path
command = program_path .. "GetClipboard.py"
text = ""
--print(program .. " \"".. command .. "\"")
full_command = "Start /B " .. program .. " \"".. command .. "\""
--print(full_command)
f = assert(io.popen(full_command, "r"))
for line in f:lines() do
text = text .. line .. " \n "
--print(line)
end -- for loop
f:close()
return text
end
In fact, the function call the external python script to get the content from the clipboard and print the value. Then, the script utilizes the printed value as the return parameter. The external functions can be implemented by the third-party programming, and it acts as the function of "require".
For reference, "GetClipboard.py" is shown as below.
# -*- coding: utf-8 -*-
from __future__ import print_function
import PathCatcher
content = PathCatcher.GetClipboardText()
print(content)
The "PathCatcher" is available in
http://code.activestate.com/recipes/528 ... ck-captur/
Hope the solution helps the users with the similar needs!
Due to the absence of the return from lmc_spawn(). I would use the io.popen() as the channel in getting the return value.
For instance,
function getClipboard()
program = pythonw_path
command = program_path .. "GetClipboard.py"
text = ""
--print(program .. " \"".. command .. "\"")
full_command = "Start /B " .. program .. " \"".. command .. "\""
--print(full_command)
f = assert(io.popen(full_command, "r"))
for line in f:lines() do
text = text .. line .. " \n "
--print(line)
end -- for loop
f:close()
return text
end
In fact, the function call the external python script to get the content from the clipboard and print the value. Then, the script utilizes the printed value as the return parameter. The external functions can be implemented by the third-party programming, and it acts as the function of "require".
For reference, "GetClipboard.py" is shown as below.
# -*- coding: utf-8 -*-
from __future__ import print_function
import PathCatcher
content = PathCatcher.GetClipboardText()
print(content)
The "PathCatcher" is available in
http://code.activestate.com/recipes/528 ... ck-captur/
Hope the solution helps the users with the similar needs!