GeExecuteFile to open specific webpage?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/04/2009 at 18:59, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:    Mac  ;  
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hi,
       I'm trying to open a plugin-registration-page in a user's default browser via coffee when they click a "register now" button in a GeUserDialog... I've hit a snag.
       I would really like to do this in a direct manner, e.g., the way one can open Maxon's pages using CallCommand(13681) as indicated in "Basic Functions" of the coffeeSDK, but I've searched the SDK and the Cafe archives and can't find a function that simply fires up a website.
       As a workaround, I have my plugin write a .url file and then try to open that file with GeExecuteFile(filepathToURLfile.url). This works great on my mac, but when I try it on a fresh mac, the GeExecuteFile() tries to open the file in its creator program, C4D, rather than a default browser and returns a C4D error of unrecognizable file format. To make it work, I need to use the macOSx system finder to 'get info' on any old example .url file and then select a browser under "Open with:" and say apply to all files of this type in the system's file info window.
       I have no idea what would happen on a Windows machine, but I suspect it Windows would be more .suffix dependent and would open the file correctly, eh?
       Surely there is a better way to pull off this simple task with coffee. I appreciate any suggestions.
    Thanks,
    Graham

    TextDialog("You pressed OK! Now you'll register in your favorite browser.", DLG_OK);               
    var vFilenameWeb = GeGetRootFilename();
    vFilenameWeb->RemoveLast();
    vFilenameWeb->AddLast("PDBSurfReg");
    vFilenameWeb->SetSuffix("url");
    var vBaseFile = new(BaseFile);
    vBaseFile->Open(vFilenameWeb, GE_WRITE);
    var vStr = "[InternetShortcut]\n\nURL=http://www.fivth.com/\n\nWorkingDirectory=C:\WINDOWS\ \n\nShowCommand=7\n\nIconIndex=1\n\nIconFile=C:\WINDOWS\SYSTEM\url.dll\n\nModified=20F06BA06D07BD014D\n\nHotKey=1601";
    var test = vBaseFile->WriteString(vStr);
    var myString = ReturnFileAsString(vFilenameWeb);
    vBaseFile->Close();
         var file = new(Filename);
         file->SetFullString(vFilenameWeb);
         var i = GeExecuteFile(file); // this fails if mac users have not set .url files to open with a browser by default!
         println("file executed = ", i);
         return;



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/04/2009 at 20:19, xxxxxxxx wrote:

    The problem with GeExecuteFile() is that what application is called depends upon the associations between the file types and applications (as you note). Unfortunately, GeExecute() doesn't take arguments so you can't call the default browser with a file as an argument either.

    On Windows, I use a .bat (batch) file and call it to execute an application with a particular file as argument.

    In the C++ SDK, one can use a web view custom gui to show a URL in a Cinema 4D dialog window directly or GeOpenHTML() to open a URL (string) in the default browser.

    You may need to find a similar 'batch' approach for the Mac (AppleScript?). Not on my Mac at the moment but maybe one can make a file-level association with an application? Otherwise, COFFEE doesn't have as many options in this direction.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/04/2009 at 06:38, xxxxxxxx wrote:

    On Mac call an Apple script file.

    Such as (In AppleScript file) :

    > \> property target_URL : "http://www.mycoolplace.com/" \> \> open location target_URL \>

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/04/2009 at 14:22, xxxxxxxx wrote:

    Thanks for the feedback guys. Two updates:

    1. I tested a .url file created with notebook on a windows machine as well as .url files generated by my original script (above) on my mac set both to Open with Safari as default and a copy of the .url set to open with C4D by default. Windows opened both properly (curiously in Firefox rather than explorer,) so I think the .url suffix dominates on that system.
    2. On a Mac, I've generated apple scripts as suggested by Lennart, but unless they are compiled into an "applescript application", they just open ScriptEditor. Even if I try to cheat and copy the compiled code, into a new file with an .app tag on, my mac says it can't open a "classic application" file in OS10.5. I'm sure I'm just doing something wrong.
         In the past, I've called to an Apple Automator file from C4D to download userinput from the web and it worked great, so I'll look into that option.
    3. I guess my current options are to create a second file for the user to download with my .cob file that will contain a compiled script or automator file, but I'd really rather keep it simple and allow users to just grab a single file. On second thought, I'll probably create a small library of plugins that have functionality similar to this one, so a zipped folder to organize them and with a Readme might not be a bad approach.


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/04/2009 at 15:23, xxxxxxxx wrote:

    Quick test on a mac shows that an html redirect file seems to work...danger of it opening in something like Dreamweaver, but I'll take that chance for now and will stick with the .url for Windows.

    <HEAD>
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.fivth.com/">
    </HEAD>



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/04/2009 at 13:42, xxxxxxxx wrote:

    Another update: creating a .html file in TextEdit and saving to the desktop works fine, but the same problem occurs if I create an identical file via my coffee code. The system writes C4D as the creator and tries to open it into C4D. It seems the only file that is default 100% recognized by a mac to open a browser is a .webloc file. These write the URL into the resource fork which I don't think I could access via Coffee, so instead I'm just packaging one with the plugin in a folder...lame. I do a test for the operating system and if its Windows I write the .url file, if mac, I open the included .webloc file.
    It was worth a try,
    Graham


Log in to reply