Send Commands to Delphi Application with Lua Script - delphi

I would like to be able to access TButton TCheckBox TEdit etc.. of a running Delphi application from a Lua script.
It is a retail Delphi application so I have no access to the source code. I would normally use AutoHotKey but would like more control.
Is this possible as I seem to be able to change things with the Enabler below. Could it be done by integrating Lua into a Delphi app and use it to send to the retail Delphi app ?
Or is there another way ?
An open source solution would be best so to make it available to others.
I use Reaper DAW and it has API for Lua scripting I would like to be able to do similar with the Delphi app without the API available.

In order to run any script in a specific application then that specific application needs to have suitable scripting capabilities built into it in order to be able to interpret that script accordingly.
Now I'm guessing that "retail" application you are using doesn't have LUA scripting built into it otherwise you probably wouldn't be here.
So I'm afraid that the answer is no. You can't interact with a third part application from LUA script unless that application is designed to work with LUA scripts.

Related

Is it possible to customize your desktop through the electron framework?

I'm working on a project in which the user will be able to change windows app icons through an application. Is it possible to have electron perform such a task or is it impossible for the electron framework to actually communicate with windows like that?
I sadly can't proof that but
I think it is possible. You could for example use Child Process and spawn processes that do things for you or write your own c/c++ modules. You can actually write c/c++ node functions, classes and so on, wrap them and use them in nodejs. Here to the Reference. Be aware though, if you don't find any pre-made solutions you have to do that for every operating system individual!

How can I distribute my program if it has dependencies?

So I recently wrote a chat bot which relies on lua and luasocket to respond to a twitch stream's chat. It's very basic and has various files it reads/writes to. It runs from the local computer. I finally got it working perfectly and now I'm interested in potentially distributing it to streamers who would get the most practical usage out of it.
But I can't just give them the files and lua script; they wouldn't be able to run it. They would need an interpreter and they would need to set up luasocket. With very little experience this is a very daunting task. Even I struggled to properly get luasocket working to make this bot.
So my question: Is there a way to package the lua interpreter and luasocket library such that I can give my bot to other people in an easy to use and practical manner? Preferably a .exe file, but really anything that doesn't require them to go out and set up the entire language and script dependencies on their own.

