Search the Community
Showing results for tags 'lua script'.
-
Win32 API GetOpenFileName using the function with lua. Can I open a file dialog box in the folder I am in with lua. FileOpenDialog ('Open a Text File', @ScriptDir ... and such. $FileOpenDialog = FileOpenDialog('Open a Text File', @ScriptDir, 'Text Files (*.txt)') I'm looking for a command like this FileOpenDialog = GetOpenFileName("Open a Text File", "txt\n*.txt", @ScriptDir)
-
Hello, I've read a article about lua functions here: https://debian-administration.org/article/264/Embedding_a_scripting_language_inside_your_C/C_code There are two ways of include lua scripts to your AutoIt code. 1. Run lua functions by Autoit. 2. Register Autoit function and run as lua. It's even possible to apply second way to AutoIt? As we can see on example there a few functions to make it possible. It's a lua file save as average.lua avg, sum = average(10, 20, 30, 40, 50) print("The average is ", avg) print("The sum is ", sum) This is a C functions to run lua. Can be convert to AutoIt ofc. There is a problem with func lua_register(L, "average", average) this function is not even detected in Lua51.dll We can use lua_pushcclosure instead. #include <stdio.h> #include "lua.h" #include "lualib.h" #include "lauxlib.h" /* the Lua interpreter */ lua_State* L; /* The function we'll call from the lua script */ static int average(lua_State *L) { /* get number of arguments */ int n = lua_gettop(L); double sum = 0; int i; /* loop through each argument */ for (i = 1; i <= n; i++) { if (!lua_isnumber(L, i)) { lua_pushstring(L, "Incorrect argument to 'average'"); lua_error(L); } /* total the arguments */ sum += lua_tonumber(L, i); } /* push the average */ lua_pushnumber(L, sum / n); /* push the sum */ lua_pushnumber(L, sum); /* return the number of results */ return 2; } int main ( int argc, char *argv[] ) { /* initialize Lua */ L = lua_open(); /* load Lua base libraries */ lua_baselibopen(L); /* register our function */ lua_register(L, "average", average); /* run the script */ lua_dofile(L, "average.lua"); /* cleanup Lua */ lua_close(L); return 0; }