Jump to content

Any way to open a webpage URL in the user's default web browser


Zethrax
 Share

Recommended Posts

Hi. Is there any way in either the Leadwerks engine or the Lua implementation to open a webpage URL in the user's default web browser. Basically I'm looking to shell execute a URL.

 

For example, in Blitz3D I can use the code:-

 

Execfile "http://www.leadwerks.com/"

 

to shell execute the specified URL which will open the webpage in the user's default web browser.

 

In a project for a free advergame I'm working on in Blitz3D I have a couple of main menu links to open the game project's website and to open the website for the advertised product. I'm considering porting that project to Leadwerks, but if I can't open a webpage from my program then it ends up being a deal killer for an advertising supported game.

Link to comment
Share on other sites

No, but if you look in the BMX module you can find how to do it:

int bbOpenURL( BBString *url ){
int n;
if( _usew ){
n=(int)ShellExecuteW( 0,0,(wchar_t*)bbTmpWString(url),0,0,10 )>32; //SW_SHOWDEFAULT
}else{
n=(int)ShellExecuteA( 0,0,bbTmpCString(url),0,0,10 )>32; //SW_SHOWDEFAULT
}
return n;
}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

If that does not work, you can try to call it with a lua library.

 

i made a small one with some additional functions. (was mostly just playing around with it)

 

Have uploaded it for you here:

https://cloud.software-sl.de/index.php/s/JLiv6hkd9koCLms

 

You have to extract the files where your executable is

and add import("LEAddon.lua") to your App.lua or Main.lua at the beginning.

 

Then you can call something like

addon.Execute("http://www.google.de") and the default browser is started.

 

It has a couple of other functions but as i said i where mostly playing around with it and not everything will work.

 

You will have to disable sandbox Lua though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...