Pages: 1
Print
Author Topic: Create toolbar button or macro to go to URL  (Read 4574 times)
meisenman
Member

Posts: 3


« on: May 18, 2012, 12:12:55 PM »

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.
« Last Edit: May 18, 2012, 12:32:20 PM by meisenman » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: May 18, 2012, 01:38:25 PM »

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?
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #2 on: May 18, 2012, 01:50:55 PM »

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;
« Last Edit: May 18, 2012, 02:16:55 PM by Derek Read » Logged
meisenman
Member

Posts: 3


« Reply #3 on: May 18, 2012, 02:26:26 PM »

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.
« Last Edit: May 18, 2012, 02:46:17 PM by meisenman » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #4 on: May 18, 2012, 03:04:30 PM »

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:

<?xml version="1.0"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">

<MACROS>

<MACRO name="Demo1: Open Web Page" lang="JScript" hide="true"><![CDATA[
   Application.ShowPage("http://ussm-infodev2.corp.company.com:8031/termcontribution.html");
]]></MACRO>

<MACRO name="Demo2: Open Web Page" lang="JScript" hide="true"><![CDATA[
   var oWSH = new ActiveXObject("WScript.Shell");
   oWSH.Run("http://ussm-infodev2.corp.company.com:8031/termcontribution.html");
   oWSH = null;
]]></MACRO>

</MACROS>


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).
Logged
meisenman
Member

Posts: 3


« Reply #5 on: May 18, 2012, 03:07:11 PM »

Thanks for the info, Derek. I'll pass it on.
Logged
Pages: 1
Print
Jump to: