GameMaker: Fixing “%22http[s]” in url_open

If you've made a game with GameMaker during the past decade that opens web pages on some occasion, you might have been recently hearing complaints from players about the game no longer successfully doing so. This is a tiny post about what is that all about and how to fix it.

The problem

At some point there has been a change in Chromium code that removed support for quoting the URL when passing command-line arguments to the browser on Windows.

You can test this yourself by opening Command Prompt (cmd) and running the following:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" —single-argument "https://yal.cc"

(replace the browser path if needed)

Meanwhile, GameMaker had been adding double quotes around the URL since introduction of url_open functions in ~2011 - after all, that's how Windows works - if your parameter might have spaces in it, you add double quotes around it so that it doesn't get mixed up for two or more parameters.

By October 2020 the change made its way into Chrome and Edge beta builds and I tried to report the issue, but couldn't quite figure out what the deal was at the time (after all, registry values didn't change).

Closer to the end of the year this started rolling out into stable versions of browsers, at which point it became more widely reported and was fixed in GameMaker Studio 2.3.1 update.

All in all, if you have released a GameMaker game before 2021, it will now not open the browser correctly for a portion of the players.

The solution

As per above, you should generally consider updating to a more recent version of GameMaker, but if you cannot, you can use an extension I made to create an Internet Shortcut and open it, like so:

var _url = "https://yal.cc";
var _path = game_save_id + "/shortcut.url";
var _txt = file_text_open_write(_path);
// note: use '' instead of @'' in GMS1
file_text_write_string(_txt, @'[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=' + _url);
file_text_close(_txt);
execute_shell_simple(_path);

(which would seem like the safest way to handle this)


That's all!

Related posts:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.