Skip to content

Instantly share code, notes, and snippets.

@Vexcited
Last active September 24, 2023 22:31
Show Gist options
  • Save Vexcited/84be95289e5aee87dce10b8f3d957e69 to your computer and use it in GitHub Desktop.
Save Vexcited/84be95289e5aee87dce10b8f3d957e69 to your computer and use it in GitHub Desktop.
Run an Alt+Tab on Boosteroid when the game get in background

Boosteroid ALT+TAB

This script can be used when your game gets in background (when the game opens a window for example).

Where have you found the key codes ?

The key codes for ALT and TAB - and every other key codes btw - are taken from https://keycode.info/table-of-all-keycodes.

Usage

Here is the minifed script:

javascript:void%20function(){(async()=%3E{function%20a(a){return%20new%20Promise(b=%3E{setTimeout(b,a)})}async%20function%20b(){c({isPressed:!0,code:9}),await%20a(100),c({isPressed:!1,code:9}),await%20a(100)}const%20c=({isPressed:a,code:b})=%3ESessionHandler.sendEvents({type:%22keyboard%22,action:%22button%22,isPressed:a,code:b});c({isPressed:!0,code:18}),await%20a(100);const%20d=document.createElement(%22div%22),e=document.createElement(%22button%22);e.innerText=%22TAB%22,e.onclick=async()=%3E{await%20b()};const%20f=document.createElement(%22button%22);f.innerText=%22Confirm%20and%20close%22,f.onclick=async()=%3E{c({isPressed:!1,code:18}),await%20a(100),d.remove()},d.style.bottom=%2225px%22,d.style.width=%22100vw%22,d.style.left=%220%22,d.style.zIndex=%22999%22,d.style.position=%22fixed%22,d.style.display=%22flex%22,d.style.flexDirection=%22column%22,d.style.gap=%2224px%22,e.style.padding=%224px%208px%22,f.style.padding=%224px%208px%22,d.appendChild(e),d.appendChild(f),document.body.append(d)})()}();

If you don't trust it, minify the code below (in the other file) yourself by using this tool.

Two methods

  • Slow method: Copy the minifed script and paste it the URL bar (don't forget the javascript: at the beginning).
  • Fast method: Copy the minifed script and create a bookmark with the URL in it (don't forget the javascript: at the beginning).
    • Using this method, you'll be able to run the script by clicking on the bookmark.

When you run the script, it will press ALT.

Now you'll have two buttons on the screen...

  • "TAB": When you press it, it will send TAB.
  • "Close and confirm": This will release the ALT key and remove the helper from Boosteroid.

Have fun !

Now you can go back on your game, even if the game have opened another window !

By the way !, you'll see a CMD running the ALT+TAB menu that's called boosteroid-experience. DON'T CLOSE IT, or your session will be automatically stopped.

(async () => {
const sendKeyboardEvent = ({ isPressed, code }) => SessionHandler.sendEvents({
type: "keyboard",
action: "button",
isPressed,
code
});
function delay (ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
// Press TAB (9) and release TAB.
async function pressTab () {
sendKeyboardEvent({ isPressed: true, code: 9 });
await delay(100);
sendKeyboardEvent({ isPressed: false, code: 9 });
await delay(100);
}
// Press ALT (18)
sendKeyboardEvent({ isPressed: true, code: 18 });
await delay(100);
const altTabHelperContainer = document.createElement("div");
const buttonTabPressElement = document.createElement("button");
buttonTabPressElement.innerText = "TAB";
buttonTabPressElement.onclick = async () => {
await pressTab();
};
const buttonConfirmElement = document.createElement("button");
buttonConfirmElement.innerText = "Confirm and close";
buttonConfirmElement.onclick = async () => {
// Release ALT.
sendKeyboardEvent({ isPressed: false, code: 18 });
await delay(100);
// Remove helper from DOM.
altTabHelperContainer.remove();
};
// Styling.
altTabHelperContainer.style.bottom = "25px";
altTabHelperContainer.style.width = "100vw";
altTabHelperContainer.style.left = "0";
altTabHelperContainer.style.zIndex = "999";
altTabHelperContainer.style.position = "fixed";
altTabHelperContainer.style.display = "flex";
altTabHelperContainer.style.flexDirection = "column";
altTabHelperContainer.style.gap = "24px";
buttonTabPressElement.style.padding = "4px 8px";
buttonConfirmElement.style.padding = "4px 8px";
altTabHelperContainer.appendChild(buttonTabPressElement)
altTabHelperContainer.appendChild(buttonConfirmElement);
document.body.append(altTabHelperContainer);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment