stack a new full userdata with the block address, and returns this address. This function allocates a new block of memory with the given size, pushes onto the void *lua_newuserdata (lua_State *L, size_t size) Return, DllCall("lua51\lua_newthread", "UInt", l, "Cdecl UInt") Return, DllCall("lua51\lua_newtable", "UInt", l, "Cdecl") Return, DllCall("lua51\lua_newstate", "UInt", f, "UInt", ud, "Cdecl UInt") Return, DllCall("lua51\lua_load", "UInt", L, "UInt", reader, "UInt", data, "UInt", chunkname, "Cdecl Int") Lua_load(ByRef l, reader, ByRef data, ByRef chunkname) Return, DllCall("lua51\lua_lessthan", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isuserdata", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isthread", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_istable", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isstring", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isnumber", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isnoneornil", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isnone", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isnil", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_islightuserdata", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isfunction", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_iscfunction", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_isboolean", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_insert", "UInt", l, "Int", index, "Cdecl") Return, DllCall("lua51\lua_gettop", "UInt", l, "Cdecl Int")
Return, DllCall("lua51\lua_gettable", "UInt", L, "Int", index, "Cdecl") Return, DllCall("lua51\lua_getmetatable", "UInt", L, "Int", index, "Cdecl Int") Return, DllCall("lua51\lua_getfield", "UInt", L, "Int", index, "Str", name, "Cdecl") Return, DllCall("lua51\lua_getfenv", "UInt", l, "Int", index, "Cdecl") If ud is not NULL, Lua stores in *ud the opaque pointer passed to lua_newstate.
Returns the memory-allocation function of a given state. Return, DllCall("lua51\lua_gc", "UInt", l, "Int", what, "Int", data, "Cdecl Int") Return, DllCall("lua51\lua_error", "UInt", l, "Cdecl Int") Return, DllCall("lua51\lua_equal", "UInt", l, "Int", index1, "Int", index2, "Cdecl Int") Return, DllCall("lua51\lua_dump", "UInt", l, "UInt", writer, "UInt", data, "Cdecl Int") Return, DllCall("lua51\lua_createtable", "UInt", l, "Int", narr, "Int", nrec, "Cdecl") Return, DllCall("lua51\lua_cpcall", "UInt", l, "UInt", func, "UInt", ud, "Cdecl Int") Return, DllCall("lua51\lua_concat", "UInt", l, "Int", extra, "Cdecl") Return, DllCall("lua51\lua_close", "UInt", l, "Cdecl") Return, DllCall("lua51\lua_checkstack", "UInt", l, "Int", extra, "Cdecl Int") Return, DllCall("lua51\lua_pcall", "UInt", l, "Int", nargs, "Int", nresults, "Cdecl") Return, DllCall("lua51\lua_atPanic", "UInt", L, "UInt", panicF, "Cdecl") Return, DllCall("LoadLibrary", "str", dll) Msgbox("this lua-function has been called by hotkey") Out := "Screen Width := " screenWidth "`n" Msgbox % "Error failed to load " lua_tostring(L,-1) call the function with 2 arguments, return 1 result Gui("Add", "Text","x5 y5", "Please enter your name:")Įxample 2: Calling an lua-function from ahk Lua_register(l, "average", AverageAddress)įile = io.open ("example_callAhkFromLua.txt","w")Įxample 1.2: Calling an ahk-command from lua and examples + lua-ahk stdlib from here (zip)Įxample 1.1: Calling an ahk-command from luaĪverageAddress := RegisterCallback("average","C") get the required libs from here (lua5.1.dll, lua51.dll) So far i've implemented the needed functions to:įor now this is merely a proof of concept, but if you want to try it Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is a powerful, fast, lightweight, embeddable scripting language.