General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Create toolbar button or macro to go to URL

  • meisenman

    Create toolbar button or macro to go to URL

    Participants 4
    Replies 5
    Last Activity 10 years, 4 months ago

    Looking for a way to add a toolbar button or create a macro that will open a specified web page.

    I'm not an XMetaL expert or a programmer; just a user who wants to make things easier for my colleagues.

    Using XMetaL Author 4.6.12.177 (no further description in Help > About or on splash screen).

    Many thanks.

    Reply

    Derek Read

    Reply to: Create toolbar button or macro to go to URL

    Do you mean a specific (ie: never changing) web page, or a specified (ie: by the user each time) web page?

    Can I also assume you wish their default browser to launch and open the page?

    Reply

    Derek Read

    Reply to: Create toolbar button or macro to go to URL

    There's an API for that:

    //JScript:
    Application.ShowPage("strURL");

    Where strURL is the page you wish to display.

    If the user has never specified the path to a browser (they would need to have selected File > Preview in Browser) then they will be prompted to provide that path when this API is first called. That value is saved in their per-user copy of xmetal##.ini (in your case xmetal46.ini).

    Using the Windows Script Host “Run” API:

    The alternative would be to “run” the URL and allow Windows to decide which application to launch based on the user's file associations or the format of the URL. It may or may not launch a browser though it should for most people. Example:

    //JScript:
    var oWSH = new ActiveXObject("WScript.Shell");
    oWSH.Run("http://www.xmetal.com");
    oWSH = null;

    Reply

    meisenman

    Reply to: Create toolbar button or macro to go to URL

    Yes, there is a specific, never-changing URL, and default browser would be fine.

    URL = http://ussm-infodev2.corp.company.com:8031/termcontribution.html

    I don't know APIs. How would I specify it in a macro or toolbar button? Sorry, that's the best I can do.

    Edit: If it can't be done within the XMetaL client UI, I'll have to ask our tools group to help.

    Reply

    Derek Read

    Reply to: Create toolbar button or macro to go to URL

    If your “tools group” builds customizations for XMetaL then they should probably do this for you. That way they can integrate this into what they have built without fear of having their code broken.

    You will need to create an MCR file containing code similar to what I have specified (or modify an existing one). You can do that with any text editor if you don't have XMetaL Developer but you need to get the format correct (it is pretty obvious once you open an MCR file and have a look). A user initiated macro can be given any name as long as it isn't the name of an event macro (which are predefined and described in the XMetaL Developer Programmers Guide).

    It might be as simple as dropping an MCR file with content similar to this into the Startup folder in your XMetaL Author installation path:


    Application.ShowPage("http://ussm-infodev2.corp.company.com:8031/termcontribution.html");
    ]]>

    var oWSH = new ActiveXObject("WScript.Shell");
    oWSH.Run("http://ussm-infodev2.corp.company.com:8031/termcontribution.html");
    oWSH = null;
    ]]>

    Generally speaking, user initiated macros like this do not conflict with other customizations, unless there happens to be a naming collision on the macro name.

    If you want to create a button for it follow the instructions in the help topic “Associate a macro with a toolbar button” (that part you can do in XMetaL Author's UI).

    Reply

    meisenman

    Reply to: Create toolbar button or macro to go to URL

    Thanks for the info, Derek. I'll pass it on.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support