Asset - Extension Process Information (for Windows, macOS, and Ubuntu)

Samuel Venable

Time Killer









The macOS dylib file is not code signed; please code sign it before testing and distributing for macOS.

Process Information

Allows executing, reading, and manipulating various information from application processes.

The library's source code can also be easily used in your C++ projects, (which is how I included a BSD build screenshot).

  • process_t - process identifier (real) - on Windows, this is a typedef of a DWORD (unsigned long), and on Mac/Linux it is a pid_t (signed long). Safely casted to a double for GameMaker extension compatibility.

  • window_t - window handle (pointer) - HWND (void *) on Windows, NSWindow * (void *) on Mac, and Window (unsigned long) on Linux. Casted to a void * for generic, cross-platform compatibility, using the same header.

  • wid_t - window identifier (string) - a std::string (basic_string<char>) wrapping a window id number in quotes for use in various interpreted scripting languages like VBScript on Windows or AppleScript on Mac, or shell programs like Zenity on Linux. On Windows, this number is a std::to_string((unsigned long long)HWND), on Mac, this is a std::to_string((unsigned long)CGWindowID), and on Linux is is a std::to_string((unsigned long)Window). This string can be used to represent the shell scripting equivalent for a global window handle.

C++:
// Execute process, returns process id
process_t process_execute(string command);

// Execute process outside main thread
void process_execute_async(string command);

// Return previous executed process id
process_t process_previous();

// Evaluate last process output string
string process_evaluate();

// Clears previous process id executed
void process_clear_pid();

// Clears previous process output text
void process_clear_out();

// Get process id from current process
process_t pid_from_self();

// Parent process id from this process
process_t ppid_from_self();

// Get executable path from process id
string path_from_pid(process_t pid);

// Get exe parent path from process id
string dir_from_pid(process_t pid);

// Get executable name from process id
string name_from_pid(process_t pid);

// Return command line from process id
string cmd_from_pid(process_t pid);

// Return environ vars from process id
string env_from_pid(process_t pid);

// Check for existence from process id
bool pid_exists(process_t pid);

// Check existence for given window id
bool wid_exists(wid_t wid);

// Kill an application from process id
bool pid_kill(process_t pid);

// Return window handle from window id
window_t window_from_wid(wid_t wid);

// Return window id from window handle
wid_t wid_from_window(window_t window);

// Get owner process id from window id
process_t pid_from_wid(wid_t wid);

// Return strings for every process id
string pids_enum(bool trim_dir, bool trim_empty);

// Get parent process id of process id
process_t ppid_from_pid(process_t pid);

// Get list of process ids from parent
string pids_from_ppid(process_t ppid);

// Get list of window ids from process
string wids_from_pid(process_t pid);

// Get window id from frontmost window
wid_t wid_from_top();

// Get process id from topmost process
process_t pid_from_top();

// Bring window id to frontmost window
void wid_to_top(wid_t wid);

// Add a parent window id to window id
void wid_set_pwid(wid_t wid, wid_t pwid);

// Return output of a given expression
string echo(string expression);
Marketplace Page:
 
Last edited:

Samuel Venable

Time Killer
lol I can't help but notice that this is basically just like my most popular asset on the marketplace, Execute Shell, but on steroids. Execute Shell has thousands of downloads, and a crap ton of 5/5 reviews. I wonder why this asset, which capable of all the same things, and a lot more than that, hasn't really gotten any traction yet? Does anyone actually know what this extension even does? Am I not describing it properly? Or am I just overthinking it with my impatience?
 

Samuel Venable

Time Killer

Free GameMaker Video Player Example for Linux, (uses Process Information Extension + MPV Media Player).

Download Free:

I will be adding this example to the marketplace in the near future. Note mpv media player may be GPL but because you are not linking with it nor are you using its source compiled directly into your exe it is fine to distribute your game closed-source using this and since GPL is officially bypassed when used in an binary executable format separate from your game, all the extension does is execute the program with command line parameters which is not linking at all. It requires you and the end user to have the video player installed via your package manager or however:
Code:
sudo apt-get install mpv
 
Last edited:

Samuel Venable

Time Killer
@Unknown Entity I fixed this extension if you ever happen to need it. It should no longer hang for you. If you are ok with updating and trying it again that would be great so other people will be able to see you verified it works now.
 

IGameArt

Member
This can be used to execute batch files? I'm having a tough time getting it to do what I'm trying. Essentially I'm saving a surface to a png then trying to use this to convert it to another format using a bat file with the proper instructions.

GML:
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
I've placed quotes around the directory but it doesn't launch the bat, even if I use get_open_filename to track down the file I want to launch manually it still fails to do anything.
 

Samuel Venable

Time Killer
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = "cmd /c " + @'"'+dir+@'"';
show_message(dir);
process_execute(dir)

Should do the trick. :)
 

IGameArt

Member
I'll give that a shot when I get home, thanks!

EDIT: Still getting no results. It's like it can't find the file or something.
 
Last edited:

Samuel Venable

Time Killer
Is anyone else able to reproduce this problem with batch files not working, even when attempted the way I mentioned? I'm still waiting to hear back from @IGameArt with a private conversation we're having regarding the issue, and if I could debug it and find the source of the problem sooner, it would help him and potenially others.

Edit:

Just noticed a problem with the code provided.
var dir = working_directory+"\Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
There is an unnecessary backslash that bwoke it. It should be:

var dir = working_directory+"Assets\\Dependencies\\ConvertStepA.bat";
dir = @'"'+dir+@'"';
show_message(dir);
process_execute(dir)
 
Last edited:
Top