Drag and Drop to Exe STDIN / ARGV (SOLVED)

With ExeOutput for PHP, you have to use HEScript in order to read the command line switches. The HEScript function is ParamStr.

[quote]Returns the index-th parameter passed to the program using the command line.
function ParamStr(index: Integer): String;
Index: index of the parameter you want to obtain.

Steps to follow:

  1. in ExeOutput, go to Application Settings => Scripting. Double-click on UserMain and paste:

    function ReadParamNumber(idx: String): String;
    Result := paramstr(StrToInt(idx));

  1. call this function from PHP. Code example:

    <?php echo exo_return_hescriptcom("UserMain.ReadParamNumber|1", "Error"); ?>

In the case of “myexe.exe \o c:\output.txt \u user_1 \p pass1234”, you would get: \o

echo exo_return_hescriptcom("UserMain.ReadParamNumber|2", "Error");

would return c:\output.txt

I was trying a simple test to see if I could drag a file onto a compiled php script and have it read that file as stdin. My test’s indicate that while dragging a file onto the compiled exe does make it execute, however it does not seem to pass action on to the script. Does exeoutput for php support stdin or argv input to compiled files? Could I make “command line” switches available to my compiled exe, something like “myexe.exe \o c:\output.txt \u user_1 \p pass1234” ? I suppose if that were possible (I couldn’t find an example in the forums or doc’s) then perhaps the “drag and drop” method I tested would also work? I am able to use the code below as a drag and drop with php (non compiled and php files are associated with php.exe). I’d love to have something I could quickly drag and drop on to without having it open already, I’m sure I could get some JS written to accept a drag and drop file. I like the duality of having a very nice gui program, as well as the utility of a command line executable. I’ve done some work with PHc-Win and those exe’s easily accept stdin/argv but have all of these other files outside of the exe that they depend on. Your program is by far the best I’ve encountered!

<?PHP array_shift($argv); if (count($argv) == 0) { $argv[0] = "php://stdin"; } foreach ($argv as $file) { $hash = hash_file( 'md5', $file ); if ($hash !== "") { echo "$hash\n"; } }; ?>

Awesome! I’m liking this program more and more everyday! It turned out to be ReadParamNumber|0 when dragging and dropping, but works very well nonetheless. I’ll be moving on the CLI options like in your last example so I’m sure I’ll have a few more questions about those if I don’t get them working, but I think I get it now :slight_smile:

<?PHP $file = exo_return_hescriptcom("UserMain.ReadParamNumber|0", "Error"); $hash = hash_file( 'md5', $file ); if ($hash !== "") { echo "$hash\n"; }; ?>