Skip to content

Instantly share code, notes, and snippets.

@maxwellainatchi
Last active February 3, 2021 05:09
Show Gist options
  • Save maxwellainatchi/794d22c2c24f98d5dc8e6abc7ccc8a92 to your computer and use it in GitHub Desktop.
Save maxwellainatchi/794d22c2c24f98d5dc8e6abc7ccc8a92 to your computer and use it in GitHub Desktop.
Random Galaxy Game

Random Galaxy Game launcher

Opens the game page of a random game you own from your GOG library, including from third-party plugins.

Works by pulling data from GOG's internal SQLite DB and then using their URI handler to open the game by its unique identifier. GOG may change the structure of these at any time, so this may stop working without warning.

This Gist is licensed under the MIT license.

Installing SQLite3 (required)

In order to pull data from the internal database, you need access to sqlite3. Here are install instructions. I'm working on trying to bundle these directly into an EXE so that less technical people can get this working without needing to install anything. If anyone has any suggestions on how, let me know!

Packaging into an EXE (and hiding the command prompt window)

If like me, the command prompt window bugs you, you can use iexpress.exe (bundled with windows) to turn this into an exe file and hide the command prompt window entirely. It also appears to make it a bit faster (probably because of the time to launch command prompt and create the window).

Steps

  1. Download the cmd file below
  2. Launch iexpress.exe AS AN ADMINISTRATOR
  3. Press next until you get to "Package title", type whatever you want (this is never shown)
  4. Press next until you get to "Packaged files", and select the cmd file wherever you downloaded it.
  5. Press next, and under "Install Program" write cmd /c "Random Galaxy Game.cmd"
  6. Press next, and under "Show window" press "hidden"
  7. Press next until you get to the "package name and options" page. Select both of the options, and in the file select box enter where you want your exe to be saved.
  8. Press next, and select "No restart"
  9. Press next and choose "Don't save"
  10. Press next, then finish.

MIT License

Copyright (c) 2020 Maxwell Ainatchi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@echo off
set statement="SELECT releaseKey from libraryreleases order by random() limit 1;"
for /f "usebackq tokens=*" %%a in (`sqlite3 %programData%\GOG.com\Galaxy\storage\galaxy-2.0.db %statement%`) do set releaseKey=%%a
start goggalaxy://openGameView/%releaseKey%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment