Shell Execute - coldrockgames/gml-raptor GitHub Wiki
Note
Due to our efforts in making raptor fully HTML compatible, this extension is not part of the raptor project by default.
You find a folder extensions
in the root of the raptor repository.
The shell-execute extension is there as a local package, ready to be included in your project, but keep in mind, that this extension works for the windows-target
only!
Sometimes, you want to execute a shell command from your game, like opening a URL in the browser or any other website (maybe a feedback form, bug reports, something like that).
In a more sophisticated game you might even want to execute some scripts or utility programs to patch your game files. Whatever the need is, when you need to communicate with the OS, things can get complicated, especially from within a game engine like GameMaker. While it supports opening of a URL, it does not support executing other things.
For these scenarios, raptor comes with a slightly modified version of execute_shell_simple
by YellowAfterLife. This extension allows you (Windows only!) to execute any command on the windows shell.
Raptor modified it a bit and applied a more intuitive and simpler interface (you shouldn't have to deal with Microsoft's MSDN page and read through C++ constant declarations just run a batch script), and offers you two easy-to-use functions to execute something in the operating system.
/// @func shell_run(_commandline, _hidden = true)
/// @desc Executes a shell command or starts a program, optionally hidden
/// NOTE: This call does NOT wait until the program is finished!
/// To sync with execution end, use shell_run_wait(...).
function shell_run(_commandline, _hidden = true) {
/// @func shell_run_wait(_commandline, _finished_callback = undefined)
/// @desc Executes a command line and waits until it is finished.
/// NOTE: Due to the nature of a temp batch file created to allow this, you can not
/// run this hidden (the temp batch is executed hidden, though, but not your
/// command unless it is just a shell command).
/// The finished callback is invoked when the task is finished.
function shell_run_wait(_commandline, _finished_callback = undefined) {
Here are some short examples, how to use the functions:
// Open any website in your browser
shell_run("start https://www.coldrock.games");
// Run any program and continue the game
shell_run("notepad.exe");
// Run any program and receive a callback when it
// is finished or closed
shell_run_wait("notepad.exe", function() {
ilog("Notepad has been closed");
});