What do I need to know to create a server script interpreter? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am interested in model an develop a new object pascal interpreter for web site scripting.
We have PHP, Pearl, Java, Javabeans... But not Pascal as a option for web developers.
Since Delphi only works in Windows based servers...
I would like to do things like:
<input name="ClientName" value="<?pas write(ClintObj.Name); ?>">
or
<input name="ClientName" value="<?pas #ClintObj.GetName; ?>">
not just as a template, but just like PHP, something I could use with a MVC framework, or even create one:
<?pas
System.Writeln('<html><head>...');
?>
Where should I start?
Or is it already done and I fail to find it? (for linux)
Two existing products:
Oxygene
You can check out Oxygene, formerly known as Delphi Prism, formerly known as RemObjects Chrome.
They have found a way to compile a Pascal style language to Java. Not convert Pascal code to Java code, but actually compile it to the bytecode that runs in the Java runtime engine. Apart from that, they can also compile to the .NET runtime.
I don't know if you can use Oxygene for your purpose, but at least their product may give you some inspiration and some insight of the possibilities and difficulties of building something like that yourself.
PascalScript
Maybe you can use PascalScript, also by RemObjects. It is a script interpreter. So you can embed it in a server application. For instance, if you create an ISAPI application that embeds PascalScript, all you need to do is expose some 'write' method to the script to allow it to write output. All the application needs to do is output that output to ISS, and your basis server side Pascal scripting is done. After that, you can expose more convenience functions to the script to make it more useful.
PascalScript can be used in Delphi as well as FreePascal, so maybe you can make it work in Linux as well.
You are mixing embedding a scripting version of a language in templates with general web development in that language.
While Pascal isn't really used much as templating language, doing webdevelopment is perfectly possible, e.g. with http://brookframework.org/ and several Delphi component suites.
Some of the Delphi options also support Apache, and have supported Kylix in the past. I used webhub from http://www.href.com for a while.
Writing such a interpreter is not a piece of cake:
your script files would need have be parsed, the contained Pascal code compiled / checked for syntax errors
as this compilation phase would be a CPU consuming task, the resulting object code would have to be cached for better performance
maybe you do not want to use / install the FPC or Delphi compiler on the server, then your language will be limited to what your compiler can suppport
the generated code needs access to "shared data" if different script parts need to interchange information or access global data, like a database
Also a critical functional requirement unless your application is stateless:
different users of the web site need their separate data (state), so your code needs to be session-aware (stateful)
Oh, one minor issue:
the application should not expose any vulnerabilites for malicious clients, see OWASP
So I guess this will be a long weekend ;-)
Don't forget about the free DelphiWebScript (DWS).
Though started as a Delphi-like WebScript language, it is a general purpose Delphi like language that can be used as a script, and also has a JIT compiler (though without it, the performance already is very good).
The main project compiles in Delphi (so it is Windows-only) but there is a FreePascal DelphiWebScript initiative to make it run on Linux too.
There are multiple demo web server projects to choose from so you can host your own DWS scripts, for instance the WebServer project which is based on http.sys version 2, then there are Indy based and Synopse based ones.
The development tool Smart Mobile Studio is using DWS to compile the forms and Pascal based source code into HTML5 and JavaScript then serve it from a web server to run in any HTML5/JavaScript compatible browser (including the mobile ones).
So there is a lot of power in DWS, demos and the eco system around it (:

Can I make my Delphi App start at a specific time (like 12:00AM), without the application running?

I saw an installed application, that feeds some XML data from the vendor's website and displays it in the Main Form window. Simple stuff, I suppose, but whgat I noticed was that, even when I close the Application in the system tray, tomorrow morning (at exactly 12:00AM) it pops ups again! This is so cool. I am not sure that it was written in Delphi, probably some .NET IDE or somehting.
Can Delphi XE2 achieve this? If so, how can I get that to work?
Windows can achieve this: Administrative Tools -> Task Scheduler
If you need to add / manage Task Scheduler in your delphi application, there is a JCL library specially created for that :
http://wiki.delphi-jedi.org/wiki/JCL_Help:JclTask.pas
There is no documentation but you can see the source code and use the TJclTaskSchedule to add executing your own application in Task Scheduler.
To automatically create a scheduled Task either use the "schtasks.exe" command line utility that comes with Windows or an interface to the Task Scheduler API. An alternative to the JCL library is the commercial "VCL Scheduling Agent" component for Delphi.

How to run external executable (.exe ) in C++

I'm not a developper. We want ( me and our team)to write a tool in C++ that can print a PDF ( Send a PDF to printer). We tried to use external tool, like a command line pdfprint.exe, using CreateProcessW and cmd /c, but we have a problem. With Windows XP we don't have problem with our tool, with Windows Vista we have problem and we cannot using the tool like pdfprint.exe.
There are differences between Windows XP and Vista to launch external tools within another program with CreateProcessW and "cmd /c"?
Thanks
Oronzo
There are many approaches to run external application from your C++ programm. I will count them below.
Win32API CreateProcess function. Cédric Julien gave example of use.
exec* C/C++ function family. They are defined in POSIX standard. So they are the same on Linux. But because they are deprecated in new version of MSVC, try to use analogical _exec* function.
WiNT Native API Call - NtCreateProcess. It is called in CreateProcess also :-) And this function represents deeper level of API. With use of Native API calls you can write small and simple applications, because you will make lesser number of dependencies of your program with external libraries. But there are issues: native API is binded to OS version, so there aren't any garanties that Native API will be the same in next OS versions.
You may try each. Please, note that it is good idea to point in each call to these functions full path to executable file. Also you must have read/execute rights (permissions) on pdfprint.exe. If you don't have such only way to execute external tool is to run your C++ program with administrative rights. You can run it such way if you right click on exe-file of your program and select "Run As Administrator" menu element.
As described here, you should use something like this :
LPTSTR szCmdline = _tcsdup(TEXT("C:\\Program Files\\....\\pdfprint.exe -args-you-need"));
CreateProcess(NULL, szCmdline, /* ... */);

Resources